Skip to content

Commit 30cff35

Browse files
committed
Fix test run with PHPUnit 11.2.4
The patch replaces `assertRegExp` with `assertMatchesRegularExpression` because the first one is outdated. Closes #157
1 parent 52d3e1f commit 30cff35

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

test/DMLTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public function test_16_hash_select() {
361361
self::$tarantool->select("test_hash", null, null, null, null, TARANTOOL::ITERATOR_EQ);
362362
$this->assertFalse(True);
363363
} catch (TarantoolClientError $e) {
364-
$this->assertRegExp('(Invalid key part|via a partial key)', $e->getMessage());
364+
$this->assertMatchesRegularExpression('(Invalid key part|via a partial key)', $e->getMessage());
365365
}
366366
}
367367

@@ -373,7 +373,7 @@ public function test_17_01_it_clienterror($spc, $itype, $xcmsg) {
373373
self::$tarantool->select($spc, null, null, null, null, $itype);
374374
$this->assertFalse(True);
375375
} catch (TarantoolClientError $e) {
376-
$this->assertRegExp($xcmsg, $e->getMessage());
376+
$this->assertMatchesRegularExpression($xcmsg, $e->getMessage());
377377
}
378378
}
379379

test/PhpUnitCompat.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,28 @@ public function expectExceptionMessageMatches($regularExpression) {
230230
}
231231
}
232232

233+
/*
234+
* AssertMatchesRegularExpressionTrait (private).
235+
*
236+
* phpunit-8 provides the new name for
237+
* assertRegExp() method:
238+
* assertMatchesRegularExpression(). phpunit-10 removes the old name.
239+
*
240+
* This trait adds assertMatchesRegularExpression() method for
241+
* phpunit-6, phpunit-7, phpunit-8 and phpunit-9.
242+
*/
243+
if ($testCaseRef->hasMethod('assertMatchesRegularExpression')) {
244+
trait AssertMatchesRegularExpressionTrait {
245+
/* Nothing to define. */
246+
}
247+
} else {
248+
trait AssertMatchesRegularExpressionTrait {
249+
public function assertMatchesRegularExpression($pattern, $string, $message = '') {
250+
self::assertRegExp($pattern, $string, $message);
251+
}
252+
}
253+
}
254+
233255
/*
234256
* TestCaseCompat (public).
235257
*
@@ -240,4 +262,5 @@ trait TestCaseCompat
240262
use SetUpTearDownTrait;
241263
use AssertStringContainsStringTrait;
242264
use ExpectExceptionMessageMatchesTrait;
265+
use AssertMatchesRegularExpressionTrait;
243266
}

0 commit comments

Comments
 (0)