views:

36

answers:

1

Hi

I have been going mad with this, I have found some threads on this but none of them solve my problem.

I have my bootstrap.php file for testing which looks like this

define("PHPUNIT", true);
require_once("/Applications/XAMPP/xamppfiles/htdocs/Common/test/public/index.php");

My index.php file does not call run() on the application object if PHPUNIT is defined. Is this correct to stop the application from being dispatched?

I have a test file called homepage.php, this contains a class which extends Zend_Test_PHPUnit_ControllerTestCase - this class cannot be found when I run phpunit, even when I include the file with an absolute path.

Running file_exists() on the same string returns true. I run phpunit using the --bootstrap flag with my bootstrap.php file on the test file homepage.php which is below

require_once("/Applications/XAMPP/xamppfiles/htdocs/libs_php/ZendFramework-1.10.7/library/Zend/Test/PHPUnit/ControllerTestCase.php");

class HomepageControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
    public function appBootstrap()  
    {
        $controller = $this->getFrontController();

        $controller->registerPlugin(new Default_Controller_Plugin_Initialise());
    }

    public function setUp()
    {
        $this->bootstrap = array($this, 'appBootstrap');

        parent::setUp();        
    }

    public function testA()
    {
        $this->dispatch('/');
        $this->assertController('index');
    }
}

The output from phpunit I get is below, how can the class not be found? It doesn't look like a PHP error, but something from PHPUnit - there is no line number?

PHPUnit 3.3.2 by Sebastian Bergmann.

Class Zend_Test_PHPUnit_ControllerTestCase could not be found in /Applications/XAMPP/xamppfiles/htdocs/Common/test/tests/library/homepage.php

Thanks for any help on this!

A: 

I never got my tests working in this manner.

I started again and followed this video - which is excellent.

jakenoble