Skip to content

Commit 0c8693c

Browse files
committed
Add support for PHPUnit 9
1 parent f4cd488 commit 0c8693c

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ext-sockets": "*",
2121
"friendsofphp/php-cs-fixer": "^2.14",
2222
"monolog/monolog": "^1.24|^2.0",
23-
"phpunit/phpunit": "^7.1|^8",
23+
"phpunit/phpunit": "^7.1|^8|^9",
2424
"psr/log": "^1.1",
2525
"rybakit/msgpack": "^0.7",
2626
"vimeo/psalm": "^3.9"

tests/Integration/Connection/ParseGreetingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testParseGreetingWithInvalidSalt(string $greeting) : void
6363
$client = $clientBuilder->setOptions(['username' => 'guest'])->build();
6464

6565
$this->expectException(\RuntimeException::class);
66-
$this->expectExceptionMessageRegExp('/(Unable to decode salt|Salt is too short)/');
66+
$this->expectExceptionMessageMatches('/(Unable to decode salt|Salt is too short)/');
6767

6868
$client->ping();
6969
}

tests/Integration/TestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
use Tarantool\Client\Exception\CommunicationFailed;
2222
use Tarantool\Client\Handler\Handler;
2323
use Tarantool\Client\Request\Request;
24+
use Tarantool\Client\Tests\PhpUnitCompat;
2425

2526
abstract class TestCase extends BaseTestCase
2627
{
28+
use PhpUnitCompat;
29+
2730
protected const STAT_REQUEST_SELECT = 'SELECT';
2831
protected const STAT_REQUEST_AUTH = 'AUTH';
2932

tests/PhpUnitCompat.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Tarantool Client package.
5+
*
6+
* (c) Eugene Leonovich <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace Tarantool\Client\Tests;
15+
16+
/**
17+
* A compatibility layer for the legacy PHPUnit 7.
18+
*/
19+
trait PhpUnitCompat
20+
{
21+
public function expectExceptionMessageMatches(string $regularExpression) : void
22+
{
23+
if (is_callable('parent::expectExceptionMessageRegExp')) {
24+
parent::expectExceptionMessageRegExp($regularExpression);
25+
26+
return;
27+
}
28+
29+
parent::expectExceptionMessageMatches($regularExpression);
30+
}
31+
}

tests/Unit/Packer/PeclPackerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
use Tarantool\Client\Keys;
1717
use Tarantool\Client\Packer\Packer;
1818
use Tarantool\Client\Packer\PeclPacker;
19+
use Tarantool\Client\Tests\PhpUnitCompat;
1920

2021
/**
2122
* @requires extension msgpack
2223
*/
2324
final class PeclPackerTest extends PackerTest
2425
{
26+
use PhpUnitCompat;
27+
2528
protected function createPacker() : Packer
2629
{
2730
return new PeclPacker();
@@ -33,7 +36,7 @@ protected function createPacker() : Packer
3336
public function testThrowExceptionOnBadUnpackData(string $data) : void
3437
{
3538
$this->expectException(\RuntimeException::class);
36-
$this->expectExceptionMessageRegExp('/Unable to unpack response (header|body)/');
39+
$this->expectExceptionMessageMatches('/Unable to unpack response (header|body)/');
3740

3841
$this->packer->unpack($data)->tryGetBodyField(Keys::DATA);
3942
}

0 commit comments

Comments
 (0)