mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-22 02:36:52 +01:00
improve static removal test
This commit is contained in:
parent
63c09315ab
commit
85682c412e
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Fixture;
|
||||
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Source\TurnMeToService;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return new AnotherClass;
|
||||
}
|
||||
}
|
||||
|
||||
class AnotherClass
|
||||
{
|
||||
public function someFun()
|
||||
{
|
||||
return TurnMeToService::someStaticCall();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Fixture;
|
||||
|
||||
use Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Source\TurnMeToService;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var \Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Fixture\AnotherClassFactory
|
||||
*/
|
||||
private $anotherClassFactory;
|
||||
public function __construct(\Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Fixture\AnotherClassFactory $anotherClassFactory)
|
||||
{
|
||||
$this->anotherClassFactory = $anotherClassFactory;
|
||||
}
|
||||
public function run()
|
||||
{
|
||||
return $this->anotherClassFactory->create();
|
||||
}
|
||||
}
|
||||
|
||||
class AnotherClass
|
||||
{
|
||||
/**
|
||||
* @var \Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Source\TurnMeToService
|
||||
*/
|
||||
private $turnMeToService;
|
||||
public function __construct(\Rector\RemovingStatic\Tests\Rector\Class_\PassFactoryToEntityRector\Source\TurnMeToService $turnMeToService)
|
||||
{
|
||||
$this->turnMeToService = $turnMeToService;
|
||||
}
|
||||
public function someFun()
|
||||
{
|
||||
return $this->turnMeToService->someStaticCall();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -19,23 +19,6 @@ final class PassFactoryToEntityRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
$this->doTestFile($file);
|
||||
|
||||
// test factory content
|
||||
$this->assertFileExists($this->getTempPath() . '/AnotherClassFactory.php');
|
||||
$this->assertFileEquals(
|
||||
__DIR__ . '/Source/ExpectedAnotherClassFactory.php',
|
||||
$this->getTempPath() . '/AnotherClassFactory.php'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDataMultipleArguments()
|
||||
*/
|
||||
public function testMultipleArguments(string $file): void
|
||||
{
|
||||
$this->markTestSkipped('Conflicting with previous test() for unknown reason. Works well separately');
|
||||
|
||||
$this->doTestFile($file);
|
||||
|
||||
// test factory content
|
||||
$this->assertFileExists($this->getTempPath() . '/AnotherClassWithMoreArgumentsFactory.php');
|
||||
$this->assertFileEquals(
|
||||
@ -45,11 +28,6 @@ final class PassFactoryToEntityRectorTest extends AbstractRectorTestCase
|
||||
}
|
||||
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
public function provideDataMultipleArguments(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureWithMultipleArguments');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user