Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/sets/phpunit-code-quality.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Rector\PHPUnit\CodeQuality\Rector\CallLike\DirectInstanceOverMockArgRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddParamTypeFromDependsRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddReturnTypeToDependedRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\InlineStubPropertyToCreateStubMethodCallRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\NarrowUnusedSetUpDefinedPropertyRector;
Expand Down Expand Up @@ -57,7 +58,6 @@
use Rector\PHPUnit\PHPUnit120\Rector\CallLike\CreateStubOverCreateMockArgRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\PropertyCreateMockToCreateStubRector;
use Rector\PHPUnit\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector;
use Rector\PHPUnit\PHPUnit120\Rector\Property\BareVarToStubIntersectionRector;
use Rector\PHPUnit\PHPUnit120\Rector\Property\MockObjectVarToStubRector;
use Rector\PHPUnit\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
use Rector\PHPUnit\PHPUnit90\Rector\MethodCall\ReplaceAtMethodWithDesiredMatcherRector;
Expand Down Expand Up @@ -139,7 +139,7 @@
ExpressionCreateMockToCreateStubRector::class,
PropertyCreateMockToCreateStubRector::class,
MockObjectVarToStubRector::class,
BareVarToStubIntersectionRector::class,
AddStubIntersectionVarToStubPropertyRector::class,
InlineStubPropertyToCreateStubMethodCallRector::class,

// @test first, enable later
Expand Down
4 changes: 2 additions & 2 deletions config/sets/phpunit-mock-to-stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddIntersectionVarToMockObjectPropertyRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector;
use Rector\PHPUnit\PHPUnit120\Rector\CallLike\CreateStubInCoalesceArgRector;
use Rector\PHPUnit\PHPUnit120\Rector\CallLike\CreateStubOverCreateMockArgRector;
use Rector\PHPUnit\PHPUnit120\Rector\Class_\PropertyCreateMockToCreateStubRector;
use Rector\PHPUnit\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector;
use Rector\PHPUnit\PHPUnit120\Rector\Property\BareVarToStubIntersectionRector;
use Rector\PHPUnit\PHPUnit120\Rector\Property\MockObjectVarToStubRector;

return static function (RectorConfig $rectorConfig): void {
Expand All @@ -19,7 +19,7 @@
ExpressionCreateMockToCreateStubRector::class,
PropertyCreateMockToCreateStubRector::class,
MockObjectVarToStubRector::class,
BareVarToStubIntersectionRector::class,
AddIntersectionVarToMockObjectPropertyRector::class,
AddStubIntersectionVarToStubPropertyRector::class,
]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddIntersectionVarToMockObjectPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class SkipExistingIntersectionVarTest extends TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\MockObject&\stdClass
*/
private \PHPUnit\Framework\MockObject\MockObject $someServiceMock;

protected function setUp(): void
{
$this->someServiceMock = $this->createMock(\stdClass::class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddIntersectionVarToMockObjectPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class StaticCallTest extends TestCase
{
private \PHPUnit\Framework\MockObject\MockObject $someServiceMock;

protected function setUp(): void
{
$this->someServiceMock = self::createMock(\stdClass::class);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddIntersectionVarToMockObjectPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class StaticCallTest extends TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\MockObject&\stdClass
*/
private \PHPUnit\Framework\MockObject\MockObject $someServiceMock;

protected function setUp(): void
{
$this->someServiceMock = self::createMock(\stdClass::class);
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace Rector\PHPUnit\Tests\PHPUnit120\Rector\Property\BareVarToStubIntersectionRector;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class BareVarToStubIntersectionRectorTest extends AbstractRectorTestCase
final class AddStubIntersectionVarToStubPropertyRectorTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class BareVarWithoutSetupTest extends TestCase
{
/**
* @var FormBuilderInterface
*/
private \PHPUnit\Framework\MockObject\Stub $formBuilder;
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class BareVarWithoutSetupTest extends TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\Stub&FormBuilderInterface
*/
private \PHPUnit\Framework\MockObject\Stub $formBuilder;
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class SomeTest extends TestCase
{
private \PHPUnit\Framework\MockObject\Stub $someServiceStub;

protected function setUp(): void
{
$this->someServiceStub = $this->createStub(\stdClass::class);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class SomeTest extends TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\Stub&\stdClass
*/
private \PHPUnit\Framework\MockObject\Stub $someServiceStub;

protected function setUp(): void
{
$this->someServiceStub = $this->createStub(\stdClass::class);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class OverwriteExistingVarTest extends TestCase
{
/**
* @var \stdClass
*/
private \PHPUnit\Framework\MockObject\Stub $someServiceStub;

protected function setUp(): void
{
$this->someServiceStub = $this->createStub(\stdClass::class);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class OverwriteExistingVarTest extends TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\Stub&\stdClass
*/
private \PHPUnit\Framework\MockObject\Stub $someServiceStub;

protected function setUp(): void
{
$this->someServiceStub = $this->createStub(\stdClass::class);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class SkipExistingIntersectionVarTest extends TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\Stub&\stdClass
*/
private \PHPUnit\Framework\MockObject\Stub $someServiceStub;

protected function setUp(): void
{
$this->someServiceStub = $this->createStub(\stdClass::class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class SkipMockObjectPropertyTest extends TestCase
{
private \PHPUnit\Framework\MockObject\MockObject $someServiceMock;

protected function setUp(): void
{
$this->someServiceMock = $this->createStub(\stdClass::class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

final class SkipNonTestClass
{
private \PHPUnit\Framework\MockObject\Stub $someServiceStub;

public function setUp(): void
{
$this->someServiceStub = $this->createStub(\stdClass::class);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Rector\PHPUnit\Tests\PHPUnit120\Rector\Property\BareVarToStubIntersectionRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;

final class SkipStubShortNameTest extends TestCase
final class SkipStubShortNameVarTest extends TestCase
{
/**
* @var Stub
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class StaticCallTest extends TestCase
{
private \PHPUnit\Framework\MockObject\Stub $someServiceStub;

protected function setUp(): void
{
$this->someServiceStub = self::createStub(\stdClass::class);
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector\Fixture;

use PHPUnit\Framework\TestCase;

final class StaticCallTest extends TestCase
{
/**
* @var \PHPUnit\Framework\MockObject\Stub&\stdClass
*/
private \PHPUnit\Framework\MockObject\Stub $someServiceStub;

protected function setUp(): void
{
$this->someServiceStub = self::createStub(\stdClass::class);
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddStubIntersectionVarToStubPropertyRector;

return RectorConfig::configure()
->withRules([AddStubIntersectionVarToStubPropertyRector::class]);

This file was deleted.

This file was deleted.

Loading
Loading