diff --git a/composer.json b/composer.json
index dc1df6843c23..569543381c77 100644
--- a/composer.json
+++ b/composer.json
@@ -130,7 +130,8 @@
"Rector\\VendorLocker\\": "packages/vendor-locker/src",
"Rector\\Performance\\": "rules/performance/src",
"Rector\\Naming\\": "rules/naming/src",
- "Rector\\Order\\": "rules/order/src"
+ "Rector\\Order\\": "rules/order/src",
+ "Rector\\MockistaToMockery\\": "rules/mockista-to-mockery/src"
}
},
"autoload-dev": {
@@ -199,7 +200,8 @@
"Rector\\Utils\\PHPStanStaticTypeMapperChecker\\": "utils/phpstan-static-type-mapper-checker/src",
"Rector\\Performance\\Tests\\": "rules/performance/tests",
"Rector\\Naming\\Tests\\": "rules/naming/tests",
- "Rector\\Order\\Tests\\": "rules/order/tests"
+ "Rector\\Order\\Tests\\": "rules/order/tests",
+ "Rector\\MockistaToMockery\\Tests\\": "rules/mockista-to-mockery/tests"
},
"classmap": [
"rules/cakephp/tests/Rector/Name/ImplicitShortClassNameUseStatementRector/Source",
diff --git a/config/set/framework-migration/mockista-to-mockery.yaml b/config/set/framework-migration/mockista-to-mockery.yaml
new file mode 100644
index 000000000000..b6c2c1185cc4
--- /dev/null
+++ b/config/set/framework-migration/mockista-to-mockery.yaml
@@ -0,0 +1,3 @@
+services:
+ Rector\MockistaToMockery\Rector\Class_\MockeryTearDownRector: null
+ Rector\MockistaToMockery\Rector\ClassMethod\MockistaMockToMockeryMockRector: null
diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md
index a88100931e01..2a12150b3d82 100644
--- a/docs/rector_rules_overview.md
+++ b/docs/rector_rules_overview.md
@@ -1,4 +1,4 @@
-# All 483 Rectors Overview
+# All 485 Rectors Overview
- [Projects](#projects)
- [General](#general)
@@ -22,6 +22,7 @@
- [JMS](#jms) (2)
- [Laravel](#laravel) (6)
- [Legacy](#legacy) (2)
+- [MockistaToMockery](#mockistatomockery) (2)
- [MysqlToMysqli](#mysqltomysqli) (4)
- [Naming](#naming) (1)
- [Nette](#nette) (11)
@@ -4129,6 +4130,56 @@ Change functions to static calls, so composer can autoload them
+## MockistaToMockery
+
+### `MockeryTearDownRector`
+
+- class: [`Rector\MockistaToMockery\Rector\Class_\MockeryTearDownRector`](/../master/rules/mockista-to-mockery/src/Rector/Class_/MockeryTearDownRector.php)
+- [test fixtures](/../master/rules/mockista-to-mockery/tests/Rector/Class_/MockeryTearDownRector/Fixture)
+
+Add Mockery::close() in tearDown() method if not yet
+
+```diff
+ use PHPUnit\Framework\TestCase;
+
+ class SomeTest extends TestCase
+ {
++ protected function tearDown(): void
++ {
++ Mockery::close();
++ }
+ public function test()
+ {
+ $mockUser = mock(User::class);
+ }
+ }
+```
+
+
+
+### `MockistaMockToMockeryMockRector`
+
+- class: [`Rector\MockistaToMockery\Rector\ClassMethod\MockistaMockToMockeryMockRector`](/../master/rules/mockista-to-mockery/src/Rector/ClassMethod/MockistaMockToMockeryMockRector.php)
+- [test fixtures](/../master/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture)
+
+Change functions to static calls, so composer can autoload them
+
+```diff
+ class SomeTest
+ {
+ public function run()
+ {
+- $mockUser = mock(User::class);
+- $mockUser->getId()->once->andReturn(1);
+- $mockUser->freeze();
++ $mockUser = Mockery::mock(User::class);
++ $mockUser->expects()->getId()->once()->andReturn(1);
+ }
+ }
+```
+
+
+
## MysqlToMysqli
### `MysqlAssignToMysqliRector`
diff --git a/packages/node-name-resolver/src/NodeNameResolver.php b/packages/node-name-resolver/src/NodeNameResolver.php
index a7dc04171ad5..97f7fb67c5b1 100644
--- a/packages/node-name-resolver/src/NodeNameResolver.php
+++ b/packages/node-name-resolver/src/NodeNameResolver.php
@@ -13,6 +13,7 @@
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\Interface_;
use PhpParser\Node\Stmt\Trait_;
+use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
@@ -214,9 +215,11 @@ private function reportInvalidNodeForName(Node $node): void
}
$backtrace = debug_backtrace();
- if (isset($backtrace[1])) {
- $fileInfo = new SmartFileInfo($backtrace[1]['file']);
- $fileAndLine = $fileInfo->getRelativeFilePathFromCwd() . ':' . $backtrace[1]['line'];
+ $rectorBacktrace = $this->matchRectorBacktraceCall($backtrace);
+
+ if ($rectorBacktrace) {
+ $fileInfo = new SmartFileInfo($rectorBacktrace['file']);
+ $fileAndLine = $fileInfo->getRelativeFilePathFromCwd() . ':' . $rectorBacktrace['line'];
$message .= PHP_EOL . PHP_EOL;
$message .= sprintf('Look at %s', $fileAndLine);
@@ -224,4 +227,22 @@ private function reportInvalidNodeForName(Node $node): void
throw new ShouldNotHappenException($message);
}
+
+ private function matchRectorBacktraceCall(array $backtrace): ?array
+ {
+ foreach ($backtrace as $singleTrace) {
+ if (! isset($singleTrace['object'])) {
+ continue;
+ }
+
+ // match a Rector class
+ if (! is_a($singleTrace['object'], RectorInterface::class)) {
+ continue;
+ }
+
+ return $singleTrace;
+ }
+
+ return $backtrace[1] ?? null;
+ }
}
diff --git a/rules/mockista-to-mockery/config/config.yaml b/rules/mockista-to-mockery/config/config.yaml
new file mode 100644
index 000000000000..5d175f868de3
--- /dev/null
+++ b/rules/mockista-to-mockery/config/config.yaml
@@ -0,0 +1,9 @@
+services:
+ _defaults:
+ public: true
+ autowire: true
+
+ Rector\MockistaToMockery\:
+ resource: '../src'
+ exclude:
+ - '../src/Rector/**/*Rector.php'
diff --git a/rules/mockista-to-mockery/src/MockistaDetector.php b/rules/mockista-to-mockery/src/MockistaDetector.php
new file mode 100644
index 000000000000..5d8bd41d1c48
--- /dev/null
+++ b/rules/mockista-to-mockery/src/MockistaDetector.php
@@ -0,0 +1,41 @@
+betterNodeFinder = $betterNodeFinder;
+ $this->nodeNameResolver = $nodeNameResolver;
+ }
+
+ public function isInClass(Class_ $class): bool
+ {
+ return (bool) $this->betterNodeFinder->findFirst((array) $class->stmts, function (Node $node) {
+ if (! $node instanceof FuncCall) {
+ return false;
+ }
+
+ return $this->nodeNameResolver->isName($node, 'mock');
+ });
+ }
+}
diff --git a/rules/mockista-to-mockery/src/Rector/ClassMethod/MockistaMockToMockeryMockRector.php b/rules/mockista-to-mockery/src/Rector/ClassMethod/MockistaMockToMockeryMockRector.php
new file mode 100644
index 000000000000..5398add89e9c
--- /dev/null
+++ b/rules/mockista-to-mockery/src/Rector/ClassMethod/MockistaMockToMockeryMockRector.php
@@ -0,0 +1,300 @@
+getId()->once->andReturn(1);
+ $mockUser->freeze();
+ }
+}
+PHP
+,
+ <<<'PHP'
+class SomeTest
+{
+ public function run()
+ {
+ $mockUser = Mockery::mock(User::class);
+ $mockUser->expects()->getId()->once()->andReturn(1);
+ }
+}
+PHP
+ ),
+ ]);
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getNodeTypes(): array
+ {
+ return [ClassMethod::class];
+ }
+
+ /**
+ * @param ClassMethod $node
+ */
+ public function refactor(Node $node): ?Node
+ {
+ if (! $this->isInTestClass($node)) {
+ return null;
+ }
+
+ $this->replaceMockWithMockerMockAndCollectMockVariableName($node);
+ $this->replaceMethodCallOncePropertyFetch($node);
+ $this->removeUnusedMethodCalls($node);
+ $this->replaceMethodCallWithExpects($node);
+
+ $this->switchWithAnyArgsAndOnceTwice($node);
+
+ return $node;
+ }
+
+ private function collectMockVariableName(FuncCall $funcCall): void
+ {
+ $parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE);
+ if (! $parentNode instanceof Assign) {
+ return;
+ }
+
+ if (! $parentNode->var instanceof Variable) {
+ return;
+ }
+
+ /** @var Variable $variable */
+ $variable = $parentNode->var;
+
+ /** @var string $variableName */
+ $variableName = $this->getName($variable);
+
+ $type = $funcCall->args[0]->value;
+ $mockedType = $this->getValue($type);
+
+ $this->mockVariableTypesByNames[$variableName] = $mockedType;
+ }
+
+ private function isMethodCallOrPropertyFetchOnMockVariable(Node $node): bool
+ {
+ if (! $node instanceof MethodCall && ! $this->isPropertyFetchDisguisedAsMethodCall($node)) {
+ return false;
+ }
+
+ if (! $node->var instanceof Variable) {
+ return false;
+ }
+
+ /** @var string $variableName */
+ $variableName = $this->getName($node->var);
+
+ return isset($this->mockVariableTypesByNames[$variableName]);
+ }
+
+ private function replaceMockWithMockerMockAndCollectMockVariableName(ClassMethod $classMethod): void
+ {
+ $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) {
+ if (! $this->isFuncCallName($node, 'mock')) {
+ return null;
+ }
+
+ /** @var FuncCall $node */
+ $this->collectMockVariableName($node);
+
+ return $this->createStaticCall('Mockery', 'mock', $node->args);
+ });
+ }
+
+ private function removeUnusedMethodCalls(ClassMethod $classMethod): void
+ {
+ $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) {
+ if (! $this->isMethodCallOrPropertyFetchOnMockVariable($node)) {
+ return null;
+ }
+
+ if (! $this->isNames($node->name, self::METHODS_TO_REMOVE)) {
+ return null;
+ }
+
+ $this->removeNode($node);
+ });
+ }
+
+ /**
+ * $mock->getMethod()->once()
+ * ↓
+ * $mock->expects()->getMethod()->once()
+ */
+ private function replaceMethodCallWithExpects(ClassMethod $classMethod): void
+ {
+ $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) {
+ if (! $this->isMethodCallOrPropertyFetchOnMockVariable($node)) {
+ return null;
+ }
+
+ // skip assigns
+ $parent = $node->getAttribute(AttributeKey::PARENT_NODE);
+ if ($parent instanceof Assign) {
+ return null;
+ }
+
+ /** @var MethodCall|PropertyFetch $node */
+ if ($this->isNames($node->name, self::METHODS_TO_REMOVE)) {
+ return null;
+ }
+
+ if ($this->isNames($node->name, ['expects', 'allows'])) {
+ return null;
+ }
+
+ // probably method mock
+ $expectedMethodCall = new MethodCall($node->var, 'expects');
+ $methodCall = new MethodCall($expectedMethodCall, $node->name);
+
+ if ($node instanceof PropertyFetch) {
+ return $methodCall;
+ }
+
+ $methodCall->args = $node->args;
+
+ return $this->decorateWithAnyArgs($node, $methodCall);
+ });
+ }
+
+ /**
+ * $mock->getMethod()->once
+ * ↓
+ * $mock->getMethod()->once()
+ */
+ private function replaceMethodCallOncePropertyFetch(ClassMethod $classMethod): void
+ {
+ $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) {
+ if (! $node instanceof PropertyFetch) {
+ return null;
+ }
+
+ if (! $this->isNames($node->name, ['once', 'twice'])) {
+ return null;
+ }
+
+ return new MethodCall($node->var, $node->name);
+ });
+ }
+
+ private function isPropertyFetchDisguisedAsMethodCall(Node $node): bool
+ {
+ if (! $node instanceof PropertyFetch) {
+ return false;
+ }
+
+ if ($node->var instanceof MethodCall) {
+ return false;
+ }
+
+ $variableName = $this->getName($node->var);
+ if (! isset($this->mockVariableTypesByNames[$variableName])) {
+ return false;
+ }
+
+ $mockVariableType = $this->mockVariableTypesByNames[$variableName];
+ $propertyName = $this->getName($node->name);
+ if ($propertyName === null) {
+ return false;
+ }
+
+ return method_exists($mockVariableType, $propertyName);
+ }
+
+ /**
+ * $mock->someMethodWithArgs()->once()
+ * ↓
+ * $mock->expects()->someMethodWithArgs()->withAnyArgs()->once()
+ */
+ private function decorateWithAnyArgs(MethodCall $originalMethodCall, MethodCall $expectsMethodCall): MethodCall
+ {
+ $variableName = $this->getName($originalMethodCall->var);
+ $mockVariableType = $this->mockVariableTypesByNames[$variableName];
+
+ $methodName = $this->getName($originalMethodCall->name);
+ if ($methodName === null) {
+ return $expectsMethodCall;
+ }
+
+ if (! method_exists($mockVariableType, $methodName)) {
+ return $expectsMethodCall;
+ }
+
+ $methodReflection = new ReflectionMethod($mockVariableType, $methodName);
+ if ($methodReflection->getNumberOfRequiredParameters() === 0) {
+ return $expectsMethodCall;
+ }
+
+ return new MethodCall($expectsMethodCall, 'withAnyArgs');
+ }
+
+ /**
+ * Order correction for @see replaceMethodCallWithExpects()
+ */
+ private function switchWithAnyArgsAndOnceTwice(ClassMethod $classMethod): void
+ {
+ $this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $node) {
+ if (! $node instanceof MethodCall) {
+ return null;
+ }
+
+ if (! $this->isNames($node->name, ['once', 'twice'])) {
+ return;
+ }
+
+ if (! $node->var instanceof MethodCall) {
+ return null;
+ }
+
+ /** @var MethodCall $previousMethodCall */
+ $previousMethodCall = $node->var;
+ if (! $this->isName($previousMethodCall->name, 'withAnyArgs')) {
+ return null;
+ }
+
+ [$node->name, $previousMethodCall->name] = [$previousMethodCall->name, $node->name];
+ });
+ }
+}
diff --git a/rules/mockista-to-mockery/src/Rector/Class_/MockeryTearDownRector.php b/rules/mockista-to-mockery/src/Rector/Class_/MockeryTearDownRector.php
new file mode 100644
index 000000000000..b0f8b1fb7a61
--- /dev/null
+++ b/rules/mockista-to-mockery/src/Rector/Class_/MockeryTearDownRector.php
@@ -0,0 +1,130 @@
+mockistaDetector = $mockistaDetector;
+ }
+
+ public function getDefinition(): RectorDefinition
+ {
+ return new RectorDefinition('Add Mockery::close() in tearDown() method if not yet', [
+ new CodeSample(
+ <<<'PHP'
+use PHPUnit\Framework\TestCase;
+
+class SomeTest extends TestCase
+{
+ public function test()
+ {
+ $mockUser = mock(User::class);
+ }
+}
+PHP
+,
+ <<<'PHP'
+use PHPUnit\Framework\TestCase;
+
+class SomeTest extends TestCase
+{
+ protected function tearDown(): void
+ {
+ Mockery::close();
+ }
+ public function test()
+ {
+ $mockUser = mock(User::class);
+ }
+}
+PHP
+
+ ),
+ ]);
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getNodeTypes(): array
+ {
+ return [Class_::class];
+ }
+
+ /**
+ * @param Class_ $node
+ */
+ public function refactor(Node $node): ?Node
+ {
+ if (! $this->mockistaDetector->isInClass($node)) {
+ return null;
+ }
+
+ $tearDownClassMethod = $node->getMethod('tearDown');
+ if ($tearDownClassMethod === null) {
+ $node->stmts[] = $this->createTearDownMethodWithMockeryClose();
+ } elseif (! $this->containsMockeryClose($tearDownClassMethod)) {
+ $tearDownClassMethod->stmts[] = $this->createMockeryClose();
+ }
+
+ return $node;
+ }
+
+ private function createTearDownMethodWithMockeryClose(): ClassMethod
+ {
+ $tearDownClassMethodBuilder = new Method('tearDown');
+ $tearDownClassMethodBuilder->setReturnType('void');
+ $tearDownClassMethodBuilder->makeProtected();
+
+ $staticCall = $this->createMockeryClose();
+ $tearDownClassMethodBuilder->addStmt($staticCall);
+
+ return $tearDownClassMethodBuilder->getNode();
+ }
+
+ private function containsMockeryClose(ClassMethod $classMethod): bool
+ {
+ return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) {
+ if (! $node instanceof StaticCall) {
+ return false;
+ }
+
+ if (! $this->isName($node->class, 'Mockery')) {
+ return false;
+ }
+
+ return $this->isName($node->name, 'close');
+ });
+ }
+
+ private function createMockeryClose(): Stmt
+ {
+ $staticCall = $this->createStaticCall('Mockery', 'close');
+
+ return BuilderHelpers::normalizeStmt($staticCall);
+ }
+}
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/fixture.php.inc b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/fixture.php.inc
new file mode 100644
index 000000000000..c83ee0ee9f79
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/fixture.php.inc
@@ -0,0 +1,33 @@
+getId()->once->andReturn(1);
+ }
+}
+
+?>
+-----
+expects()->getId()->once()->andReturn(1);
+ }
+}
+
+?>
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/method_args.php.inc b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/method_args.php.inc
new file mode 100644
index 000000000000..2b9fc656e16d
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/method_args.php.inc
@@ -0,0 +1,33 @@
+getId(1);
+ }
+}
+
+?>
+-----
+expects()->getId(1);
+ }
+}
+
+?>
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/method_with_args_without_any.php.inc b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/method_with_args_without_any.php.inc
new file mode 100644
index 000000000000..a44308ba18b2
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/method_with_args_without_any.php.inc
@@ -0,0 +1,35 @@
+methodWithArg()->once();
+ }
+}
+
+?>
+-----
+expects()->methodWithArg()->once()->withAnyArgs();
+ }
+}
+
+?>
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/methods_to_remove.php.inc b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/methods_to_remove.php.inc
new file mode 100644
index 000000000000..7096100d9e24
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/methods_to_remove.php.inc
@@ -0,0 +1,33 @@
+freeze();
+ $mockUser->assertExpectations();
+ }
+}
+
+?>
+-----
+
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/property_or_method.php.inc b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/property_or_method.php.inc
new file mode 100644
index 000000000000..e0bb72a0cee3
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/property_or_method.php.inc
@@ -0,0 +1,35 @@
+insert->once;
+ }
+}
+
+?>
+-----
+expects()->insert()->once();
+ }
+}
+
+?>
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/set_value.php.inc b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/set_value.php.inc
new file mode 100644
index 000000000000..e764b7b110e4
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/set_value.php.inc
@@ -0,0 +1,33 @@
+id = 5;
+ }
+}
+
+?>
+-----
+id = 5;
+ }
+}
+
+?>
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/twice.php.inc b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/twice.php.inc
new file mode 100644
index 000000000000..59fa06d51e97
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/twice.php.inc
@@ -0,0 +1,35 @@
+insert->twice;
+ }
+}
+
+?>
+-----
+expects()->insert()->twice();
+ }
+}
+
+?>
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/use_value.php.inc b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/use_value.php.inc
new file mode 100644
index 000000000000..92f5b230148b
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Fixture/use_value.php.inc
@@ -0,0 +1,37 @@
+id = 5;
+ $mockUser->run($mockUser->id);
+ }
+}
+
+?>
+-----
+id = 5;
+ $mockUser->expects()->run($mockUser->id);
+ }
+}
+
+?>
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/MockistaMockToMockeryMockRectorTest.php b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/MockistaMockToMockeryMockRectorTest.php
new file mode 100644
index 000000000000..f968653ac991
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/MockistaMockToMockeryMockRectorTest.php
@@ -0,0 +1,30 @@
+doTestFile($file);
+ }
+
+ public function provideData(): Iterator
+ {
+ return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
+ }
+
+ protected function getRectorClass(): string
+ {
+ return MockistaMockToMockeryMockRector::class;
+ }
+}
diff --git a/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Source/User.php b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Source/User.php
new file mode 100644
index 000000000000..08031fd1c71d
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/ClassMethod/MockistaMockToMockeryMockRector/Source/User.php
@@ -0,0 +1,16 @@
+
+-----
+
diff --git a/rules/mockista-to-mockery/tests/Rector/Class_/MockeryTearDownRector/Fixture/fixture.php.inc b/rules/mockista-to-mockery/tests/Rector/Class_/MockeryTearDownRector/Fixture/fixture.php.inc
new file mode 100644
index 000000000000..60b830da28ed
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/Class_/MockeryTearDownRector/Fixture/fixture.php.inc
@@ -0,0 +1,35 @@
+
+-----
+
diff --git a/rules/mockista-to-mockery/tests/Rector/Class_/MockeryTearDownRector/Fixture/skip_existing.php.inc b/rules/mockista-to-mockery/tests/Rector/Class_/MockeryTearDownRector/Fixture/skip_existing.php.inc
new file mode 100644
index 000000000000..7120307da8fc
--- /dev/null
+++ b/rules/mockista-to-mockery/tests/Rector/Class_/MockeryTearDownRector/Fixture/skip_existing.php.inc
@@ -0,0 +1,17 @@
+doTestFile($file);
+ }
+
+ public function provideData(): Iterator
+ {
+ return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
+ }
+
+ protected function getRectorClass(): string
+ {
+ return MockeryTearDownRector::class;
+ }
+}
diff --git a/stubs/Mockista/DummyMock.php b/stubs/Mockista/DummyMock.php
new file mode 100644
index 000000000000..8ef2e1e228ba
--- /dev/null
+++ b/stubs/Mockista/DummyMock.php
@@ -0,0 +1,10 @@
+