Vra

Is daar iemand hier gebruik Zend Framework, ZFDoctrine en PHPUnit saam?

Hoe om die databasis op elke toetslopie herbou? Hoe om te skei plaaslike / produksie / toets omgewings?

Wil jy jou eenheid toets opstel deel?

Ek het probeer so iets:

// /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);

Maar dit eindig 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

modelle is nie gegenereer.

Ek kry soortgelyke foute loop:

$provider->createDatabase();

Maar in hierdie geval databasis geskep.
Die ander bevele nie werk nie.


Die oplossing:

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

As iemand 'n beter benadering weet, asseblief korrek my.

Was dit nuttig?

Oplossing

Ek het nie gebruik ZFDoctrine, maar net plain Doctrine 1.2. Ek weet nie of my oplossing is beter, maar ek het gedink ek 'n boodskap as Enige 1 belangstel, hier is die bootstrap.php in my toetse gids:

<?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"));

Die sleutel hier is eintlik die laaste reël dat rebuild al databasisse skep van 'n skoon omgewing vir elke toets.

Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top