-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Rector] add PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD #5320
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
Conversation
@kenjis could you run:
and commit the change? |
1ebe1e9
to
daeaeb3
Compare
@samsonasik I committed. I also added |
@kenjis I think we can add setlist one by one, as it cause error : Error: ] Could not process "system/Cookie/CloneableCookieInterface.php" file,
due to:
"Argument 1 passed to Rector\Core\Rector\AbstractRector::isObjectType()
must implement interface PhpParser\Node, null given, called in
vendor/rector/rector/rules/TypeDeclaration/Rector/ClassMethod/AddParamT
ypeDeclarationRector.php:83". On line: 315 first, ensure If we have specific rule that failed, eg: |
45922a4
to
daeaeb3
Compare
@samsonasik Okay, I will do one by one. Thanks! |
tests/system/Entity/EntityTest.php
Outdated
|
||
$attributes = $this->getPrivateProperty($entity, 'attributes'); | ||
$this->assertFalse(isset($attributes['foo'])); | ||
$this->assertTrue(isset($attributes['default'])); | ||
$this->assertArrayNotHasKey('foo', $attributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion fails. Because $attributes
is
array (4) [
'foo' => null
'bar' => null
'default' => string (6) "sumfin"
'created_at' => null
]
What do we do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can register Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector
into Option::SKIP
use Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector;
$parameters->set(Option::SKIP, [
// ....
AssertIssetToSpecificMethodRector::class => [
__DIR__ . '/tests/system/Entity/EntityTest.php',
],
]);
and then rollback change for tests/system/Entity/EntityTest.php
tests/system/Entity/EntityTest.php
Outdated
@@ -908,10 +908,10 @@ public function testIssetKeyMap() | |||
$entity = $this->getEntity(); | |||
|
|||
$entity->created_at = '12345678'; | |||
$this->assertTrue(isset($entity->createdAt)); | |||
$this->assertObjectHasAttribute('createdAt', $entity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion fails.
tests/system/Session/SessionTest.php
Outdated
@@ -248,7 +248,7 @@ public function testIssetReturnsTrueOnSuccess() | |||
|
|||
$_SESSION['foo'] = 'bar'; | |||
|
|||
$this->assertTrue(isset($session->foo)); | |||
$this->assertObjectHasAttribute('foo', $session); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can register Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector
into Option::SKIP
use Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector;
$parameters->set(Option::SKIP, [
// ....
AssertIssetToSpecificMethodRector::class => [
__DIR__ . '/tests/system/Entity/EntityTest.php',
__DIR__ . '/tests/system/Session/SessionTest.php',
],
]);
and then rollback change for tests/system/Entity/EntityTest.php
and tests/system/Session/SessionTest.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If AssertIssetToSpecificMethodRector
cause invalid result in many places, we can just skip it al together:
use Rector\PHPUnit\Rector\MethodCall\AssertIssetToSpecificMethodRector;
$parameters->set(Option::SKIP, [
// ....
AssertIssetToSpecificMethodRector::class,
]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather change the test code to remove the skip AssertIssetToSpecificMethodRector
.
Thank you for telling me about rector!
daeaeb3
to
c4f0fbb
Compare
Description
See https://github.com/rectorphp/rector-phpunit#rector-rules-for-phpunit
Checklist: