moodlehq / moodle-cs

Moodle Coding Style
https://github.com/moodlehq/moodle-cs
GNU General Public License v3.0
18 stars 16 forks source link

Unit test classes should be declared as either final or abstract #103

Closed andrewnicols closed 9 months ago

andrewnicols commented 9 months ago

Fixes #102

The rationale for this change is based on the principle of least astonishment.

To solve this the idea is:

codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (da7aa56) 96.57% compared to head (b8f9eee) 96.73%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #103 +/- ## ============================================ + Coverage 96.57% 96.73% +0.16% - Complexity 557 586 +29 ============================================ Files 24 26 +2 Lines 1547 1625 +78 ============================================ + Hits 1494 1572 +78 Misses 53 53 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

stronk7 commented 9 months ago

Apart from the detail in the review, surely the major "problem" of this nice Sniff is to determine how do we apply it (only for X.Y and up, warning and error in 1-year, only for non-plugins, ...).

As far as it's not part of the coding-style neither enforced by PHPUnit incoming versions... we need to be careful about it (back to the discussion happening @ #92).

Ciao :-)

andrewnicols commented 9 months ago

Okay,

I've:

I think we need to add this to the epic for PHPUnit 10 as a part of that puzzle and add it to our coding style. This isn't something radical.

stronk7 commented 9 months ago

For fixtures...

moodle/Tests/Sniffs/PHPUnit/fixtures

or

moodle/Tests/fixtures/PHPUnit

I've been doing the later lately and it seems that you've been doing the former. Of course, there are still a lot of fixtures to move so, at some time, we should decide which of the 2 fixtures dirs to use and go for it everywhere (for testing own Sniffs, other standards sniffs are another story).

andrewnicols commented 9 months ago

For fixtures...

moodle/Tests/Sniffs/PHPUnit/fixtures

or

moodle/Tests/fixtures/PHPUnit

I've been doing the later lately and it seems that you've been doing the former. Of course, there are still a lot of fixtures to move so, at some time, we should decide which of the 2 fixtures dirs to use and go for it everywhere (for testing own Sniffs, other standards sniffs are another story).

I've been doing the former because it keeps the fixtures closer to the thing under test, and makes them easier to find, but I'm happy to move them. Let me know your preference.

stronk7 commented 9 months ago

I've been doing the former because it keeps the fixtures closer to the thing under test, and makes them easier to find, but I'm happy to move them. Let me know your preference.

Yeah, I think I agree with you, let's keep the fixtures closer to the the Test using them, specially now that we are creating subdirs for the tests.

Not in a hurry to move all current ones that have followed other paths, but let's go with your alternative for new ones.

stronk7 commented 9 months ago

So, just to be 100% sure, as commented above:

I'm happy with that (4.4dev), will generate some noise for plugins, but it's a good thing, I think. And prepares us for the future, together with #106 and other details that have arrived recently (static providers, ....).

So, with your 👍 , agreement!

stronk7 commented 9 months ago

Sold!