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

PhpUnitDedicateAssertFixer - remove is_resource. #6254

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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