0

I'm using symfony 3 and PhpUnit 5.6.4. I'm testing my form with http://symfony.com/doc/master/form/unit_testing.html

My code is here but when I run phpunit I get:

Testing Test Suite PHP Fatal error: Call to undefined method Tests\AnnBundle\Form\Type\AnnTypeTest::createMock() in /media/mpf/mmf/tests/AnnBundle/Form/Type/AnnTypeTest.php on line 26 PHP Stack trace: PHP 1. {main}() /media/mpf/mmf/vendor/symfony/phpunit-bridge/bin/.phpunit/phpunit-4.8/phpunit:0

Thanks.

  • youve likely forgotton to extend the TypeTestCase class, or you have a use statement for the wrong one – DevDonkey Apr 10 '17 at 13:46
  • no, i extend TypeTestCase. I think that i must inject same extension that the ttc default not loads. – user3686739 Apr 10 '17 at 15:07
  • I update php versione to PHP 5.6 and PHPUnit version to 5.6.4 now i get: `Argument 1 passed to Symfony\Bridge\Doctrine\Form\Type\DoctrineType::__construct() must be an instance of Doctrine\Common\Persistence\ManagerRegistry, none given, called in /media/mpf/mmf/vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php on line 85 and defined /media/mpf/mmf/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:73` – user3686739 Apr 11 '17 at 10:28
  • Can you provide your `AnnTypeTest` class? – Kwadz Apr 12 '17 at 08:32
  • You are calling `createMock()` on your form type instead of your test. The error should be easy to spot as the method should basically only be called on `$this`. If it's called on anything else there is a high chance of it being wrong. – dbrumann Apr 13 '17 at 15:24
  • Thanks for reply. My test class is:
    [https://gist.github.com/anonymous/e0c4dacdcb71c9969a3d645986519543]
    – user3686739 Apr 13 '17 at 21:11
  • To avoid any confusion, please edit your question to include the tested class and its test, mention the current PHPUnit version and the error message that your are facing with the provided details. I would also suggest you to read [how do I ask a good question](https://stackoverflow.com/help/how-to-ask). – Kwadz Apr 13 '17 at 23:18
  • Your class is called Ann*unci*TypeTest and your error message says AnnTypeTest. Is this just a typo or do you accidentally have a file with that name and that is throwing the error instead? – dbrumann Apr 16 '17 at 14:18
  • Also phpunit 4.8 is a bit outdated. Try if there is a more up to date version in your vendor folder with `php vendor/bin/phpunit --version` and if so use that instead by running `php vendor/bin/phpunit tests/` – dbrumann Apr 16 '17 at 14:20

0 Answers0