-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Split test cases used in static code analysis
- Loading branch information
1 parent
c804947
commit 64d2628
Showing
5 changed files
with
185 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2018 Jan Gregor Emge-Triebel | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/Jan0707/phpstan-prophecy | ||
*/ | ||
|
||
namespace JanGregor\Prophecy\Test\StaticAnalysis\Test; | ||
|
||
use JanGregor\Prophecy\Test\StaticAnalysis\Src; | ||
use PHPUnit\Framework; | ||
use Prophecy\Argument; | ||
use Prophecy\Prophecy; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @coversNothing | ||
*/ | ||
final class ProphesizeTest extends Framework\TestCase | ||
{ | ||
/** | ||
* @var Prophecy\ObjectProphecy|Src\BaseModel | ||
*/ | ||
private $prophecy; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->prophecy = $this->prophesize(Src\BaseModel::class); | ||
} | ||
|
||
public function testInSetUp(): void | ||
{ | ||
$this->prophecy | ||
->getFoo() | ||
->willReturn('bar'); | ||
|
||
$this->prophecy | ||
->doubleTheNumber(Argument::is(2)) | ||
->willReturn(5); | ||
|
||
$testDouble = $this->prophecy->reveal(); | ||
|
||
self::assertEquals('bar', $testDouble->getFoo()); | ||
self::assertEquals(5, $testDouble->doubleTheNumber(2)); | ||
} | ||
|
||
public function testInTestMethod(): void | ||
{ | ||
$prophecy = $this->prophesize(Src\BaseModel::class); | ||
|
||
$prophecy | ||
->getFoo() | ||
->willReturn('bar'); | ||
|
||
$prophecy | ||
->doubleTheNumber(Argument::is(2)) | ||
->willReturn(5); | ||
|
||
$testDouble = $prophecy->reveal(); | ||
|
||
self::assertEquals('bar', $testDouble->getFoo()); | ||
self::assertEquals(5, $testDouble->doubleTheNumber(2)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2018 Jan Gregor Emge-Triebel | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/Jan0707/phpstan-prophecy | ||
*/ | ||
|
||
namespace JanGregor\Prophecy\Test\StaticAnalysis\Test; | ||
|
||
use JanGregor\Prophecy\Test\StaticAnalysis\Src; | ||
use PHPUnit\Framework; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @coversNothing | ||
*/ | ||
final class WillExtendTest extends Framework\TestCase | ||
{ | ||
public function testInTestMethod(): void | ||
{ | ||
$prophecy = $this->prophesize()->willExtend(Src\Baz::class); | ||
|
||
$prophecy | ||
->baz() | ||
->shouldBeCalled() | ||
->willReturn('Hmm'); | ||
|
||
$subject = new Src\BaseModel(); | ||
|
||
self::assertSame('Hmm', $subject->baz($prophecy->reveal())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2018 Jan Gregor Emge-Triebel | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/Jan0707/phpstan-prophecy | ||
*/ | ||
|
||
namespace JanGregor\Prophecy\Test\StaticAnalysis\Test; | ||
|
||
use JanGregor\Prophecy\Test\StaticAnalysis\Src; | ||
use PHPUnit\Framework; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @coversNothing | ||
*/ | ||
final class WillImplementTest extends Framework\TestCase | ||
{ | ||
public function testInTestMethod(): void | ||
{ | ||
$prophecy = $this->prophesize(Src\Foo::class)->willImplement(Src\Bar::class); | ||
|
||
$prophecy | ||
->bar() | ||
->shouldBeCalled() | ||
->willReturn('Oh'); | ||
|
||
$subject = new Src\BaseModel(); | ||
|
||
self::assertSame('Oh', $subject->bar($prophecy->reveal())); | ||
} | ||
} |