Skip to content

Commit

Permalink
DX: cleanup FullyQualifiedStrictTypesFixerTest (#7954)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Apr 16, 2024
1 parent 1e6e13b commit 35aca55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 65 deletions.
71 changes: 8 additions & 63 deletions tests/Fixer/Import/FullyQualifiedStrictTypesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1539,22 +1539,7 @@ class Foo
function bar() {}
}
PHP];
}

/**
* @dataProvider provideCodeWithReturnTypesCases
* @dataProvider provideCodeWithReturnTypesCasesWithNullableCases
*/
public function testCodeWithReturnTypes(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}

/**
* @return iterable<array{0: string, 1?: null|string}>
*/
public static function provideCodeWithReturnTypesCases(): iterable
{
yield 'Import common strict types' => [
'<?php
Expand Down Expand Up @@ -1755,24 +1740,7 @@ public function doSomething(\Foo\Bar $foo, array $bar): \Foo\Bar\Baz
}
}',
];
}

/**
* @param array<string, array<string, mixed>|bool> $config
*
* @dataProvider provideCodeWithoutReturnTypesCases
*/
public function testCodeWithoutReturnTypes(string $expected, ?string $input = null, array $config = []): void
{
$this->fixer->configure($config);
$this->doTest($expected, $input);
}

/**
* @return iterable<array{0: string, 1?: null|string}>
*/
public static function provideCodeWithoutReturnTypesCases(): iterable
{
yield 'import from namespace and global' => [
'<?php
use App\DateTime;
Expand All @@ -1786,7 +1754,7 @@ public function bar(\DateTime $dateTime)
',
];

yield 'Import common strict types' => [
yield 'Import common strict types without return type' => [
'<?php
use Foo\Bar;
Expand All @@ -1809,7 +1777,7 @@ public function doSomething(\Foo\Bar $foo)
}',
];

yield 'Test namespace fixes' => [
yield 'Test namespace fixes without return type' => [
'<?php
namespace Foo\Bar;
Expand All @@ -1832,7 +1800,7 @@ public function doSomething(\Foo\Bar\SomeClass $foo, \Foo\Bar\Buz $buz, \Foo\Bar
}',
];

yield 'Partial class name looks like FQCN' => [
yield 'Partial class name looks like FQCN without return type' => [
'<?php
namespace One;
Expand All @@ -1854,7 +1822,7 @@ public function three(Two\Three $three, Three $other)
}',
];

yield 'Test multi namespace fixes' => [
yield 'Test multi namespace fixes without return type' => [
'<?php
namespace Foo\Other {
}
Expand All @@ -1881,7 +1849,7 @@ public function doSomething(\Foo\Bar\SomeClass $foo, \Foo\Bar\Buz $buz, \Foo\Bar
}',
];

yield 'Test fixes in interface' => [
yield 'Test fixes in interface without return type' => [
'<?php
namespace Foo\Bar;
Expand All @@ -1904,7 +1872,7 @@ public function doSomething(\Foo\Bar\SomeClass $foo, \Foo\Bar\Buz $buz, \Foo\Bar
}',
];

yield 'Test fixes in trait' => [
yield 'Test fixes in trait without return type' => [
'<?php
namespace Foo\Bar;
Expand All @@ -1931,7 +1899,7 @@ public function doSomething(\Foo\Bar\SomeClass $foo, \Foo\Bar\Buz $buz, \Foo\Bar
}',
];

yield 'Test fixes in regular functions' => [
yield 'Test fixes in regular functions without return type' => [
'<?php
namespace Foo\Bar;
Expand Down Expand Up @@ -2028,13 +1996,7 @@ public function __construct(
}
',
];
}

/**
* @return iterable<array{0: string, 1?: null|string}>
*/
public static function provideCodeWithReturnTypesCasesWithNullableCases(): iterable
{
yield 'Test namespace fixes with nullable types' => [
'<?php
Expand Down Expand Up @@ -2062,7 +2024,7 @@ public function doSomething(\Foo\Bar\SomeClass $foo, \Foo\Bar\Buz $buz, ?\Foo\Ba
}',
];

yield 'Partial class name looks like FQCN' => [
yield 'Partial class name looks like FQCN with return type with nullable' => [
'<?php
namespace One;
Expand All @@ -2083,24 +2045,7 @@ public function three(Three\Four $four): ?Two\Three
}
}',
];
}

/**
* @param array<string, mixed> $config
*
* @dataProvider provideCodeWithPhpDocCases
*/
public function testCodeWithPhpDoc(string $expected, ?string $input = null, array $config = []): void
{
$this->fixer->configure($config);
$this->doTest($expected, $input);
}

/**
* @return iterable<string, array{0: string, 1?: null|string, 2?: array<string, mixed>}>
*/
public static function provideCodeWithPhpDocCases(): iterable
{
yield 'Test class PHPDoc fixes' => [
'<?php
Expand Down
2 changes: 0 additions & 2 deletions tests/Test/AbstractFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
use PhpCsFixer\Tests\Fixer\FunctionNotation\MethodArgumentSpaceFixerTest;
use PhpCsFixer\Tests\Fixer\FunctionNotation\NativeFunctionInvocationFixerTest;
use PhpCsFixer\Tests\Fixer\FunctionNotation\ReturnTypeDeclarationFixerTest;
use PhpCsFixer\Tests\Fixer\Import\FullyQualifiedStrictTypesFixerTest;
use PhpCsFixer\Tests\Fixer\Import\GlobalNamespaceImportFixerTest;
use PhpCsFixer\Tests\Fixer\Import\OrderedImportsFixerTest;
use PhpCsFixer\Tests\Fixer\Import\SingleImportPerStatementFixerTest;
Expand Down Expand Up @@ -460,7 +459,6 @@ final public function testProperMethodNaming(): void
DoctrineAnnotationIndentationFixerTest::class,
DoctrineAnnotationSpacesFixerTest::class,
EchoTagSyntaxFixerTest::class,
FullyQualifiedStrictTypesFixerTest::class,
FunctionDeclarationFixerTest::class,
FunctionToConstantFixerTest::class,
GeneralPhpdocTagRenameFixerTest::class,
Expand Down

0 comments on commit 35aca55

Please sign in to comment.