Skip to content

Commit

Permalink
Do not isolate
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 22, 2021
1 parent 4e12ccf commit 9bd00f9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
25 changes: 25 additions & 0 deletions tests/Mockery/Foo2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types = 1);

namespace PHPStan\Mockery;

class Foo2 implements Baz
{

/** @var bool */
private $optional;

public function __construct(bool $optional = true)
{
$this->optional = $optional;
}

public function doFoo(): ?string
{
if ($this->optional) {
return null;
}

return 'foo';
}

}
25 changes: 25 additions & 0 deletions tests/Mockery/Foo3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types = 1);

namespace PHPStan\Mockery;

class Foo3 implements Baz
{

/** @var bool */
private $optional;

public function __construct(bool $optional = true)
{
$this->optional = $optional;
}

public function doFoo(): ?string
{
if ($this->optional) {
return null;
}

return 'foo';
}

}
17 changes: 9 additions & 8 deletions tests/Mockery/IsolatedMockeryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@

namespace PHPStan\Mockery;

/**
* @runTestsInSeparateProcesses
*/
class IsolatedMockeryTest extends \PHPUnit\Framework\TestCase
{

public function testAliasMock(): void
{
$fooMock = \Mockery::mock('alias:' . Foo::class);
$this->requireFoo($fooMock);
$fooMock = \Mockery::mock('alias:' . Foo2::class);
$this->requireFoo2($fooMock);

$fooMock->shouldReceive('doFoo')->andReturn('bar');
self::assertSame('bar', $fooMock->doFoo());
}

public function testOverloadMock(): void
{
$fooMock = \Mockery::mock('overload:' . Foo::class);
$this->requireFoo($fooMock);
$fooMock = \Mockery::mock('overload:' . Foo3::class);
$this->requireFoo3($fooMock);

$fooMock->shouldReceive('doFoo')->andReturn('bar');
self::assertSame('bar', $fooMock->doFoo());
}

private function requireFoo(Foo $foo): void
private function requireFoo2(Foo2 $foo): void
{
}

private function requireFoo3(Foo3 $foo): void
{
}

Expand Down

0 comments on commit 9bd00f9

Please sign in to comment.