nevvermind
nevvermind

Reputation: 3392

Zend Application not fully bootstraped when testing with PHPUnit

Zend Framework 1.11.2
PHPUnit 3.5.10
PHP 5.3.1
NetBeans 6.9.1

  1. http://pastebin.com/L5bi9AgY
  2. I followed Lebensold's tutorial.

Testing works, even with things like
$this->dispatch('/');
$this->assertResponseCode(200);

, but as soon as I require a controller class (pastebin, #33) to instantiate it in the setUp() method, I get an error saying that PHPUnit didn't find the parent class (Zend_Controller_Action). So my guess is that I've somehow missed something in bootstrap, because I don't get all the classes loaded (?).

Also, when using the "@covers Class::method" annotation, I get the same type of error.

Any suggestions are welcomed. Thanks.

Upvotes: 0

Views: 434

Answers (1)

Marcin
Marcin

Reputation: 238647

Try requiring the controller class from within your setup, e.g.

    class SearchControllerTest extends ControllerTestCase {

        public function setUp() {

            parent::setUp();

            require_once(APPLICATION_PATH . '/controllers/SearchController.php');

        }
    }

I remember having similar problem and it worked this way.

Upvotes: 2

Related Questions