Annotate `@uses` on test method level
mentisy opened this issue · comments
Previously discussed here:
#577
Back then @uses
was added at test controller class level. This is useful, but personally I'd like to also have them at method level. This way I can avoid having IDE yell at me about unused elements (methods etc.). This scenario occurs especially with controller actions and table find methods. If you only call finder methods through the ORM find(string $type = 'all'...)
method, the custom methods won't have been called according to the IDE.
I'm not sure if @dereuromark covers this in his cakephp-ide-helper, maybe PR #135, but adding it to the plugin code could be useful.
I have forked this repo and added a branch that adds @uses \{{class}}::{{method}}()
to all test methods that bake generates. I will happily create a PR from my fork if this is something you'd like to implement.
Fork: master...mentisy:uses-docblocks
Example of PostsController and index action:
/**
* Test index method
*
* @return void
* @uses \Bake\Test\App\Controller\PostsController::index()
*/
public function testIndex(): void
{
$this->markTestIncomplete('Not implemented yet.');
}
Feel free to open the PR to discuss the details.
Yes, the IdeHelper already syncs the class for existing code. Not the methods, only the class, e.g.
/**
* PagesControllerTest class
*
* @uses \App\Controller\PagesController
*/
class PagesControllerTest extends TestCase
But you are absolutely right that this should also be added to new files using bake plugin :)