Skip to content

Commit

Permalink
bug #6254 PhpUnitDedicateAssertFixer - remove is_resource. (drupol)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the master branch (closes #6254).

Discussion
----------

PhpUnitDedicateAssertFixer - remove `is_resource`.

This PR:

- [x] Update `phpunit_dedicate_assert` fixer

Fix #6179

Commits
-------

2b1ecae PhpUnitDedicateAssertFixer - remove `is_resource`.
  • Loading branch information
SpacePossum committed Feb 4, 2022
2 parents 55aec39 + 2b1ecae commit 6ba7795
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php
Expand Up @@ -144,7 +144,6 @@ public function configure(array $configuration): void
'is_numeric',
'is_object',
'is_real',
'is_resource',
'is_scalar',
'is_string',
]);
Expand Down
9 changes: 8 additions & 1 deletion tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php
Expand Up @@ -159,7 +159,7 @@ public function provideTestFixCases(): \Generator
],
];

foreach (['array', 'bool', 'callable', 'double', 'float', 'int', 'integer', 'long', 'numeric', 'object', 'resource', 'real', 'scalar', 'string'] as $type) {
foreach (['array', 'bool', 'callable', 'double', 'float', 'int', 'integer', 'long', 'numeric', 'object', 'real', 'scalar', 'string'] as $type) {
yield [
self::generateTest(sprintf('$this->assertInternalType(\'%s\', $a);', $type)),
self::generateTest(sprintf('$this->assertTrue(is_%s($a));', $type)),
Expand Down Expand Up @@ -307,6 +307,13 @@ public function provideNotFixCases(): \Generator
yield 'not in class' => [
'<?php self::assertTrue(is_null($a));',
];

// Do not replace is_resource() by assertIsResource().
// is_resource() also checks if the resource is open or closed,
// while assertIsResource() does not.
yield 'Do not replace is_resource' => [
self::generateTest('self::assertTrue(is_resource($resource));'),
];
}

public function testInvalidConfig(): void
Expand Down

0 comments on commit 6ba7795

Please sign in to comment.