[PHPUnit] Decouple to own package (#5905)

This commit is contained in:
Tomas Votruba 2021-03-19 10:52:08 +01:00 committed by GitHub
parent 3aa1f86778
commit 16b2b0376c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
252 changed files with 3 additions and 13627 deletions

View File

@ -44,6 +44,7 @@
"rector/rector-symfony": "dev-main",
"rector/rector-nette": "dev-main",
"rector/rector-laravel": "dev-main",
"rector/rector-phpunit": "dev-main",
"sebastian/diff": "^4.0.4",
"symfony/console": "^4.4.8|^5.1",
"symfony/dependency-injection": "^5.1",

View File

@ -15,10 +15,12 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-symfony/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-nette/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-laravel/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-phpunit/config/config.php', null, 'not_found');
// rector sub-package
$containerConfigurator->import(__DIR__ . '/../../rector-symfony/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../../rector-nette/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../../rector-laravel/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../../rector-phpunit/config/config.php', null, 'not_found');
// require only in dev
$containerConfigurator->import(__DIR__ . '/../utils/compiler/config/config.php', null, 'not_found');

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
use Iterator;
use Rector\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class AddDoesNotPerformAssertionToNonAssertingTestRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return AddDoesNotPerformAssertionToNonAssertingTestRector::class;
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class SomeClass extends \PHPUnit\Framework\TestCase
{
public function test()
{
$nothing = 5;
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class SomeClass extends \PHPUnit\Framework\TestCase
{
/**
* @doesNotPerformAssertions
*/
public function test()
{
$nothing = 5;
}
}
?>

View File

@ -1,38 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
use Mockery;
use PHPUnit\Framework\TestCase;
class JustMocksTest extends TestCase
{
public function test()
{
$mockNetteUser = Mockery::mock(User::class);
$mockNetteUser->expects()->isAllowed('yes', 'vote');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
use Mockery;
use PHPUnit\Framework\TestCase;
class JustMocksTest extends TestCase
{
/**
* @doesNotPerformAssertions
*/
public function test()
{
$mockNetteUser = Mockery::mock(User::class);
$mockNetteUser->expects()->isAllowed('yes', 'vote');
}
}
?>

View File

@ -1,18 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class KeepAssert extends \PHPUnit\Framework\TestCase
{
public function test()
{
$nothing = 5;
$this->assertNotNull(5);
}
public function testStatic()
{
$nothing = 5;
self::assertNotNull(5);
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class KeepAssertInCall extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->doElsewhere(5);
}
private function doElsewhere($value)
{
$this->assertNotNull($value);
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class KeepAssertInStaticCall extends \PHPUnit\Framework\TestCase
{
public function test()
{
self::doElsewhere(5);
}
private static function doElsewhere($value)
{
if ($value) {
self::assertNotNull($value);
}
}
}

View File

@ -1,26 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
use InvalidArgumentException;
class KeepExpectedException extends \PHPUnit\Framework\TestCase
{
/**
* @expectedException \Exception
*/
public function test()
{
}
public function testExpectException()
{
$this->expectException('Throwable');
throw new InvalidArgumentException();
}
public function testSetExpectedException()
{
$this->setExpectedException('Throwable');
}
}

View File

@ -1,10 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class KeepNonPublic extends \PHPUnit\Framework\TestCase
{
protected function testDelegated()
{
}
}

View File

@ -1,10 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class KeepNonTest extends \PHPUnit\Framework\TestCase
{
public function provideData()
{
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
use Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\AbstractClassWithAssert;
final class KeepWithParentMethodAssert extends AbstractClassWithAssert
{
public function test()
{
$this->doAssertThis();
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
use Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\AbstractClassWithStaticAssert;
class KeepWithParentMethodStaticAssert extends AbstractClassWithStaticAssert
{
public function test()
{
$this->doAssertThis();
}
}

View File

@ -1,58 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
use Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\Denormalizer;
use Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\DenormalizerInterface;
class ProphecyAssertions extends \PHPUnit\Framework\TestCase
{
public function testDenormalize(): void
{
$badData = ['42'];
$fixedData = [42];
$type = 'anything';
/** @var DenormalizerInterface $denormalizer */
$denormalizer = $this->prophesize(DenormalizerInterface::class);
$denormalizer
->denormalize($fixedData, $type)
->shouldBeCalled();
(new Denormalizer($denormalizer))->handle($badData, $type);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
use Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\Denormalizer;
use Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source\DenormalizerInterface;
class ProphecyAssertions extends \PHPUnit\Framework\TestCase
{
/**
* @doesNotPerformAssertions
*/
public function testDenormalize(): void
{
$badData = ['42'];
$fixedData = [42];
$type = 'anything';
/** @var DenormalizerInterface $denormalizer */
$denormalizer = $this->prophesize(DenormalizerInterface::class);
$denormalizer
->denormalize($fixedData, $type)
->shouldBeCalled();
(new Denormalizer($denormalizer))->handle($badData, $type);
}
}
?>

View File

@ -1,13 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class SkipExistingAnnotation extends \PHPUnit\Framework\TestCase
{
/**
* @doesNotPerformAssertions
*/
public function testSomething(): void
{
}
}

View File

@ -1,34 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class TestInAnnotatoin extends \PHPUnit\Framework\TestCase
{
/**
* @test
*/
public function thisIsTest()
{
$nothing = 5;
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class TestInAnnotatoin extends \PHPUnit\Framework\TestCase
{
/**
* @test
* @doesNotPerformAssertions
*/
public function thisIsTest()
{
$nothing = 5;
}
}
?>

View File

@ -1,20 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
use PHPUnit\Framework\TestCase;
abstract class AbstractClassWithAssert extends TestCase
{
public function doAssertThis()
{
$this->anotherMethod();
}
private function anotherMethod()
{
$this->assertTrue(true);
}
}

View File

@ -1,20 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
use PHPUnit\Framework\TestCase;
abstract class AbstractClassWithStaticAssert extends TestCase
{
public function doAssertThis()
{
self::anotherMethod();
}
private static function anotherMethod()
{
self::assertTrue(true);
}
}

View File

@ -1,27 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
final class Denormalizer
{
/**
* @var DenormalizerInterface
*/
private $denormalizer;
public function __construct(DenormalizerInterface $denormalizer)
{
$this->denormalizer = $denormalizer;
}
public function handle(array $data, string $type): ?array
{
try {
return $this->denormalizer->denormalize($data, $type);
} catch (\Throwable $throwable) {
return null;
}
}
}

View File

@ -1,20 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Source;
interface DenormalizerInterface
{
/**
* Denormalizes data back into an object of the given class.
*
* @param mixed $data Data to restore
* @param string $type The expected class to instantiate
* @param string $format Format the given data was extracted from
* @param array $context Options available to the denormalizer
*
* @return object|array
*/
public function denormalize($data, $type, $format = null, array $context = []);
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector;
use Iterator;
use Rector\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class ExceptionAnnotationRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return ExceptionAnnotationRector::class;
}
}

View File

@ -1,35 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
use PHPUnit\Framework\TestCase;
use Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Source\SomeConstant;
final class ConstantCode extends TestCase
{
/**
* @expectedExceptionCode SomeConstant::ERROR_CODE
*/
public function testThrowExceptionWhenOperatorIsInvalid(): void
{
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
use PHPUnit\Framework\TestCase;
use Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Source\SomeConstant;
final class ConstantCode extends TestCase
{
public function testThrowExceptionWhenOperatorIsInvalid(): void
{
$this->expectExceptionCode(SomeConstant::ERROR_CODE);
}
}
?>

View File

@ -1,33 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
final class MyTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \FooException
*/
public function test()
{
// some code
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
final class MyTest extends \PHPUnit_Framework_TestCase
{
public function test()
{
$this->expectException('FooException');
// some code
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
final class MyTest2 extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Phpml\Exception\InvalidArgumentException
* @expectedExceptionMessage Invalid operator "~=" provided
*/
public function testThrowExceptionWhenOperatorIsInvalid(): void
{
Comparison::compare(1, 1, '~=');
// extra line
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
final class MyTest2 extends \PHPUnit_Framework_TestCase
{
public function testThrowExceptionWhenOperatorIsInvalid(): void
{
$this->expectException('Phpml\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Invalid operator "~=" provided');
Comparison::compare(1, 1, '~=');
// extra line
}
}
?>

View File

@ -1,29 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
final class MyTest3 extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Exception
*/
public function testThrowExceptionWhenOperatorIsInvalid(): void
{
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
final class MyTest3 extends \PHPUnit_Framework_TestCase
{
public function testThrowExceptionWhenOperatorIsInvalid(): void
{
$this->expectException(\Exception::class);
}
}
?>

View File

@ -1,63 +0,0 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
use PHPUnit\Framework\TestCase;
class ExceptionMessageTest extends TestCase
{
/**
* @expectedException \Exception
*/
public function testLiteralMessage(): void
{
throw new \Exception('A literal exception message');
}
/**
* @expectedException \Exception
*/
public function testPartialMessageBegin(): void
{
throw new \Exception('A partial exception message');
}
}
?>
-----
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
use PHPUnit\Framework\TestCase;
class ExceptionMessageTest extends TestCase
{
public function testLiteralMessage(): void
{
$this->expectException(\Exception::class);
throw new \Exception('A literal exception message');
}
public function testPartialMessageBegin(): void
{
$this->expectException(\Exception::class);
throw new \Exception('A partial exception message');
}
}
?>

View File

@ -1,21 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Fixture;
use PHPUnit\Framework\TestCase;
class SkipMethodWithNullPhpDoc extends TestCase
{
public function testLiteralMessage(): void
{
$this->expectException('Exception');
throw new \Exception('A literal exception message');
}
// test
public function testPartialMessageBegin(): void
{
throw new \Exception('A partial exception message');
}
}

View File

@ -1,13 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector\Source;
final class SomeConstant
{
/**
* @var int
*/
public const ERROR_CODE = 1000004;
}

View File

@ -1,74 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class DifferentReturnValues extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->method('someMethod')
->willReturn('1');
$reference = '2';
$mock
->expects($this->at(1))
->method('someMethod')
->willReturnReference($reference);
$mock
->expects($this->at(2))
->method('someMethod')
->willReturnMap(['foo' => 'bar']);
$mock
->expects($this->at(3))
->method('someMethod')
->willReturnArgument(1);
$mock
->expects($this->at(4))
->method('someMethod')
->willReturnCallback(static function () {
return null;
});
$mock
->expects($this->at(5))
->method('someMethod')
->willReturnSelf();
$mock
->expects($this->at(6))
->method('someMethod')
->willThrowException(new \Exception());
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class DifferentReturnValues extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$reference = '2';
$mock->method('someMethod')->willReturnOnConsecutiveCalls('1', new \PHPUnit\Framework\MockObject\Stub\ReturnReference($reference), $this->returnValueMap(['foo' => 'bar']), $this->returnArgument(1), $this->returnCallback(static function () {
return null;
}), $this->returnSelf(), $this->throwException(new \Exception()));
}
}
?>

View File

@ -1,22 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class ExpectsNonAtIsSkipped extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->exactly(1))
->method('someMethod');
}
}
?>

View File

@ -1,65 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class HandleMultipleVariables extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->with('0')
->method('someMethod')
->willReturn('1');
$mock
->expects($this->at(1))
->with('1')
->method('someMethod')
->willReturn('2');
$mock2 = $this->createMock(Foo::class);
$mock2
->expects($this->at(0))
->with('0')
->method('someMethod')
->willReturn('1');
$mock2
->expects($this->at(1))
->with('1')
->method('someMethod')
->willReturn('2');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class HandleMultipleVariables extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock->method('someMethod')->withConsecutive(['0'], ['1'])->willReturnOnConsecutiveCalls('1', '2');
$mock2 = $this->createMock(Foo::class);
$mock2->method('someMethod')->withConsecutive(['0'], ['1'])->willReturnOnConsecutiveCalls('1', '2');
}
}
?>

View File

@ -1,48 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class MissingWithIsReplacedByEmptyArrayIfNoReturnExpectation extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->with('0')
->method('someMethod');
$mock
->expects($this->at(2))
->with('2')
->method('someMethod');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class MissingWithIsReplacedByEmptyArrayIfNoReturnExpectation extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock->method('someMethod')->withConsecutive(['0'], [], ['2']);
}
}
?>

View File

@ -1,48 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class MissingWithIsReplacedByEmptyArrayIfNoReturnExpectation2 extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(1))
->with('1')
->method('someMethod');
$mock
->expects($this->at(2))
->with('2')
->method('someMethod');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class MissingWithIsReplacedByEmptyArrayIfNoReturnExpectation2 extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock->method('someMethod')->withConsecutive([], ['1'], ['2']);
}
}
?>

View File

@ -1,50 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class Mixed extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->with(0)
->method('someMethod')
->willReturn('0');
$mock
->expects($this->at(1))
->with(1)
->method('someMethod')
->willReturn('1');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class Mixed extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock->method('someMethod')->withConsecutive([0], [1])->willReturnOnConsecutiveCalls('0', '1');
}
}
?>

View File

@ -1,56 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class Mixed2 extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->exactly(2))
->method('someMethod');
$mock
->expects($this->at(0))
->with(0)
->method('someMethod')
->willReturn('0');
$mock
->expects($this->at(1))
->with(1)
->method('someMethod')
->willReturn('1');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class Mixed2 extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->exactly(2))
->method('someMethod');
$mock->method('someMethod')->withConsecutive([0], [1])->willReturnOnConsecutiveCalls('0', '1');
}
}
?>

View File

@ -1,39 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
public function someOtherMethod()
{
}
}
final class SkipDifferentMethodExpectations extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->method('someMethod')
->willReturn('1');
$mock
->expects($this->at(1))
->with('1')
->method('someOtherMethod');
$mock
->expects($this->at(2))
->with('2')
->method('someMethod')
->willReturn('3');
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
public function someOtherMethod()
{
}
}
final class SkipMissingReturnExpectation extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->method('someMethod')
->willReturn('1');
$mock
->expects($this->at(1))
->method('someMethod');
$mock
->expects($this->at(2))
->method('someMethod')
->willReturn('3');
}
}
?>

View File

@ -1,30 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class SkipMissingWithIfReturnExpectationsExist extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->with('0')
->method('someMethod')
->willReturn('1');
$mock
->expects($this->at(2))
->with('2')
->method('someMethod')
->willReturn('3');
}
}
?>

View File

@ -1,48 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class WillCallbacksAreKept extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->method('someMethod')
->will($this->throwException(new \Exception()));
$mock
->expects($this->at(1))
->method('someMethod')
->will($this->returnValue('1'));
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class WillCallbacksAreKept extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock->method('someMethod')->willReturnOnConsecutiveCalls($this->throwException(new \Exception()), $this->returnValue('1'));
}
}
?>

View File

@ -1,56 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class WillReturnOnly extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->method('someMethod')
->willReturn('0');
$mock
->expects($this->at(1))
->method('someMethod')
->willReturn('1');
$mock
->expects($this->at(2))
->method('someMethod')
->willReturn('2');
$mock
->expects($this->at(3))
->method('someMethod')
->willReturn(null);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class WillReturnOnly extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock->method('someMethod')->willReturnOnConsecutiveCalls('0', '1', '2', null);
}
}
?>

View File

@ -1,44 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class WithMultipleArguments extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->with('0', '1')
->method('someMethod');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class WithMultipleArguments extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock->method('someMethod')->withConsecutive(['0', '1']);
}
}
?>

View File

@ -1,56 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class WithOnly extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock
->expects($this->at(0))
->with('0')
->method('someMethod');
$mock
->expects($this->at(1))
->with('1')
->method('someMethod');
$mock
->expects($this->at(2))
->with('2')
->method('someMethod');
$mock
->expects($this->at(3))
->with(null)
->method('someMethod');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector\Fixture;
class Foo
{
public function someMethod()
{
}
}
final class WithOnly extends \PHPUnit\Framework\TestCase
{
public function test(): void
{
$mock = $this->createMock(Foo::class);
$mock->method('someMethod')->withConsecutive(['0'], ['1'], ['2'], [null]);
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector;
use Iterator;
use Rector\PHPUnit\Rector\ClassMethod\MigrateAtToConsecutiveExpectationsRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class MigrateAtToConsecutiveExpectationsRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return MigrateAtToConsecutiveExpectationsRector::class;
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector\Fixture;
class SomeTest extends \PHPUnit\Framework\TestCase
{
/**
* testGetTranslatedModelField method
*
* @return void
*/
public function testGetTranslatedModelField()
{
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector\Fixture;
class SomeTest extends \PHPUnit\Framework\TestCase
{
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
use Iterator;
use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class RemoveEmptyTestMethodRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return RemoveEmptyTestMethodRector::class;
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\TryCatchToExpectExceptionRector\Fixture;
use PHPUnit\Framework\TestCase;
final class MyTest extends TestCase
{
public function test()
{
try {
$someService->run();
} catch (Throwable $exception) {
$this->assertInstanceOf(RuntimeException::class, $exception);
$this->assertSame('There was an error executing the following script', $exception->getMessage());
$this->assertContains('There was an error executing the following script', $exception->getMessage());
}
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\TryCatchToExpectExceptionRector\Fixture;
use PHPUnit\Framework\TestCase;
final class MyTest extends TestCase
{
public function test()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('There was an error executing the following script');
$this->expectExceptionMessageRegExp('#There was an error executing the following script#');
$someService->run();
}
}
?>

View File

@ -1,38 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\TryCatchToExpectExceptionRector\Fixture;
final class MyTest2 extends \PHPUnit\Framework\TestCase
{
public function test()
{
try {
$someService->run();
$someService->moreCalls();
} catch (Throwable $exception) {
$this->assertSame(1000, $exception->getCode());
$this->assertInstanceOf(RuntimeException::class, $exception);
$this->assertEquals('There was an error executing the following script', $exception->getMessage());
}
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\TryCatchToExpectExceptionRector\Fixture;
final class MyTest2 extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->expectExceptionCode(1000);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('There was an error executing the following script');
$someService->run();
$someService->moreCalls();
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\ClassMethod\TryCatchToExpectExceptionRector;
use Iterator;
use Rector\PHPUnit\Rector\ClassMethod\TryCatchToExpectExceptionRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class TryCatchToExpectExceptionRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return TryCatchToExpectExceptionRector::class;
}
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\AddProphecyTraitRector;
use Iterator;
use Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class AddProphecyTraitRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return AddProphecyTraitRector::class;
}
}

View File

@ -1,32 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddProphecyTraitRector\Fixture;
use PHPUnit\Framework\TestCase;
final class ExampleTest extends TestCase
{
public function testOne(): void
{
$prophecy = $this->prophesize(\AnInterface::class);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddProphecyTraitRector\Fixture;
use PHPUnit\Framework\TestCase;
final class ExampleTest extends TestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
public function testOne(): void
{
$prophecy = $this->prophesize(\AnInterface::class);
}
}
?>

View File

@ -1,16 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddProphecyTraitRector\Fixture;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
final class SkipIfAlreadyAdded extends TestCase
{
use ProphecyTrait;
public function testOne(): void
{
$prophecy = $this->prophesize(\AnInterface::class);
}
}

View File

@ -1,15 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddProphecyTraitRector\Fixture;
use PHPUnit\Framework\TestCase;
use stdClass;
final class SkipNonProphesizeTest extends TestCase
{
public function testOne(): void
{
$that = new stdClass();
$prophecy = $that->prophesize(\AnInterface::class);
}
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector;
use Iterator;
use Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class AddSeeTestAnnotationRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return AddSeeTestAnnotationRector::class;
}
}

View File

@ -1,34 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/**
* This is here
*/
class AddToDocBlock
{
}
class AddToDocBlockTest extends \PHPUnit\Framework\TestCase
{
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/**
* This is here
* @see \Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture\AddToDocBlockTest
*/
class AddToDocBlock
{
}
class AddToDocBlockTest extends \PHPUnit\Framework\TestCase
{
}
?>

View File

@ -1,33 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/**
* @see \SomeRandom\MissingTest
*/
final class RemoveNonExistingSee
{
}
class RemoveNonExistingSeeTest
{
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/**
* @see \Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture\RemoveNonExistingSeeTest
*/
final class RemoveNonExistingSee
{
}
class RemoveNonExistingSeeTest
{
}
?>

View File

@ -1,10 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/**
* This is here
*/
class SkipDifferentNamespace
{
}

View File

@ -1,10 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/**
* @see \Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Source\SomeExistingTest
*/
class SkipExisting
{
}

View File

@ -1,10 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/*
* Some class command not in a PHPDoc Block
*/
class SkipSimpleClassComment
{
}

View File

@ -1,34 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/**
* @doto àreprendre et refactorer
*/
class SurroundedDoc
{
}
class SurroundedDocTest extends \PHPUnit\Framework\TestCase
{
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture;
/**
* @doto àreprendre et refactorer
* @see \Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Fixture\SurroundedDocTest
*/
class SurroundedDoc
{
}
class SurroundedDocTest extends \PHPUnit\Framework\TestCase
{
}
?>

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Source;
class DifferentNamespaceTest
{
}

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Source;
final class SkipSimpleClassCommentTest
{
}

View File

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector\Source;
final class SomeExistingTest
{
}

View File

@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector;
use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class ArrayArgumentToDataProviderRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
class SomeServiceTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->doTestMultiple([1, 2, 3]);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
class SomeServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider provideDataForTest()
*/
public function test(int $variable)
{
$this->doTestSingle($variable);
}
public function provideDataForTest(): \Iterator
{
yield [1];
yield [2];
yield [3];
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
class TwoArgumentsTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->doTestMultiple([['before', 'after']]);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
class TwoArgumentsTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider provideDataForTest()
*/
public function test(string $variable, string $variable2)
{
$this->doTestSingle($variable, $variable2);
}
public function provideDataForTest(): \Iterator
{
yield [['before', 'after']];
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
class VariousTypesTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->doTestMultiple([1, '2', 3.5]);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector\Fixture;
class VariousTypesTest extends \PHPUnit\Framework\TestCase
{
/**
* @param int|string|float $variable
* @dataProvider provideDataForTest()
*/
public function test($variable)
{
$this->doTestSingle($variable);
}
public function provideDataForTest(): \Iterator
{
yield [1];
yield ['2'];
yield [3.5];
}
}
?>

View File

@ -1,22 +0,0 @@
<?php
use Rector\PHPUnit\Rector\Class_\ArrayArgumentToDataProviderRector;
use Rector\PHPUnit\ValueObject\ArrayArgumentToDataProvider;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArrayArgumentToDataProviderRector::class)
->call('configure', [[
ArrayArgumentToDataProviderRector::ARRAY_ARGUMENTS_TO_DATA_PROVIDERS => ValueObjectInliner::inline([
new ArrayArgumentToDataProvider(
'PHPUnit\Framework\TestCase',
'doTestMultiple',
'doTestSingle',
'variable'
),
]),
]]);
};

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector;
use Iterator;
use Rector\PHPUnit\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class ConstructClassMethodToSetUpTestCaseRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return ConstructClassMethodToSetUpTestCaseRector::class;
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector\Fixture;
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
private $someValue;
public function __construct(?string $name = null, array $data = [], string $dataName = '')
{
$this->someValue = 1000;
parent::__construct($name, $data, $dataName);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector\Fixture;
use PHPUnit\Framework\TestCase;
final class SomeTest extends TestCase
{
protected function setUp()
{
parent::setUp();
$this->someValue = 1000;
}
private $someValue;
}
?>

View File

@ -1,43 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
class SomeClass extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider testProvideData()
*/
public function test()
{
$nothing = 5;
}
public function testProvideData()
{
return ['123'];
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
class SomeClass extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider provideData()
*/
public function test()
{
$nothing = 5;
}
public function provideData()
{
return ['123'];
}
}
?>

View File

@ -1,67 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
class MultipleDataProviders extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider testProvideData()
* @dataProvider testNextProvideData2()
* @dataProvider testNextProvideData()
*/
public function test()
{
$nothing = 5;
}
public function testProvideData()
{
return ['123'];
}
public function testNextProvideData2()
{
return ['123'];
}
public function testNextProvideData()
{
return ['123'];
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
class MultipleDataProviders extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider provideData()
* @dataProvider nextProvideData2()
* @dataProvider nextProvideData()
*/
public function test()
{
$nothing = 5;
}
public function provideData()
{
return ['123'];
}
public function nextProvideData2()
{
return ['123'];
}
public function nextProvideData()
{
return ['123'];
}
}
?>

View File

@ -1,45 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
class WithTestAnnotation extends \PHPUnit\Framework\TestCase
{
/**
* @test
* @dataProvider testProvideDataForWithATestAnnotation()
*/
public function test()
{
$nothing = 5;
}
public function testProvideDataForWithATestAnnotation()
{
return ['123'];
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector\Fixture;
class WithTestAnnotation extends \PHPUnit\Framework\TestCase
{
/**
* @test
* @dataProvider provideDataForWithATestAnnotation()
*/
public function test()
{
$nothing = 5;
}
public function provideDataForWithATestAnnotation()
{
return ['123'];
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector;
use Iterator;
use Rector\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class RemoveDataProviderTestPrefixRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return RemoveDataProviderTestPrefixRector::class;
}
}

View File

@ -1,82 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\TestListenerToHooksRector\Fixture;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
final class BeforeListHook implements TestListener
{
public function addError(Test $test, \Throwable $t, float $time): void
{
}
public function addWarning(Test $test, Warning $e, float $time): void
{
}
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
{
}
public function addIncompleteTest(Test $test, \Throwable $t, float $time): void
{
}
public function addRiskyTest(Test $test, \Throwable $t, float $time): void
{
}
public function addSkippedTest(Test $test, \Throwable $t, float $time): void
{
}
public function startTestSuite(TestSuite $suite): void
{
}
public function endTestSuite(TestSuite $suite): void
{
}
public function startTest(Test $test): void
{
dump($test);
echo 'start test!';
}
public function endTest(Test $test, float $time): void
{
dump($time);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\TestListenerToHooksRector\Fixture;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
final class BeforeListHook implements \PHPUnit\Runner\BeforeTestHook, \PHPUnit\Runner\AfterTestHook
{
public function executeBeforeTest(Test $test): void
{
dump($test);
echo 'start test!';
}
public function executeAfterTest(Test $test, float $time): void
{
dump($time);
}
}
?>

View File

@ -1,70 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\TestListenerToHooksRector\Fixture;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
final class SomeListener implements TestListener
{
public function addError(Test $test, \Throwable $t, float $time): void
{
}
public function addWarning(Test $test, Warning $e, float $time): void
{
}
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
{
}
public function addIncompleteTest(Test $test, \Throwable $t, float $time): void
{
}
public function addRiskyTest(Test $test, \Throwable $t, float $time): void
{
}
public function addSkippedTest(Test $test, \Throwable $t, float $time): void
{
}
public function startTestSuite(TestSuite $suite): void
{
}
public function endTestSuite(TestSuite $suite): void
{
}
public function startTest(Test $test): void
{
}
public function endTest(Test $test, float $time): void
{
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\Class_\TestListenerToHooksRector\Fixture;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
final class SomeListener
{
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Class_\TestListenerToHooksRector;
use Iterator;
use Rector\PHPUnit\Rector\Class_\TestListenerToHooksRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class TestListenerToHooksRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return TestListenerToHooksRector::class;
}
}

View File

@ -1,49 +0,0 @@
<?php
final class MyOtherTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$foos = [];
foreach ($foos as $foo) {
$this->assertInstanceOf(\SplFileInfo::class, $foo);
}
foreach ($foos as $foo) {
self::assertInstanceOf(\SplFileInfo::class, $foo);
}
foreach ($foos as $bar => $foo) {
$this->assertInstanceOf(\SplFileInfo::class, $bar);
}
foreach ($foos as $foo) {
$this->assertInstanceOf(\SplFileInfo::class, $foos);
}
}
}
?>
-----
<?php
final class MyOtherTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$foos = [];
$this->assertContainsOnlyInstancesOf(\SplFileInfo::class, $foos);
self::assertContainsOnlyInstancesOf(\SplFileInfo::class, $foos);
foreach ($foos as $bar => $foo) {
$this->assertInstanceOf(\SplFileInfo::class, $bar);
}
foreach ($foos as $foo) {
$this->assertInstanceOf(\SplFileInfo::class, $foos);
}
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector;
use Iterator;
use Rector\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class SimplifyForeachInstanceOfRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return SimplifyForeachInstanceOfRector::class;
}
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector;
use Iterator;
use Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class AssertCompareToSpecificMethodRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return AssertCompareToSpecificMethodRector::class;
}
}

View File

@ -1,35 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector\Fixture;
final class Count extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertSame(5, count($something));
$this->assertEquals(10, iterator_count($something));
$count = 92;
$this->assertNotEquals($count, sizeof($something), 'third argument');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector\Fixture;
final class Count extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertCount(5, $something);
$this->assertCount(10, $something);
$count = 92;
$this->assertNotCount($count, $something, 'third argument');
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector\Fixture;
final class MyAssertCompareTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertEquals('string', gettype($something));
$this->assertEquals('string', $something['property']());
$this->assertNotSame($foo[1]->result, count($this->results));
$this->assertSame(1, $count);
$this->assertNotSame(2, $foo->count());
$this->assertEquals($count, $foo->sizeof);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector\Fixture;
final class MyAssertCompareTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertInternalType('string', $something);
$this->assertEquals('string', $something['property']());
$this->assertNotCount($foo[1]->result, $this->results);
$this->assertSame(1, $count);
$this->assertNotSame(2, $foo->count());
$this->assertEquals($count, $foo->sizeof);
}
}
?>

View File

@ -1,35 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector\Fixture;
use stdClass;
final class GetClass extends \PHPUnit\Framework\TestCase
{
public function test()
{
$something = new stdClass();
$this->assertSame(get_class($something), 'stdClass');
self::assertSame('stdClass', get_class($something));
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector\Fixture;
use stdClass;
final class GetClass extends \PHPUnit\Framework\TestCase
{
public function test()
{
$something = new stdClass();
$this->assertInstanceOf('stdClass', $something);
self::assertInstanceOf('stdClass', $something);
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
use Iterator;
use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class AssertComparisonToSpecificMethodRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return AssertComparisonToSpecificMethodRector::class;
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
final class MyEqualsTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertFalse($expected === $anything);
$this->assertTrue(count($something) > 2);
$this->assertTrue($something[0]['foo'] > $something[1]['foo']);
$this->assertTrue(__DIR__ <> $something, 'message');
$this->assertTrue(1.0 === $something);
$this->assertFalse(true === in_array('foo', ['bar', 'baz'], true));
$this->assertTrue('string' != gettype($foo));
$this->assertTrue(['foo', 'bar'] == $something);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector\Fixture;
final class MyEqualsTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertNotSame($expected, $anything);
$this->assertGreaterThan(2, count($something));
$this->assertGreaterThan($something[1]['foo'], $something[0]['foo']);
$this->assertNotEquals(__DIR__, $something, 'message');
$this->assertSame(1.0, $something);
$this->assertNotSame(true, in_array('foo', ['bar', 'baz'], true));
$this->assertNotEquals('string', gettype($foo));
$this->assertEquals(['foo', 'bar'], $something);
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector;
use Iterator;
use Rector\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class AssertEqualsParameterToSpecificMethodsTypeRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return AssertEqualsParameterToSpecificMethodsTypeRector::class;
}
}

View File

@ -1,42 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RefactorCombination extends TestCase
{
public function test()
{
$value = 'value';
// $expected, $actual, string $message = '',
// float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
$this->assertEquals('string', $value, 'message', 100.0, 50, true, true);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RefactorCombination extends TestCase
{
public function test()
{
$value = 'value';
// $expected, $actual, string $message = '',
// float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false)
$this->assertEquals('string', $value, 'message');
$this->assertEqualsIgnoringCase('string', $value, 'message');
$this->assertEqualsCanonicalizing('string', $value, 'message');
$this->assertEqualsWithDelta('string', $value, 100.0, 'message');
}
}
?>

View File

@ -1,36 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RefactorCanonize extends TestCase
{
public function test()
{
$value = 'value';
$this->assertEquals('string', $value, 'message', 0.0, 10, true);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RefactorCanonize extends TestCase
{
public function test()
{
$value = 'value';
$this->assertEquals('string', $value, 'message');
$this->assertEqualsCanonicalizing('string', $value, 'message');
}
}
?>

View File

@ -1,45 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RefactorDelta extends TestCase
{
public function test()
{
$value = 'value';
$this->assertEquals('string', $value, 'message', 5.0);
$this->assertEquals('string', $value, 'message', 0.0);
$this->assertEquals('string', $value, 'message', 20.0);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RefactorDelta extends TestCase
{
public function test()
{
$value = 'value';
$this->assertEquals('string', $value, 'message');
$this->assertEqualsWithDelta('string', $value, 5.0, 'message');
$this->assertEquals('string', $value, 'message');
$this->assertEquals('string', $value, 'message');
$this->assertEqualsWithDelta('string', $value, 20.0, 'message');
}
}
?>

View File

@ -1,36 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RefactorIgnoreCase extends TestCase
{
public function test()
{
$value = 'value';
$this->assertEquals('string', $value, 'message', 0.0, 10, false, true);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RefactorIgnoreCase extends TestCase
{
public function test()
{
$value = 'value';
$this->assertEquals('string', $value, 'message');
$this->assertEqualsIgnoringCase('string', $value, 'message');
}
}
?>

View File

@ -1,33 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RemoveMaxDepth extends TestCase
{
public function test()
{
$value = 'value';
$this->assertEquals('string', $value, 'message', 0.0, 20);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector\Fixture;
use PHPUnit\Framework\TestCase;
final class RemoveMaxDepth extends TestCase
{
public function test()
{
$value = 'value';
$this->assertEquals('string', $value, 'message');
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector;
use Iterator;
use Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class AssertEqualsToSameRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return AssertEqualsToSameRector::class;
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class MyTest extends TestCase
{
public function test()
{
$int = 1;
$expectedInt = 1;
$this->assertEquals($expectedInt, $int);
$float = 1.1;
$expectedFloat = 1.1;
$this->assertEquals($expectedFloat, $float);
$string = 'abc';
$expectedString = 'abc';
$this->assertEquals($expectedString, $string);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class MyTest extends TestCase
{
public function test()
{
$int = 1;
$expectedInt = 1;
$this->assertSame($expectedInt, $int);
$float = 1.1;
$expectedFloat = 1.1;
$this->assertSame($expectedFloat, $float);
$string = 'abc';
$expectedString = 'abc';
$this->assertSame($expectedString, $string);
}
}
?>

View File

@ -1,51 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class MyTest2 extends TestCase
{
public function test()
{
$int = 1;
$expectedInt = 1;
self::assertEquals($expectedInt, $int);
$float = 1.1;
$expectedFloat = 1.1;
self::assertEquals($expectedFloat, $float);
$string = 'abc';
$expectedString = 'abc';
self::assertEquals($expectedString, $string);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class MyTest2 extends TestCase
{
public function test()
{
$int = 1;
$expectedInt = 1;
self::assertSame($expectedInt, $int);
$float = 1.1;
$expectedFloat = 1.1;
self::assertSame($expectedFloat, $float);
$string = 'abc';
$expectedString = 'abc';
self::assertSame($expectedString, $string);
}
}
?>

View File

@ -1,39 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class TestIncomplete extends TestCase
{
public function test()
{
$this->markTestIncomplete('incomplete');
$this->assertEquals('foo', 'foo');
$this->assertEquals(123, 123);
$this->assertEquals(1.23, 1.23);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class TestIncomplete extends TestCase
{
public function test()
{
$this->markTestIncomplete('incomplete');
$this->assertSame('foo', 'foo');
$this->assertSame(123, 123);
$this->assertSame(1.23, 1.23);
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class TestSkipped extends TestCase
{
public function test()
{
$this->markTestSkipped('skipped');
$this->assertEquals('foo', 'foo');
$this->assertEquals(123, 123);
$this->assertEquals(1.23, 1.23);
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class TestSkipped extends TestCase
{
public function test()
{
$this->markTestSkipped('skipped');
$this->assertSame('foo', 'foo');
$this->assertSame(123, 123);
$this->assertSame(1.23, 1.23);
}
}
?>

View File

@ -1,23 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class MySkipTest extends TestCase
{
public function test()
{
$null = null;
$expectedNull = null;
$this->assertEquals($expectedNull, $null);
$bool = true;
$expectedBool = true;
$this->assertEquals($expectedBool, $bool);
$array = [];
$expectedArray = [];
$this->assertEquals($expectedArray, $array);
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
use PHPUnit\Framework\TestCase;
final class MySkipTest2 extends TestCase
{
public function test()
{
$null = null;
$expectedNull = null;
self::assertEquals($expectedNull, $null);
$bool = true;
$expectedBool = true;
self::assertEquals($expectedBool, $bool);
$array = [];
$expectedArray = [];
self::assertEquals($expectedArray, $array);
}
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector;
use Iterator;
use Rector\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class AssertFalseStrposToContainsRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}
/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
protected function getRectorClass(): string
{
return AssertFalseStrposToContainsRector::class;
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector\Fixture;
final class MyContainsStrposTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertNotFalse(strpos($node, 'foo'));
$this->assertFalse(stripos($node, 'foo'), 'message');
}
}
?>
-----
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector\Fixture;
final class MyContainsStrposTest extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertContains('foo', $node);
$this->assertNotContains('foo', $node, 'message');
}
}
?>

View File

@ -1,12 +0,0 @@
<?php
namespace Rector\Tests\PHPUnit\Rector\MethodCall\AssertFalseStrposToContainsRector\Fixture;
final class SkipMethodCall extends \PHPUnit\Framework\TestCase
{
public function test()
{
$someObject = new Foo();
self::assertFalse($someObject->someMethod());
}
}

Some files were not shown because too many files have changed in this diff Show More