[Rector] add PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD#5320
[Rector] add PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD#5320kenjis merged 4 commits intocodeigniter4:developfrom
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! |
| $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.
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.
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
|
|
||
| $entity->created_at = '12345678'; | ||
| $this->assertTrue(isset($entity->createdAt)); | ||
| $this->assertObjectHasAttribute('createdAt', $entity); |
| $_SESSION['foo'] = 'bar'; | ||
|
|
||
| $this->assertTrue(isset($session->foo)); | ||
| $this->assertObjectHasAttribute('foo', $session); |
There was a problem hiding this comment.
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.
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.
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: