Skip to content

Conversation

alexander-schranz
Copy link
Contributor

This way it is possible to use e.g.:

vendor/bin/phpunit --filter="user_get_user_name_to_get_user_identifier.php.inc"

@TomasVotruba
Copy link
Member

Does the number filter still works?

@alexander-schranz
Copy link
Contributor Author

What you mean with number filter?

@samsonasik
Copy link
Member

samsonasik commented May 25, 2022

@alexander-schranz something like this:

vendor/bin/phpunit rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/AddArrayReturnDocTypeRectorTest.php --filter=#1
PHPUnit 9.5.20 #StandWithUkraine

.                                                                   1 / 1 (100%)

Time: 00:00.772, Memory: 64.50 MB

OK (1 test, 2 assertions)

I tried locally, and after apply your change, it seems cause empty result:

➜  rector-src git:(main) vendor/bin/phpunit rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/AddArrayReturnDocTypeRectorTest.php --filter=#1
PHPUnit 9.5.20 #StandWithUkraine

No tests executed!

so it make number filter no longer working.

@alexander-schranz
Copy link
Contributor Author

Is that really required? I mean you normally don't know the number of the test but you see in your IDE the filename of the test. But we could still add if required '#' . $counter or something like that.

@samsonasik
Copy link
Member

samsonasik commented May 25, 2022

I usually doing that if found a numbered fixture error to just know the number of fixture, eg:

vendor/bin/phpunit rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/AddArrayReturnDocTypeRectorTest.php 
PHPUnit 9.5.20 #StandWithUkraine

................................F................................ 65 / 67 ( 97%)
..                                                                67 / 67 (100%)

Time: 00:04.125, Memory: 132.50 MB

There was 1 failure:

1) Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\AddArrayReturnDocTypeRectorTest::test with data set #28 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/fixture.php.inc
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
     /**
      * @return int[]
      */
-    public function getValues(): array
+    public function getValues()

above, I can see that there is error in fixture number #28, I don't need to copy fixture name, just number:

vendor/bin/phpunit rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/AddArrayReturnDocTypeRectorTest.php --filter=#28 
PHPUnit 9.5.20 #StandWithUkraine

F                                                                   1 / 1 (100%)

Time: 00:00.675, Memory: 60.50 MB

There was 1 failure:

1) Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\AddArrayReturnDocTypeRectorTest::test with data set #28 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/fixture.php.inc
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
     /**
      * @return int[]
      */
-    public function getValues(): array
+    public function getValues()

@alexander-schranz
Copy link
Contributor Author

alexander-schranz commented May 25, 2022

But it works the same for the new name instead of #28 you will now get the filename your_file.php.inc and so you can use --filter="your_file.php.inc". But if required we could prefix it with a counter.

@samsonasik
Copy link
Member

I think that will make too long to type and can make typo as copy paste in the middle of long name. I think You can extends AbstractRectorTestCase and you can override it on your own use case.

Comment on lines +97 to +102
$counter = 0;
foreach (StaticFixtureFinder::yieldDirectoryExclusivelyWithRelativePathname($directory, $suffix) as $name => $parameters) {
yield '#' . $counter . ' ' . $name => $parameters;

++$counter;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems not working:

vendor/bin/phpunit rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/AddArrayReturnDocTypeRectorTest.php --filter=#1
PHPUnit 9.5.20 #StandWithUkraine

No tests executed!

Copy link
Contributor Author

@alexander-schranz alexander-schranz May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that is really strange seems like some strange phpunit internal behaviour how # is handled in the filter.

Still thx for your time and feedback.

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

Successfully merging this pull request may close these issues.

3 participants