php - Running symfony unit test returns "There is no open connection" -
During the unit test run the Symphony may have a problem opening the database connection I have specified in my test env config / Databases.yml:
All: Principle: Category: sfDoctrineDatabase Ultimate: DSN: 'mysql: Host = Local Host; Dbname = ms 'Username: MS Password: xxx test: Principle: Category: sfDoctrineDatabase param: dsn:' mysql: host = localhost; dbname = ms' Username: MS Password: xxx ...
test file (test / unit / Mstiiti.afpi) looks like the following:
require_once dirname (__ file __ ). '/ .. / bootstrap / unit.php'; $ A = new paragraph (); $ A-> setHeadline ("Article Title"); $ A-> save ();
When I try to run a test using "Symphony Test: Unit MS" then it is only "no open connection" and it exits. Running trial alone (php test / unit / MSTest.php) returns full stack trace:
C: \ phpworkspace \ MS> php test / unit / MSTest.php serious error: Do not come with the exception of 'Doctrine_Connection_Exception' message of 'no open connection': \ Phpworkspace \ ms \ lib \ vendor \ symfony \ lib \ plugins \ sfDoctrinePlugin \ lib \ vendor \ theory \ theory \ Manager.php: 662 stack trace: # 0 C: \ phpworkspace \ ms \ lib \ vendor \ symphony \ lib \ plugins \ sfDoctrinePlugin \ lib \ vendor \ principle \ theory \ Manager.php (557): Doctrine_Manager-> getCurrentConnection () # 1 C: \ phpworkspace \ ms \ lib \ vendor \ symfony \ lib \ plugins \ sfDoctrinePlugin \ lib \ vendor \ Theory \ Theory \ core.php (1095): Doctrine_Manager-> getConnectionForComponent ( 'article') # 2 C: \ phpworkspace \ ms \ lib \ vendor \ symfony \ lib \ plugins \ sfDoctrinePlugin \ lib \ vendor \ theory \ theory \ Record.php (219): Doctrine_Core :: receivable ( 'article') # 3 C: \ phpworkspace \ ms \ test \ unit \ UniversalDemoTest.php (15): Doctrine_Record -> __ construct () # 4 was thrown into {main} C: \ phpworkspace \ ms \ lib \ vendor \ Symfony \ lib \ Plugins \ sfDoctrinePlugin \ lib In the place \ vendor \ doctrine \ Doctrine \ Manager.php line 662
I googled it around and looks like all the signals to the database.yml test directly: The environment (look up) is in place . I have tested the username / password / db name on the command line and the user authentication is valid. Change the line in unit.php to
$ configuration = ProjectConfiguration :: hasActive ()? Project Configuration :: getActive (): New project configuration (actual path ($ _ test_dir. '/ ..'));
to
$ configuration = project configuration :: getApplicationConfiguration ('front end', 'test', true);
But in my case it does not seem that it loads configuration in both cases, but returns different objects (print_a ($ configuration) as the result - new replacement line cases Project configuration in case of default and frontend configuration; In the last one, all the proper configuration instructions (app_xxx from the app.xxx file) occur. Please advice - Where else can I see? I am cleaning my cache (symphony cc), preparing a separate database for testing, reloading models / fixtures and so far nothing works; the models are valid and already available everywhere Used in the application, so it has to do something with the test environment.
I am running with PHP 5.3.1, mysql 5.1.41 symfony 1.4 (
thanks.
You need to start the database manager to use the theory Model Classes:
$ Configuration = Project Configuration :: getApplicationConfiguration 'Foreground', 'test', is true); new sfDatabaseManager ($ configuration);
Comments
Post a Comment