Skip to content

Commit

Permalink
Merge pull request #14 from jakzal/phpunit-9
Browse files Browse the repository at this point in the history
Support PHPUnit 9
  • Loading branch information
jakzal committed Feb 10, 2020
2 parents 2cba47f + 5577383 commit 064b208
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ class DiscworldTest extends TestCase
private $vimes;

/**
* @var Nobby|Fred|MockObject
* @var Nobby|MockObject
*/
private $nobbyAndFred;

public function test_it_hires_new_recruits_for_nightwatch()
{
$discworld = new Discworld($this->vimes, $this->nobbyAndFred);
$discworld = new Discworld($this->vimes, $this->nobby);

$this->vimes->expects($this->once())
->method('recruit')
->with($this->nobbyAndFred);
->with($this->nobby);

$discworld->createNightWatch();
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "library",
"require": {
"php": "^7.2,<8.0",
"phpunit/phpunit": "^8.0",
"phpunit/phpunit": "^8.5 || ^9.0",
"phpdocumentor/reflection-docblock": "^4.0.1"
},
"require-dev": {
Expand All @@ -28,7 +28,7 @@
],
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
"dev-master": "1.5.x-dev"
}
}
}
4 changes: 2 additions & 2 deletions src/TestCase/TestDoubles.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

trait TestDoubles
{
abstract public function getMockBuilder($className): MockBuilder;
abstract public function getMockBuilder(string $className): MockBuilder;

abstract protected function prophesize($classOrInterface = null): ObjectProphecy;

Expand Down Expand Up @@ -54,7 +54,7 @@ private function createTestDoubleWithProphecy(array $types): ObjectProphecy

private function createTestDoubleWithPhpunit(array $types): MockObject
{
$normalisedTypes = 1 === \count($types) ? \array_pop($types) : (!empty($types) ? $types : \stdClass::class);
$normalisedTypes = \array_shift($types) ?? \stdClass::class;

return $this->getMockBuilder($normalisedTypes)
->disableOriginalConstructor()
Expand Down
8 changes: 2 additions & 6 deletions tests/TestCase/TestDoubles/PhpunitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
use Zalas\PHPUnit\Doubles\Tests\TestCase\TestDoubles\Fixtures\Copper;
use Zalas\PHPUnit\Doubles\Tests\TestCase\TestDoubles\Fixtures\Death;
use Zalas\PHPUnit\Doubles\Tests\TestCase\TestDoubles\Fixtures\Discworld;
use Zalas\PHPUnit\Doubles\Tests\TestCase\TestDoubles\Fixtures\Fred;
use Zalas\PHPUnit\Doubles\Tests\TestCase\TestDoubles\Fixtures\Nobby;
use Zalas\PHPUnit\Doubles\Tests\TestCase\TestDoubles\Fixtures\Vimes;

class PhpunitTest extends TestCase
Expand All @@ -23,12 +21,12 @@ class PhpunitTest extends TestCase
private $vimes;

/**
* @var Nobby|Copper|MockObject
* @var Copper|MockObject
*/
private $nobby;

/**
* @var Fred|Copper|MockObject
* @var Copper|MockObject
*/
private $fred;

Expand All @@ -43,8 +41,6 @@ public function test_it_initialises_mock_objects()
$this->assertInstanceOf(MockObject::class, $this->nobby);
$this->assertInstanceOf(MockObject::class, $this->fred);
$this->assertInstanceOf(Vimes::class, $this->vimes);
$this->assertInstanceOf(Nobby::class, $this->nobby);
$this->assertInstanceOf(Fred::class, $this->fred);
$this->assertInstanceOf(Copper::class, $this->nobby);
$this->assertInstanceOf(Copper::class, $this->fred);
}
Expand Down

0 comments on commit 064b208

Please sign in to comment.