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

  • Home
  • SEARCH
  • 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 3757664
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:02:31+00:00 2026-05-19T10:02:31+00:00

Does anyone here use Zend Framework, ZFDoctrine and PHPUnit together? How to rebuild the

  • 0

Does anyone here use Zend Framework, ZFDoctrine and PHPUnit together?

How to rebuild the database on each test run?
How to separate local/production/testing environments?

Would you share your unit testing setup?

I have been trying something like that:

// /tests/bootstrap.php
// ... setup paths and constants here
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);

$application->bootstrap('doctrine');
$provider = new ZFDoctrine_Tool_DoctrineProvider;
$provider->generateModelsFromYaml();
//$provider->buildProject(true);

But this ends in:

Notice: Constant APPLICATION_PATH already defined in /home/user/www/library/ZendFramework/1.10.7/library/Zend/Tool/Project/Context/Zf/BootstrapFile.php on line 106

Fatal error: Call to a member function getResponse() on a non-object in /home/user/www/library/zf-doctrine/library/ZFDoctrine/Tool/DoctrineProvider.php on line 271

Models are not generated.

I get similar errors running:

$provider->createDatabase();

But in this case database is created.
The other provider commands do not work.


The solution:

$provider = new ZFDoctrine_Tool_DoctrineProvider;
$registry = new Zend_Tool_Framework_Registry;
$provider->setRegistry($registry);
@$provider->buildProject(true);

If anybody knows a better approach, please correct me.

  • 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-19T10:02:32+00:00Added an answer on May 19, 2026 at 10:02 am

    I haven’t used ZFDoctrine, but just plain Doctrine 1.2. I don’t know if my solution is better but I figured I post if any1 is interested, here’s the bootstrap.php in my tests folder:

    <?php
    
    // Define path to application directory
    defined('APPLICATION_PATH')
        || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
    
    // Define application environment
    /**
     * In the application.ini:
    [testing : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    doctrine.dsn = "mysql://my_user:passwd@localhost/my_phpunit_test_db"
     */
    define('APPLICATION_ENV', 'testing');
    
    // Ensure library/ is on include_path
    set_include_path(implode(PATH_SEPARATOR, array(
        realpath(APPLICATION_PATH . '/../library'),
        get_include_path()
    )));
    
    /** Zend_Application */
    require_once 'Zend/Application.php';
    
    // Create application, bootstrap, and run
    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH . '/../configs/application.ini'
    );
    
    $application->getBootstrap()->bootstrap();
    
    // Can run out if too small
    ini_set('memory_limit', '512M');
    
    // Get the doctrine settings
    $config = $application->getOption('doctrine');
    $cli = new Doctrine_Cli($config);
    $cli->run(array("doctrine", "build-all-reload","force"));
    

    The key here is actually the last line that rebuilds all databases creating a clean environment for each testing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone here use VB.NET and have a strong preference for or against using
Does anyone here use Spec# regularly? I would like to know if it is
Does anyone here use Dreamweaver for Struts development? I've been working on a web
Does anyone here has any experience on how to send HTML emails that renders
Does anyone here know SVG? If so, how did you learn it? Any books/tutorial
Does anyone have experience using the URL Rewrite Module (see here )? Can it
Does anyone know how to change the Bordercolor for a Datagridviewcell in c#? Here's
See here: http://code.google.com/p/ie7-js/ Does anyone have any experience or remarks about this javascript? Is
Hope here are some with more knowledge about Zend Framework than me, I've been
Does anyone remember the XMP tag? What was it used for and why was

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.