Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 3 commits into from
Closed

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

wants to merge 3 commits into from

Conversation

eduardosoliv
Copy link

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

…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
Copy link
Member

stof commented Feb 12, 2013

Please add a unit test to avoid regression

@@ -142,6 +142,9 @@ public function addReference($name, $object)
*/
public function getReference($name)
{
if (empty($this->references[$name])) {
throw new \Exception('Undefined reference ' . $name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use InvalidaArgumentException instead of Exception IMO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof +1

@eduardosoliv
Copy link
Author

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

@lavoiesl
Copy link
Member

Fixed by #179

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

Successfully merging this pull request may close these issues.

5 participants