-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add InflectorSingularResolverTest (#1107)
- Loading branch information
1 parent
3bec30a
commit c6d2339
Showing
6 changed files
with
113 additions
and
25 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...ach_/RenameForeachValueVariableToMatchExprVariableRector/Fixture/skip_with_number.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector\Fixture; | ||
|
||
final class SkipWithNumber | ||
{ | ||
public function run(array $psr4NamespacesToPaths) | ||
{ | ||
foreach ($psr4NamespacesToPaths as $psr4NamespaceToPath) { | ||
continue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
tests/Naming/ExpectedNameResolver/InflectorSingularResolverTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Naming\ExpectedNameResolver; | ||
|
||
use Iterator; | ||
use Rector\Naming\ExpectedNameResolver\InflectorSingularResolver; | ||
use Rector\Testing\PHPUnit\AbstractTestCase; | ||
|
||
final class InflectorSingularResolverTest extends AbstractTestCase | ||
{ | ||
private InflectorSingularResolver $inflectorSingularResolver; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->boot(); | ||
$this->inflectorSingularResolver = $this->getService(InflectorSingularResolver::class); | ||
} | ||
|
||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function testResolveForForeach(string $currentName, string $expectedSingularName): void | ||
{ | ||
$singularValue = $this->inflectorSingularResolver->resolve($currentName); | ||
$this->assertSame($expectedSingularName, $singularValue); | ||
} | ||
|
||
/** | ||
* @return Iterator<string[]> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
yield ['psr4NamespacesToPaths', 'psr4NamespaceToPath']; | ||
yield ['nestedNews', 'nestedNew']; | ||
yield ['news', 'new']; | ||
yield ['argsOrOptions', 'argOrOption']; | ||
} | ||
} |