Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Travis CI configuration - PHPUnit 8.2 + PHP 7.4 #37

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,44 @@ cache:

env:
- PHPUNIT_VERSION=dev-master
- PHPUNIT_VERSION=~6.0.0
- PHPUNIT_VERSION=~6.1.0
- PHPUNIT_VERSION=~6.2.0
- PHPUNIT_VERSION=~6.3.0
- PHPUNIT_VERSION=~6.4.0
- PHPUNIT_VERSION=~6.5.0
- PHPUNIT_VERSION=~7.0.0
- PHPUNIT_VERSION=~7.1.0
- PHPUNIT_VERSION=~7.2.0
- PHPUNIT_VERSION=~7.3.0
- PHPUNIT_VERSION=~7.4.0
- PHPUNIT_VERSION=~7.5.0
- PHPUNIT_VERSION=~8.0.0
- PHPUNIT_VERSION=~8.2.0
- PHPUNIT_VERSION=~8.1.0
- PHPUNIT_VERSION=~8.0.0
- PHPUNIT_VERSION=~7.5.0
- PHPUNIT_VERSION=~7.4.0
- PHPUNIT_VERSION=~7.3.0
- PHPUNIT_VERSION=~7.2.0
- PHPUNIT_VERSION=~7.1.0
- PHPUNIT_VERSION=~7.0.0
- PHPUNIT_VERSION=~6.5.0
- PHPUNIT_VERSION=~6.4.0
- PHPUNIT_VERSION=~6.3.0
- PHPUNIT_VERSION=~6.2.0
- PHPUNIT_VERSION=~6.1.0
- PHPUNIT_VERSION=~6.0.0

php:
- 7.4snapshot
- 7.3
- 7.2
- 7.1
- 7
- hhvm

matrix:
fast_finish: true
exclude:
- php: 7.1
env: PHPUNIT_VERSION=dev-master
- php: 7.1
env: PHPUNIT_VERSION=~8.2.0
- php: 7.1
env: PHPUNIT_VERSION=~8.1.0
- php: 7.1
env: PHPUNIT_VERSION=~8.0.0
- php: 7
env: PHPUNIT_VERSION=dev-master
- php: 7
env: PHPUNIT_VERSION=~8.2.0
- php: 7
env: PHPUNIT_VERSION=~8.1.0
- php: 7
Expand All @@ -58,7 +63,7 @@ matrix:
- php: 7
env: PHPUNIT_VERSION=~7.0.0
allow_failures:
- php: hhvm
- php: 7.4snapshot
- env: PHPUNIT_VERSION=dev-master

install:
Expand Down
4 changes: 3 additions & 1 deletion autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class_alias(
);
}

if (! interface_exists(\PHPUnit\Framework\MockObject\Invocation::class)) {
if (! interface_exists(\PHPUnit\Framework\MockObject\Invocation::class)
&& interface_exists(\PHPUnit_Framework_MockObject_Invocation::class)
) {
class_alias(
\PHPUnit_Framework_MockObject_Invocation::class,
\PHPUnit\Framework\MockObject\Invocation::class
Expand Down
15 changes: 11 additions & 4 deletions classes/DefaultArgumentRemoverReturnTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ public function invoked(Invocation $invocation)
*/
public function matches(Invocation $invocation) : bool
{
if ($invocation instanceof Invocation\StaticInvocation) {
$this->removeDefaultArguments($invocation);
$iClass = class_exists(Invocation::class);

if ($invocation instanceof Invocation\StaticInvocation
|| $iClass
) {
$this->removeDefaultArguments(
$invocation,
$iClass ? Invocation::class : Invocation\StaticInvocation::class
);
} else {
MockFunctionGenerator::removeDefaultArguments($invocation->parameters);
}
Expand Down Expand Up @@ -64,12 +71,12 @@ public function toString() : string
*
* @SuppressWarnings(PHPMD)
*/
private function removeDefaultArguments(Invocation\StaticInvocation $invocation)
private function removeDefaultArguments(Invocation $invocation, string $class)
{
$remover = function () {
MockFunctionGenerator::removeDefaultArguments($this->parameters);
};

$remover->bindTo($invocation, Invocation\StaticInvocation::class)();
$remover->bindTo($invocation, $class)();
}
}
17 changes: 13 additions & 4 deletions tests/MockObjectProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace phpmock\phpunit;

use PHPUnit\Framework\MockObject\Matcher\MethodName;
use PHPUnit\Framework\MockObject\Stub\MatcherCollection;
use PHPUnit\Framework\TestCase;
use phpmock\integration\MockDelegateFunctionBuilder;
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
use PHPUnit\Framework\MockObject\ConfigurableMethod;
use PHPUnit\Framework\MockObject\Matcher\Invocation;
use PHPUnit\Framework\MockObject\Matcher\MethodName;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub\MatcherCollection;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\Type\Type;

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

$methods = class_exists(ConfigurableMethod::class)
? new ConfigurableMethod(
MockDelegateFunctionBuilder::METHOD,
$this->prophesize(Type::class)->reveal()
)
: [MockDelegateFunctionBuilder::METHOD];

$invocationMocker = new InvocationMocker(
$this->prophesize(MatcherCollection::class)->reveal(),
$this->prophesize(Invocation::class)->reveal(),
[MockDelegateFunctionBuilder::METHOD]
$methods
);

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