Skip to content

Commit 04f78fe

Browse files
committed
Merge branch 'phpunit-8.2-and-php-7.4'
Close #37
2 parents d49b8c5 + 8ef45f3 commit 04f78fe

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

.travis.yml

+20-15
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,44 @@ cache:
88

99
env:
1010
- PHPUNIT_VERSION=dev-master
11-
- PHPUNIT_VERSION=~6.0.0
12-
- PHPUNIT_VERSION=~6.1.0
13-
- PHPUNIT_VERSION=~6.2.0
14-
- PHPUNIT_VERSION=~6.3.0
15-
- PHPUNIT_VERSION=~6.4.0
16-
- PHPUNIT_VERSION=~6.5.0
17-
- PHPUNIT_VERSION=~7.0.0
18-
- PHPUNIT_VERSION=~7.1.0
19-
- PHPUNIT_VERSION=~7.2.0
20-
- PHPUNIT_VERSION=~7.3.0
21-
- PHPUNIT_VERSION=~7.4.0
22-
- PHPUNIT_VERSION=~7.5.0
23-
- PHPUNIT_VERSION=~8.0.0
11+
- PHPUNIT_VERSION=~8.2.0
2412
- PHPUNIT_VERSION=~8.1.0
13+
- PHPUNIT_VERSION=~8.0.0
14+
- PHPUNIT_VERSION=~7.5.0
15+
- PHPUNIT_VERSION=~7.4.0
16+
- PHPUNIT_VERSION=~7.3.0
17+
- PHPUNIT_VERSION=~7.2.0
18+
- PHPUNIT_VERSION=~7.1.0
19+
- PHPUNIT_VERSION=~7.0.0
20+
- PHPUNIT_VERSION=~6.5.0
21+
- PHPUNIT_VERSION=~6.4.0
22+
- PHPUNIT_VERSION=~6.3.0
23+
- PHPUNIT_VERSION=~6.2.0
24+
- PHPUNIT_VERSION=~6.1.0
25+
- PHPUNIT_VERSION=~6.0.0
2526

2627
php:
28+
- 7.4snapshot
2729
- 7.3
2830
- 7.2
2931
- 7.1
3032
- 7
31-
- hhvm
3233

3334
matrix:
3435
fast_finish: true
3536
exclude:
3637
- php: 7.1
3738
env: PHPUNIT_VERSION=dev-master
39+
- php: 7.1
40+
env: PHPUNIT_VERSION=~8.2.0
3841
- php: 7.1
3942
env: PHPUNIT_VERSION=~8.1.0
4043
- php: 7.1
4144
env: PHPUNIT_VERSION=~8.0.0
4245
- php: 7
4346
env: PHPUNIT_VERSION=dev-master
47+
- php: 7
48+
env: PHPUNIT_VERSION=~8.2.0
4449
- php: 7
4550
env: PHPUNIT_VERSION=~8.1.0
4651
- php: 7
@@ -58,7 +63,7 @@ matrix:
5863
- php: 7
5964
env: PHPUNIT_VERSION=~7.0.0
6065
allow_failures:
61-
- php: hhvm
66+
- php: 7.4snapshot
6267
- env: PHPUNIT_VERSION=dev-master
6368

6469
install:

autoload.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class_alias(
77
);
88
}
99

10-
if (! interface_exists(\PHPUnit\Framework\MockObject\Invocation::class)) {
10+
if (! interface_exists(\PHPUnit\Framework\MockObject\Invocation::class)
11+
&& interface_exists(\PHPUnit_Framework_MockObject_Invocation::class)
12+
) {
1113
class_alias(
1214
\PHPUnit_Framework_MockObject_Invocation::class,
1315
\PHPUnit\Framework\MockObject\Invocation::class

classes/DefaultArgumentRemoverReturnTypes.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ public function invoked(Invocation $invocation)
2929
*/
3030
public function matches(Invocation $invocation) : bool
3131
{
32-
if ($invocation instanceof Invocation\StaticInvocation) {
33-
$this->removeDefaultArguments($invocation);
32+
$iClass = class_exists(Invocation::class);
33+
34+
if ($invocation instanceof Invocation\StaticInvocation
35+
|| $iClass
36+
) {
37+
$this->removeDefaultArguments(
38+
$invocation,
39+
$iClass ? Invocation::class : Invocation\StaticInvocation::class
40+
);
3441
} else {
3542
MockFunctionGenerator::removeDefaultArguments($invocation->parameters);
3643
}
@@ -64,12 +71,12 @@ public function toString() : string
6471
*
6572
* @SuppressWarnings(PHPMD)
6673
*/
67-
private function removeDefaultArguments(Invocation\StaticInvocation $invocation)
74+
private function removeDefaultArguments(Invocation $invocation, string $class)
6875
{
6976
$remover = function () {
7077
MockFunctionGenerator::removeDefaultArguments($this->parameters);
7178
};
7279

73-
$remover->bindTo($invocation, Invocation\StaticInvocation::class)();
80+
$remover->bindTo($invocation, $class)();
7481
}
7582
}

tests/MockObjectProxyTest.php

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
namespace phpmock\phpunit;
44

5-
use PHPUnit\Framework\MockObject\Matcher\MethodName;
6-
use PHPUnit\Framework\MockObject\Stub\MatcherCollection;
7-
use PHPUnit\Framework\TestCase;
85
use phpmock\integration\MockDelegateFunctionBuilder;
96
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
7+
use PHPUnit\Framework\MockObject\ConfigurableMethod;
108
use PHPUnit\Framework\MockObject\Matcher\Invocation;
9+
use PHPUnit\Framework\MockObject\Matcher\MethodName;
1110
use PHPUnit\Framework\MockObject\MockObject;
11+
use PHPUnit\Framework\MockObject\Stub\MatcherCollection;
12+
use PHPUnit\Framework\TestCase;
13+
use SebastianBergmann\Type\Type;
1214

1315
/**
1416
* Tests MockObjectProxyTest.
@@ -31,10 +33,17 @@ public function testExpects()
3133
{
3234
$matcher = $this->getMockBuilder(Invocation::class)->getMock();
3335

36+
$methods = class_exists(ConfigurableMethod::class)
37+
? new ConfigurableMethod(
38+
MockDelegateFunctionBuilder::METHOD,
39+
$this->prophesize(Type::class)->reveal()
40+
)
41+
: [MockDelegateFunctionBuilder::METHOD];
42+
3443
$invocationMocker = new InvocationMocker(
3544
$this->prophesize(MatcherCollection::class)->reveal(),
3645
$this->prophesize(Invocation::class)->reveal(),
37-
[MockDelegateFunctionBuilder::METHOD]
46+
$methods
3847
);
3948

4049
$prophecy = $this->prophesize(MockObject::class);

0 commit comments

Comments
 (0)