On doctrine:fixtures:load if data-fixtures cannot get a reference will f... #90

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
5 participants
@entering

On doctrine:fixtures:load if data-fixtures cannot get a reference will fail with a undefined index.

I think this can be improve, to really pass the message undefined reference.

So I improved from this:
[ErrorException]
Notice: Undefined index: database_1_1 in /home/www/eb/platform/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ReferenceRepository.php line 145

To:
[Exception]
Undefined reference database_1_1

On doctrine:fixtures:load if data-fixtures cannot get a reference wil…
…l fail with a undefined index.

I think this can be improve, to really pass the message undefined reference.

So I improved from this:
[ErrorException]
Notice: Undefined index: database_1_1 in /home/www/eb/platform/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/ReferenceRepository.php line 145

To:
[Exception]
Undefined reference database_1_1
@stof

This comment has been minimized.

Show comment Hide comment
@stof

stof Feb 12, 2013

Member

Please add a unit test to avoid regression

Member

stof commented Feb 12, 2013

Please add a unit test to avoid regression

@stof

View changes

lib/Doctrine/Common/DataFixtures/ReferenceRepository.php
@@ -142,6 +142,9 @@ public function addReference($name, $object)
*/
public function getReference($name)
{
+ if (empty($this->references[$name])) {
+ throw new \Exception('Undefined reference ' . $name);

This comment has been minimized.

Show comment Hide comment
@stof

stof Feb 12, 2013

Member

You should use InvalidaArgumentException instead of Exception IMO

@stof

stof Feb 12, 2013

Member

You should use InvalidaArgumentException instead of Exception IMO

This comment has been minimized.

Show comment Hide comment
@guilhermeblanco

guilhermeblanco Feb 12, 2013

Owner

@stof +1

@guilhermeblanco

View changes

lib/Doctrine/Common/DataFixtures/ReferenceRepository.php
@@ -142,6 +142,9 @@ public function addReference($name, $object)
*/
public function getReference($name)
{
+ if (empty($this->references[$name])) {
+ throw new \Exception('Undefined reference ' . $name);
+ }

This comment has been minimized.

Show comment Hide comment
@guilhermeblanco

guilhermeblanco Feb 12, 2013

Owner

Missing line break after closing curly braces

@guilhermeblanco

guilhermeblanco Feb 12, 2013

Owner

Missing line break after closing curly braces

@entering

This comment has been minimized.

Show comment Hide comment
@entering

entering Feb 13, 2013

Changed to InvalidArgumentException and improved to instead use empty use the method hasReference (makes much more sense) and I updated PHPdoc (forget before).

About the regression test sounds good, but I just run the README and I think I made what is suppose to run the tests but without success, I would be glad to add a test if you can give me some help.

[eoliveira@localhost data-fixtures]$ pwd
/home/www/data-fixtures
[eoliveira@localhost data-fixtures]$ curl -s https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /home/www/data-fixtures/composer.phar
Use it: php composer.phar
[eoliveira@localhost data-fixtures]$ php composer.phar install --dev
Loading composer repositories with package information
Installing dependencies
  - Installing doctrine/common (2.3.0)
    Loading from cache

Loading composer repositories with package information
Installing dev dependencies
  - Installing symfony/console (v2.1.7)
    Loading from cache

  - Installing doctrine/dbal (2.3.2)
    Loading from cache

  - Installing doctrine/orm (2.3.2)
    Loading from cache

doctrine/orm suggests installing symfony/yaml (If you want to use YAML Metadata Mapping Driver)
Writing lock file
Generating autoload files
[eoliveira@localhost data-fixtures]$ cp phpunit.xml.dist phpunit.xml
[eoliveira@localhost data-fixtures]$ phpunit 
PHPUnit 3.7.9 by Sebastian Bergmann.

Configuration read from /home/www/data-fixtures/phpunit.xml

..PHP Fatal error:  Maximum function nesting level of '100' reached, aborting! in /home/www/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php on line 129
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/pear/PHPUnit/TextUI/Command.php:129
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/pear/PHPUnit/TextUI/Command.php:176
PHP   5. PHPUnit_Framework_TestSuite->run() /usr/share/pear/PHPUnit/TextUI/TestRunner.php:346
PHP   6. PHPUnit_Framework_TestSuite->run() /usr/share/pear/PHPUnit/Framework/TestSuite.php:705
PHP   7. PHPUnit_Framework_TestSuite->runTest() /usr/share/pear/PHPUnit/Framework/TestSuite.php:745
PHP   8. PHPUnit_Framework_TestCase->run() /usr/share/pear/PHPUnit/Framework/TestSuite.php:775
PHP   9. PHPUnit_Framework_TestResult->run() /usr/share/pear/PHPUnit/Framework/TestCase.php:769
PHP  10. PHPUnit_Framework_TestCase->runBare() /usr/share/pear/PHPUnit/Framework/TestResult.php:648
PHP  11. PHPUnit_Framework_TestCase->runTest() /usr/share/pear/PHPUnit/Framework/TestCase.php:824
PHP  12. ReflectionMethod->invokeArgs() /usr/share/pear/PHPUnit/Framework/TestCase.php:969
PHP  13. Doctrine\Tests\Common\DataFixtures\DependentFixtureTest->test_orderFixturesByDependencies_circularReferencesMakeMethodThrowCircularReferenceException() /usr/share/pear/PHPUnit/Framework/TestCase.php:969
PHP  14. Doctrine\Common\DataFixtures\Loader->addFixture() /home/www/data-fixtures/tests/Doctrine/Tests/Common/DataFixtures/DependentFixtureTest.php:105
PHP  15. Doctrine\Common\DataFixtures\Loader->addFixture() /home/www/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php:142

Changed to InvalidArgumentException and improved to instead use empty use the method hasReference (makes much more sense) and I updated PHPdoc (forget before).

About the regression test sounds good, but I just run the README and I think I made what is suppose to run the tests but without success, I would be glad to add a test if you can give me some help.

[eoliveira@localhost data-fixtures]$ pwd
/home/www/data-fixtures
[eoliveira@localhost data-fixtures]$ curl -s https://getcomposer.org/installer | php
#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /home/www/data-fixtures/composer.phar
Use it: php composer.phar
[eoliveira@localhost data-fixtures]$ php composer.phar install --dev
Loading composer repositories with package information
Installing dependencies
  - Installing doctrine/common (2.3.0)
    Loading from cache

Loading composer repositories with package information
Installing dev dependencies
  - Installing symfony/console (v2.1.7)
    Loading from cache

  - Installing doctrine/dbal (2.3.2)
    Loading from cache

  - Installing doctrine/orm (2.3.2)
    Loading from cache

doctrine/orm suggests installing symfony/yaml (If you want to use YAML Metadata Mapping Driver)
Writing lock file
Generating autoload files
[eoliveira@localhost data-fixtures]$ cp phpunit.xml.dist phpunit.xml
[eoliveira@localhost data-fixtures]$ phpunit 
PHPUnit 3.7.9 by Sebastian Bergmann.

Configuration read from /home/www/data-fixtures/phpunit.xml

..PHP Fatal error:  Maximum function nesting level of '100' reached, aborting! in /home/www/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php on line 129
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/pear/PHPUnit/TextUI/Command.php:129
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/pear/PHPUnit/TextUI/Command.php:176
PHP   5. PHPUnit_Framework_TestSuite->run() /usr/share/pear/PHPUnit/TextUI/TestRunner.php:346
PHP   6. PHPUnit_Framework_TestSuite->run() /usr/share/pear/PHPUnit/Framework/TestSuite.php:705
PHP   7. PHPUnit_Framework_TestSuite->runTest() /usr/share/pear/PHPUnit/Framework/TestSuite.php:745
PHP   8. PHPUnit_Framework_TestCase->run() /usr/share/pear/PHPUnit/Framework/TestSuite.php:775
PHP   9. PHPUnit_Framework_TestResult->run() /usr/share/pear/PHPUnit/Framework/TestCase.php:769
PHP  10. PHPUnit_Framework_TestCase->runBare() /usr/share/pear/PHPUnit/Framework/TestResult.php:648
PHP  11. PHPUnit_Framework_TestCase->runTest() /usr/share/pear/PHPUnit/Framework/TestCase.php:824
PHP  12. ReflectionMethod->invokeArgs() /usr/share/pear/PHPUnit/Framework/TestCase.php:969
PHP  13. Doctrine\Tests\Common\DataFixtures\DependentFixtureTest->test_orderFixturesByDependencies_circularReferencesMakeMethodThrowCircularReferenceException() /usr/share/pear/PHPUnit/Framework/TestCase.php:969
PHP  14. Doctrine\Common\DataFixtures\Loader->addFixture() /home/www/data-fixtures/tests/Doctrine/Tests/Common/DataFixtures/DependentFixtureTest.php:105
PHP  15. Doctrine\Common\DataFixtures\Loader->addFixture() /home/www/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php:142

@tPl0ch tPl0ch referenced this pull request Sep 21, 2013

Closed

Fixing failing test cases and Loader issues. #116

6 of 7 tasks complete
@lavoiesl

This comment has been minimized.

Show comment Hide comment
@lavoiesl

lavoiesl Mar 23, 2015

Member

Fixed by #179

Member

lavoiesl commented Mar 23, 2015

Fixed by #179

@lavoiesl lavoiesl closed this Mar 23, 2015

@lavoiesl lavoiesl added the Duplicate label Mar 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment