split ListEachRector and WhileEachToForeachRector test cases

This commit is contained in:
TomasVotruba 2020-05-31 19:22:44 +02:00
parent ecc0971bf7
commit b717da698b
8 changed files with 8 additions and 23 deletions

View File

@ -18,7 +18,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
/**
* @source https://wiki.php.net/rfc/deprecations_php_7_2#each
*
* @see \Rector\Php72\Tests\Rector\Each\EachRectorTest
* @see \Rector\Php72\Tests\Rector\Each\ListEachRector\ListEachRectorTest
*/
final class ListEachRector extends AbstractRector
{

View File

@ -19,7 +19,7 @@ use Rector\Core\RectorDefinition\RectorDefinition;
/**
* @source https://wiki.php.net/rfc/deprecations_php_7_2#each
*
* @see \Rector\Php72\Tests\Rector\Each\EachRectorTest
* @see \Rector\Php72\Tests\Rector\Each\WhileEachToForeachRector\WhileEachToForeachRectorTest
*/
final class WhileEachToForeachRector extends AbstractRector
{

View File

@ -2,8 +2,7 @@
namespace Rector\Php72\Tests\Rector\Each\Fixture;
function each2
()
function each2()
{
list($key, $val) = each($opt->option);
@ -18,8 +17,7 @@ function each2
namespace Rector\Php72\Tests\Rector\Each\Fixture;
function each2
()
function each2()
{
$key = key($opt->option);
$val = current($opt->option);

View File

@ -2,19 +2,18 @@
declare(strict_types=1);
namespace Rector\Php72\Tests\Rector\Each;
namespace Rector\Php72\Tests\Rector\Each\ListEachRector;
use Iterator;
use Rector\Core\Testing\PHPUnit\AbstractRectorTestCase;
use Rector\Php72\Rector\Each\ListEachRector;
use Rector\Php72\Rector\Each\WhileEachToForeachRector;
/**
* Test battery inspired by:
* - https://stackoverflow.com/q/46492621/1348344 + Drupal refactorings
* - https://stackoverflow.com/a/51278641/1348344
*/
final class EachRectorTest extends AbstractRectorTestCase
final class ListEachRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
@ -29,14 +28,8 @@ final class EachRectorTest extends AbstractRectorTestCase
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
/**
* @return mixed[]
*/
protected function getRectorsWithConfiguration(): array
protected function getRectorClass(): string
{
return [
WhileEachToForeachRector::class => [],
ListEachRector::class => [],
];
return ListEachRector::class;
}
}

View File

@ -4,9 +4,6 @@ namespace Rector\Php72\Tests\Rector\Each\Fixture;
function each1()
{
while (list($module) = each($module_list)) {
}
while (list($key, $callback) = each($callbacks)) {
// comment
}
@ -26,9 +23,6 @@ namespace Rector\Php72\Tests\Rector\Each\Fixture;
function each1()
{
foreach (array_keys($module_list) as $module) {
}
foreach ($callbacks as $key => $callback) {
// comment
}