You may get the same error if you expect the @covers annotation to work with a use statement with a namespace.
The following code will not work:
<?php namespace MyCompany\MyBundle\Test\UnitTest\Service; use MyCompany\MyBundle\Service\ClassToTest; class MyAwesomeTest { public function testSomeMethod() {
Intelligent IDEs such as PHPStorm resolve the annotation of ClassToTest::someMethod() if you press CTRL +, but PHPUnit will give you the error Trying to @cover or @use not existing method "ClassToTest::someMethod". .
Here's a pull request here: https://github.com/sebastianbergmann/phpunit/pull/1312
For work, just use the fully qualified class name:
<?php namespace MyCompany\MyBundle\Test\UnitTest\Service; use MyCompany\MyBundle\Service\ClassToTest; class MyAwesomeTest { public function testSomeMethod() {
Francesco casula
source share