Skip to content

Commit f9d3c12

Browse files
authored
Merge pull request #43 from facile-it/feature/phpunit65
Support PHPUnit 6.5
2 parents 8508921 + 0a92a82 commit f9d3c12

File tree

8 files changed

+24
-22
lines changed

8 files changed

+24
-22
lines changed

composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@
4848
"require": {
4949
"php": ">=7.0",
5050
"phpcollection/phpcollection": "^0.5",
51-
"psr/container": "^1.0",
52-
"phpunit/phpunit-mock-objects": "^4.0"
51+
"phpunit/phpunit-mock-objects": "^5.0",
52+
"psr/container": "^1.0"
5353
},
5454
"require-dev": {
5555
"friendsofphp/php-cs-fixer": "^2.3",
5656
"mockery/mockery": "^0.9.9",
5757
"phake/phake": "^3.0",
5858
"phpspec/prophecy": "^1.7",
59-
"phpunit/phpunit": "^6.0"
59+
"phpunit/phpunit": "^6.0",
60+
"sebastian/diff": "^2.0"
6061
},
6162
"suggest": {
6263
"phpspec/prophecy": "To allow loading of ProphecyPlugin",

src/Moka.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use Moka\Proxy\ProxyTrait;
1515
use Moka\Strategy\MockingStrategyInterface;
1616
use Phake_IMock as PhakeMock;
17+
use PHPUnit\Framework\MockObject\MockObject;
1718
use PHPUnit\Framework\TestCase;
18-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1919
use Prophecy\Prophecy\ObjectProphecy;
2020
use Prophecy\Prophet;
2121

src/Plugin/PHPUnit/PHPUnitMockingStrategy.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
use Moka\Exception\MissingDependencyException;
77
use Moka\Strategy\AbstractMockingStrategy;
88
use Moka\Stub\MethodStub;
9-
use PHPUnit_Framework_MockObject_Generator as MockGenerator;
10-
use PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount as AnyInvokedCountMatcher;
11-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
9+
use PHPUnit\Framework\MockObject\Generator;
10+
use PHPUnit\Framework\MockObject\Matcher\AnyInvokedCount;
11+
use PHPUnit\Framework\MockObject\MockObject;
1212

1313
/**
1414
* Class PHPUnitMockingStrategy
1515
* @package Moka\Strategy
1616
*/
1717
class PHPUnitMockingStrategy extends AbstractMockingStrategy
1818
{
19-
const CLASS_NAME = MockGenerator::class;
19+
const CLASS_NAME = Generator::class;
2020
const PACKAGE_NAME = 'phpunit/phpunit-mock-objects';
2121

2222
/**
23-
* @var MockGenerator
23+
* @var Generator
2424
*/
2525
private $generator;
2626

@@ -33,16 +33,17 @@ public function __construct()
3333
{
3434
self::checkDependencies(self::CLASS_NAME, self::PACKAGE_NAME);
3535

36-
$this->generator = new MockGenerator();
36+
$this->generator = new Generator();
3737
$this->setMockType(MockObject::class);
3838
}
3939

4040
/**
4141
* @param string $fqcn
4242
* @return MockObject
4343
*
44-
* @throws \InvalidArgumentException
45-
* @throws \PHPUnit_Framework_MockObject_RuntimeException
44+
* @throws \PHPUnit\Framework\Exception
45+
* @throws \PHPUnit\Framework\MockObject\RuntimeException
46+
* @throws \ReflectionException
4647
*/
4748
protected function doBuild(string $fqcn)
4849
{
@@ -58,14 +59,15 @@ protected function doBuild(string $fqcn)
5859
/**
5960
* @param MockObject $mock
6061
* @param MethodStub $stub
61-
* @return void
62+
*
63+
* @throws \PHPUnit\Framework\MockObject\RuntimeException
6264
*/
6365
protected function doDecorateWithMethod($mock, MethodStub $stub)
6466
{
6567
$methodName = $stub->getName();
6668
$methodValue = $stub->getValue();
6769

68-
$partial = $mock->expects(new AnyInvokedCountMatcher())->method($methodName);
70+
$partial = $mock->expects(new AnyInvokedCount())->method($methodName);
6971
$methodValue instanceof \Throwable
7072
? $partial->willThrowException($methodValue)
7173
: $partial->willReturn($methodValue);

src/Plugin/PHPUnit/moka.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use Moka\Moka;
77
use Moka\Proxy\ProxyInterface;
8-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
8+
use PHPUnit\Framework\MockObject\MockObject;
99

1010
/**
1111
* @param string $fqcnOrAlias

tests/Builder/ProxyBuilderTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Moka\Plugin\PHPUnit\PHPUnitMockingStrategy;
88
use Moka\Proxy\ProxyInterface;
99
use Moka\Strategy\MockingStrategyInterface;
10+
use PHPUnit\Framework\MockObject\MockObject;
1011
use PHPUnit\Framework\TestCase;
11-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1212

1313
class ProxyBuilderTest extends TestCase
1414
{
@@ -77,7 +77,6 @@ protected function setUp()
7777

7878
$this->mockingStrategy = new PHPUnitMockingStrategy();
7979

80-
8180
$this->proxyBuilder = new ProxyBuilder($this->mockingStrategy);
8281
}
8382
}

tests/Generator/ProxyGeneratorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Moka\Proxy\ProxyInterface;
88
use Moka\Strategy\MockingStrategyInterface;
99
use Moka\Tests\FooTestClass;
10+
use PHPUnit\Framework\MockObject\MockObject;
1011
use PHPUnit\Framework\TestCase;
11-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1212

1313
class ProxyGeneratorTest extends TestCase
1414
{

tests/Generator/Template/FakeTemplateTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
namespace Tests\Generator\Template;
55

66
use Moka\Exception\InvalidArgumentException;
7+
use PHPUnit\Framework\MockObject\MockObject;
78
use PHPUnit\Framework\TestCase;
8-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
99

1010
class FakeTemplateTest extends TestCase
1111
{

tests/Proxy/ProxyTraitTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use Moka\Proxy\ProxyInterface;
77
use Moka\Strategy\MockingStrategyInterface;
88
use Moka\Tests\FooTestClass;
9+
use PHPUnit\Framework\MockObject\MockObject;
910
use PHPUnit\Framework\TestCase;
10-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1111

1212
class ProxyTraitTest extends TestCase
1313
{
@@ -56,7 +56,7 @@ public function testStub()
5656
$this->proxy->__moka_setMockingStrategy($this->mockingStrategy);
5757

5858
$this->proxy->stub([
59-
'getInt' => 1138
59+
'getInt' => 1138,
6060
]);
6161
}
6262

@@ -110,7 +110,7 @@ public function testGetSuccess()
110110
->method('call');
111111

112112
$this->proxy->stub([
113-
'$property' => true
113+
'$property' => true,
114114
]);
115115

116116
$this->proxy->property;

0 commit comments

Comments
 (0)