Skip to content

Commit

Permalink
add mock object test fixture (#5335)
Browse files Browse the repository at this point in the history
* add mock object test fixture

* mock
  • Loading branch information
TomasVotruba committed Dec 6, 2023
1 parent 79c57f0 commit b6f53b9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@

namespace PHPUnit\Framework;

use PHPUnit\Event\NoPreviousThrowableException;
use PHPUnit\Framework\MockObject\MockObject;

if (! class_exists('PHPUnit\Framework\TestCase')) {
abstract class TestCase
{
/**
* @psalm-template RealInstanceType of object
*
* @psalm-param class-string<RealInstanceType> $originalClassName
*
* @psalm-return MockObject&RealInstanceType
*/
protected function createMock(string $originalClassName): MockObject
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector\Fixture;

use PHPUnit\Framework\TestCase;

final class IncludeMock extends TestCase
{
private $value;

public function setUp(): void
{
parent::setUp();

$this->value = $this->createMock(\stdClass::class);
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector\Fixture;

use PHPUnit\Framework\TestCase;

final class IncludeMock extends TestCase
{
private \PHPUnit\Framework\MockObject\MockObject $value;

public function setUp(): void
{
parent::setUp();

$this->value = $this->createMock(\stdClass::class);
}
}

?>

0 comments on commit b6f53b9

Please sign in to comment.