Skip to content

Commit fc83104

Browse files
committed
- support new version phpunit/php-text-template (^5);
- support new version `phpunit/phpunit` (^12.0); - add attribute for each annotation to support phpunit 12; - use MockBuilder for building mocks instead of removed `getMockForAbstractClass` method
1 parent ec6a00a commit fc83104

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"require": {
2424
"php": ">=5.6",
2525
"php-mock/php-mock": "^2.5",
26-
"phpunit/php-text-template": "^1 || ^2 || ^3 || ^4"
26+
"phpunit/php-text-template": "^1 || ^2 || ^3 || ^4 || ^5"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^5.7.27 || ^6 || ^7 || ^8 || ^9 || ^10 || ^11"
29+
"phpunit/phpunit": "^5.7.27 || ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12"
3030
},
3131
"archive": {
3232
"exclude": ["/tests"]

tests/MockDelegateFunctionBuilderTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public function testSameSignaturesProduceSameClass()
7171
*
7272
* @doesNotPerformAssertions
7373
*/
74+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
75+
#[\PHPUnit\Framework\Attributes\DataProvider('provideTestBackupStaticAttributes')]
76+
#[\PHPUnit\Framework\Attributes\BackupStaticProperties(true)]
7477
public function testBackupStaticAttributes()
7578
{
7679
$builder = new MockDelegateFunctionBuilder();
@@ -97,12 +100,14 @@ public static function provideTestBackupStaticAttributes()
97100
*
98101
* @doesNotPerformAssertions
99102
*/
103+
#[\PHPUnit\Framework\Attributes\RunInSeparateProcess]
104+
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
100105
public function testDeserializationInNewProcess()
101106
{
102107
$builder = new MockDelegateFunctionBuilder();
103108
$builder->build("min");
104109

105-
$data = serialize($this->getMockForAbstractClass($builder->getFullyQualifiedClassName()));
110+
$data = serialize($this->getMockBuilder($builder->getFullyQualifiedClassName())->getMock());
106111

107112
unserialize($data);
108113
}

tests/MockDelegateFunctionTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ protected function setUpCompat()
3535
*
3636
* @test
3737
*/
38+
#[\PHPUnit\Framework\Attributes\Test]
3839
public function testDelegateReturnsMockResult()
3940
{
4041
$expected = 3;
41-
$mock = $this->getMockForAbstractClass($this->className);
42+
$mock = $this->getMockBuilder($this->className)
43+
->onlyMethods([MockDelegateFunctionBuilder::METHOD])
44+
->getMock();
4245

4346
$mock->expects($this->once())
4447
->method(MockDelegateFunctionBuilder::METHOD)
@@ -53,14 +56,17 @@ public function testDelegateReturnsMockResult()
5356
*
5457
* @test
5558
*/
59+
#[\PHPUnit\Framework\Attributes\Test]
5660
public function testDelegateForwardsArguments()
5761
{
58-
$mock = $this->getMockForAbstractClass($this->className);
59-
62+
$mock = $this->getMockBuilder($this->className)
63+
->onlyMethods([MockDelegateFunctionBuilder::METHOD])
64+
->getMock();
65+
6066
$mock->expects($this->once())
6167
->method(MockDelegateFunctionBuilder::METHOD)
6268
->with(1, 2);
63-
69+
6470
call_user_func($mock->getCallable(), 1, 2);
6571
}
6672
}

0 commit comments

Comments
 (0)