Skip to content

Commit ecf48b3

Browse files
authored
Merge pull request #30 from bigcommerce/support-phpunit-95
PHPMNT-100 Support PHPUnit 9.5 or 10
2 parents fea2432 + 4198b42 commit ecf48b3

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php": "^8.1",
2626
"bigcommerce/injector": "^4.1",
2727
"phpspec/prophecy-phpunit": "^2.0",
28-
"phpunit/phpunit": " ^10.0"
28+
"phpunit/phpunit": "^9.5 || ^10.0"
2929
},
3030
"require-dev": {
3131
"phpstan/phpstan": "^1.10"

tests/AutoMockingTestTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public function testTestShouldNotBeRiskyWhenItHasProphecyExpectations(): void
1515

1616
$riskyTest->runBare();
1717

18-
$this->assertSame(1, $riskyTest->numberOfAssertionsPerformed());
18+
$this->assertFalse($riskyTest->isRisky());
19+
1920
}
2021

2122
public function testTestShouldBeRiskyWhenItHasNoAssertions(): void
@@ -24,6 +25,6 @@ public function testTestShouldBeRiskyWhenItHasNoAssertions(): void
2425

2526
$riskyTest->runBare();
2627

27-
$this->assertSame(0, $riskyTest->numberOfAssertionsPerformed());
28+
$this->assertTrue($riskyTest->isRisky());
2829
}
2930
}

tests/Dummy/DummyTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
namespace Tests\Dummy;
55

6+
use BadMethodCallException;
67
use Bigcommerce\MockInjector\AutoMockingTest;
8+
use Exception;
79
use Prophecy\Prophecy\ObjectProphecy;
810

911
/**
@@ -33,4 +35,17 @@ public function testWithProphecyExpectations() : void
3335
public function testWithoutAssertions() : void
3436
{
3537
}
38+
39+
public function isRisky(): bool
40+
{
41+
if (is_callable([$this, 'numberOfAssertionsPerformed'])) {
42+
return $this->numberOfAssertionsPerformed() === 0;
43+
}
44+
45+
if (is_callable([$this, 'getNumAssertions'])) {
46+
return $this->getNumAssertions() === 0;
47+
}
48+
49+
throw new BadMethodCallException("Could not check the number of assertions performed");
50+
}
3651
}

0 commit comments

Comments
 (0)