♻️ Use PHPUnit's attributes in place of annotations (#884)#904
♻️ Use PHPUnit's attributes in place of annotations (#884)#904mk-mxp merged 1 commit intoexercism:mainfrom
Conversation
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
|
@homersimpsons So quick and so many changes :) I hope to get to it on the weekend. |
Yes, it took me 30 minutes to 1 hour to check the whole diff. Most of the files had the same changes, also the diff count per file also gives confidence at a quick glance. |
|
Currently on vacation, so would need some time to review this, can do it somewhen next week. |
mk-mxp
left a comment
There was a problem hiding this comment.
Only a few problems, automation is great!
One thing I am unsure about: Why do we have \ on students stubs exceptions, but not on those in the tests? Technically \ is not required, as there are no namespaces set. Should we remove them?
1. Used rector with the following configuration:
```php
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;
return RectorConfig::configure()
->withPaths([__DIR__ . '/exercises'])
->withSets([PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES, PHPUnitSetList::PHPUNIT_110])
->withImportNames(importShortClasses: false, removeUnusedImports: true);
```
2. Manually fix testdox that contains `::`:
```diff
-#[TestDox(specify a string type for Address::$street)]
+#[TestDox('specify a string type for Address::$street')]
```
3. Updated `TestGenerator.php` to use attribute
4. Updated `bootstrap.sh` to use attribute
33ebb3b to
5ef73ab
Compare
mk-mxp
left a comment
There was a problem hiding this comment.
Thanks a lot for contributing this!
:::TestGenerator.phpto use attributebootstrap.shto use attribute