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

is the @uses annotation for tests correct? #1022

Open
swiffer opened this issue Nov 30, 2024 · 6 comments
Open

is the @uses annotation for tests correct? #1022

swiffer opened this issue Nov 30, 2024 · 6 comments

Comments

@swiffer
Copy link
Contributor

swiffer commented Nov 30, 2024

Description

the docs state that "The @uses annotation specifies code which will be executed by a test, but is not intended to be covered by the test."

https://docs.phpunit.de/en/10.5/annotations.html#uses

currently bake adds @uses ControllerName to a controller test case. Shouldn't the @covers attribute be used instead as the primary use case for a controller test is testing the controller itself?

Bake Version

3.2.0

PHP Version

8.4

@swiffer swiffer added the defect label Nov 30, 2024
@ADmad
Copy link
Member

ADmad commented Nov 30, 2024

Docblock annotations are deprecated in phpunit 11 and the attribute for coverage can only be used at class level, not method level, so we should simply drop those annotations.

@swiffer
Copy link
Contributor Author

swiffer commented Nov 30, 2024

The @uses annotation is added at classlevel (for controllers) as well currently. Why not replacing with attributes (which exist for classes and functions)?

@ADmad
Copy link
Member

ADmad commented Nov 30, 2024

I guess we can use the CoversClass attribute then.

@dereuromark
Copy link
Member

See also dereuromark/cakephp-ide-helper#351

@dereuromark
Copy link
Member

dereuromark commented Nov 30, 2024

The uses annotation allows bidirectional IDE lookup, so basically to jump via uses detection from controller to test and the other way around.
So those are not directly related to coverage IMO.

@swiffer
Copy link
Contributor Author

swiffer commented Nov 30, 2024

I see, so the primary use case was IDE, not coverage intended, and makes sense.

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

No branches or pull requests

3 participants