Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6808559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:58:16+00:00 2026-05-26T19:58:16+00:00

I am trying to learn about unit testing in Zend Framework. I have installed

  • 0

I am trying to learn about unit testing in Zend Framework. I have installed PHPunit (not without a few problems on the way).

I have also created a simple Zend/Doctrine 2 skeleton that works fine and successfully writes to the DB etc.

I just want to start using and understanding PHPunit, but it is giving strange errors. I have an empty IndexController that does absolutely nothing. I just want to assert that it exists. PHPunit throws up a huge list of errors relating to the Bootstrap, but the bootstrap works perfectly in practice.

It’s as if phpunit doesn’t respect my include paths.

ps. If you have already read this post, I have simplified the skeleton project and edited the code and errors below to reflect this. Hopefully this will make it easier to debug.

I think some code my help explain:

demian@dimbo-TP:/var/www/z2d2/tests$ phpunit --version
PHPUnit 3.6.3 by Sebastian Bergmann.


<?php
require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';

abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{

    public function setUp()
    {

      $this->bootstrap = new Zend_Application(
        'development',
        APPLICATION_PATH . '/configs/application.ini'
      );

        parent::setUp();
    }

    public function tearDown()
    {
      parent::tearDown();
    }

}


<?php

class IndexControllerTest extends ControllerTestCase
{

    public function testDoesHomePageExist() 
    {
        $this->dispatch('/');
        $this->assertController('index');
        $this->assertAction('index');

    }   

}

This is my simple bootstrap:

 <?php

    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {

      /**
       *
       *
       *
       *
       */
      protected function _initConfig()
      {

        $config = new Zend_Config($this->getOptions());
        Zend_Registry::set('config', $config);

      }

      /**
       *
       *
       *
       *
       */
      protected function _initDoctrine() {

        require_once('Doctrine/Common/ClassLoader.php');

        $autoloader = Zend_Loader_Autoloader::getInstance();
        $classLoader = new \Doctrine\Common\ClassLoader('Entities',
          realpath(Zend_Registry::get('config')->resources->entityManager->connection->entities), 'loadClass');

        $autoloader->pushAutoloader(array($classLoader, 'loadClass'), 'Entities');

        $classLoader = new \Doctrine\Common\ClassLoader('Repositories',
          realpath(Zend_Registry::get('config')->resources->entityManager->connection->entities), 'loadClass');

        $autoloader->pushAutoloader(array($classLoader, 'loadClass'), 'Repositories');    

      }

    }

And Now the Errors (Sorry for the length of it):

    demian@dimbo-TP:/var/www/z2d2/tests$ phpunit
PHPUnit 3.5.15 by Sebastian Bergmann.

PHP Fatal error:  Bootstrap::_initDoctrine(): Failed opening required 'Doctrine/Common/ClassLoader.php' (include_path='/var/www/z2d2/application/../views:.:/usr/share/php:/usr/share/php/:/usr/local/share/php/library') in /var/www/z2d2/application/Bootstrap.php on line 28
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:49
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:188
PHP   5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:305
PHP   6. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:693
PHP   7. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:733
PHP   8. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:757
PHP   9. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:576
PHP  10. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:666
PHP  11. ModelTestCase->setUp() /usr/share/php/PHPUnit/Framework/TestCase.php:626
PHP  12. Zend_Application->bootstrap() /var/www/z2d2/tests/application/models/ModelTestCase.php:16
PHP  13. Zend_Application_Bootstrap_BootstrapAbstract->bootstrap() /usr/local/share/php/library/Zend/Application.php:355
PHP  14. Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap() /usr/local/share/php/library/Zend/Application/Bootstrap/BootstrapAbstract.php:586
PHP  15. Zend_Application_Bootstrap_BootstrapAbstract->_executeResource() /usr/local/share/php/library/Zend/Application/Bootstrap/BootstrapAbstract.php:622
PHP  16. Bootstrap->_initDoctrine() /usr/local/share/php/library/Zend/Application/Bootstrap/BootstrapAbstract.php:669

Fatal error: Bootstrap::_initDoctrine(): Failed opening required 'Doctrine/Common/ClassLoader.php' (include_path='/var/www/z2d2/application/../views:.:/usr/share/php:/usr/share/php/:/usr/local/share/php/library') in /var/www/z2d2/application/Bootstrap.php on line 28

Call Stack:
    0.0002     326940   1. {main}() /usr/bin/phpunit:0
    0.0424     666604   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:49
    0.0424     667084   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
    0.0924    4311848   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:188
    0.1036    4751832   5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:305
    0.1037    4752248   6. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:693
    0.1038    4752576   7. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:733
    0.1038    4752576   8. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:757
    0.1040    4752576   9. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:576
    0.2036    4787392  10. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:666
    0.2082    4891936  11. ModelTestCase->setUp() /usr/share/php/PHPUnit/Framework/TestCase.php:626
    0.2567    5678688  12. Zend_Application->bootstrap() /var/www/z2d2/tests/application/models/ModelTestCase.php:16
    0.2568    5678732  13. Zend_Application_Bootstrap_BootstrapAbstract->bootstrap() /usr/local/share/php/library/Zend/Application.php:355
    0.2569    5678732  14. Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap() /usr/local/share/php/library/Zend/Application/Bootstrap/BootstrapAbstract.php:586
    0.2609    5699280  15. Zend_Application_Bootstrap_BootstrapAbstract->_executeResource() /usr/local/share/php/library/Zend/Application/Bootstrap/BootstrapAbstract.php:622
    0.2610    5699472  16. Bootstrap->_initDoctrine() /usr/local/share/php/library/Zend/Application/Bootstrap/BootstrapAbstract.php:669

Can anyone show me where I am going wrong? I even suspect that my PHPunit is not set up correctly

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:58:16+00:00Added an answer on May 26, 2026 at 7:58 pm

    I solved it in this way: it seems that PHPunit does not like the relative include paths in the main application bootstrap file – this is what causes the problem. So, in the testing bootstrap pointed to by phpunit.xml make sure you specify the include paths. I added these lines :

    set_include_path(
        '.'
        . PATH_SEPARATOR . BASE_PATH . '/library'
        . PATH_SEPARATOR . get_include_path()
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project I am trying to learn unit testing and TDD practices
Trying to learn about php's arrays today. I have a set of arrays like
I am trying to learn about Google maps API. I have a project that
I'm trying to learn about shift-reduce parsing. Suppose we have the following grammar, using
I've read a few threads on SO about usefulness of unit-testing various applications. The
I'm trying to learn more about Domain Driven Development including the Repository pattern, Unit
I have trying to learn about resources. In VS when I create the project:
I am somewhat new to jQuery but have been having fun trying learn about
I have been trying to learn a bit more about delegates and lambdas while
I am trying to learn more about Javascript, I have been coding with PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.