Welcome Guest, Not a member yet? Register   Sign In
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0
#8

[eluser]rubdottocom[/eluser]
Hi!

Whoah Kenji, thanks for the amazing work!

I'm close to make it work, I have a problem with a simple test of a controller

This is my controller
Code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends MY_Controller {

    function __construct()
    {
        parent::__construct();
  $this->load->helper('json');
    }
public function view($page = 'home')
{
  log_message('debug', 'Page: '. $page);
  if ( ! file_exists('application/views/pages/'.$page.'.php'))
  {  
   show_404(); // Whoops, we don't have a page for that!
  }
  
  $data['sections'] = $this->get_sections_master();
  
  $this->load->view('templates/header', $data);
  $this->load->view('templates/sidebar', $data);
  $this->load->view('pages/'.$page, $data);
  $this->load->view('templates/footer', $data);
  
}
... Other stuff

And this my test:
Code:
<?php

/**
* @group Controller
*/

class SomeControllerTest extends CIUnit_TestCase
{
public function setUp()
{
  // Set the tested controller
  $this->CI = set_controller('Home');
}

public function testWelcomeController()
{
  // Call the controllers method
  //$this->CI->index();
  $this->CI->view('home');
  
  // Fetch the buffered output
  $out = output();
  
  // Check if the content is OK
  $this->assertSame(0, preg_match('/(error|notice)/i', $out));
}
}

When I run phpunit I receive 404 Message because the
Code:
if ( ! file_exists('application/views/pages/'.$page.'.php'))

But the file exists and if I try to open in a browser works fine, I miss something? :-(


Messages In This Thread
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 01-16-2012, 06:38 PM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 01-18-2012, 08:51 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 01-18-2012, 09:12 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 01-18-2012, 10:04 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 01-22-2012, 07:18 PM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 01-22-2012, 08:07 PM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 01-23-2012, 05:06 PM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 02-08-2012, 04:42 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 02-08-2012, 05:07 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 02-08-2012, 06:13 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 02-13-2012, 10:20 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 03-08-2012, 07:26 PM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 05-05-2012, 06:48 PM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 05-25-2012, 06:25 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 09-03-2012, 10:56 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 09-30-2012, 02:27 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-06-2012, 05:45 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-11-2012, 09:11 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-11-2012, 09:47 PM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-14-2012, 12:54 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-17-2012, 09:07 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-20-2012, 12:37 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-22-2012, 09:56 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-23-2012, 10:27 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 10-27-2012, 12:56 AM
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - by El Forum - 03-11-2013, 11:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB