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

DX: do not allow overriding constructor of PHPUnit\Framework\TestCase #7563

Merged
merged 2 commits into from Dec 15, 2023
Merged

DX: do not allow overriding constructor of PHPUnit\Framework\TestCase #7563

merged 2 commits into from Dec 15, 2023

Conversation

kubawerlos
Copy link
Contributor

@coveralls
Copy link

coveralls commented Dec 15, 2023

Coverage Status

coverage: 94.789%. remained the same
when pulling e1a4427 on 6b7562617765726c6f73:dx_testNotDefiningConstructor
into 4c57217 on PHP-CS-Fixer:master.

@kubawerlos kubawerlos enabled auto-merge (squash) December 15, 2023 15:31
@kubawerlos kubawerlos merged commit fd3b0a2 into PHP-CS-Fixer:master Dec 15, 2023
25 checks passed
@kubawerlos kubawerlos deleted the dx_testNotDefiningConstructor branch December 15, 2023 15:51
{
$reflection = new \ReflectionObject($this);

self::assertNotSame(
Copy link
Member

Choose a reason for hiding this comment

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

@kubawerlos
whenever doing things like this, use the message parameter. JohnDoe will see that they done sth we didn't want, but without understanding "why" we don't want it.

Copy link
Member

@Wirone Wirone Dec 16, 2023

Choose a reason for hiding this comment

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

I believe the default messages for each assert are good enough in most cases, it's not like the developer won't know anything about the failure.

Copy link
Member

Choose a reason for hiding this comment

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

huh? @Wirone , once more my msg:

JohnDoe will see that they done sth we didn't want, but without understanding "why" we don't want it.

So let say JohnDoe wanted to contribute for first time, they did new test and use constructor in it.
Then, they get this result:

ker@d ~/github/FriendsOfPHP/PHP-CS-Fixer λ ./vendor/bin/phpunit tests/SomeTest.php 
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.

Testing PhpCsFixer\Tests\SomeTest
....F                                                                                                                                                           5 / 5 (100%)

Time: 00:00.045, Memory: 26.50 MB

There was 1 failure:

1) PhpCsFixer\Tests\SomeTest::testNotDefiningConstructor
Failed asserting that two strings are not identical.

/Users/d.ruminski/github/FriendsOfPHP/PHP-CS-Fixer/tests/TestCase.php:33

So, JohnDoe got the msg what is failing (testNotDefiningConstructor), yet without knowledge WHY not do define that constructor.

danog pushed a commit to zoonru/PHP-CS-Fixer that referenced this pull request Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants