mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
PRovide upgrade path for assertRegExp
This commit is contained in:
parent
3a1fcaac39
commit
4642b9fd1c
2 changed files with 10 additions and 2 deletions
|
@ -43,7 +43,7 @@ class TestToken extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
$this->assertSame("RANDOM TOKEN", $this->prepTest()->tokenGenerate("ook", "Eek"));
|
$this->assertSame("RANDOM TOKEN", $this->prepTest()->tokenGenerate("ook", "Eek"));
|
||||||
$this->dbMock->tokenCreate->calledWith("ook", "miniflux.login", "~", null, "Eek");
|
$this->dbMock->tokenCreate->calledWith("ook", "miniflux.login", "~", null, "Eek");
|
||||||
$token = $this->dbMock->tokenCreate->firstCall()->argument(2);
|
$token = $this->dbMock->tokenCreate->firstCall()->argument(2);
|
||||||
$this->assertRegExp("/^[A-Za-z0-9_\-]{43}=$/", $token);
|
$this->assertMatchesRegularExpression("/^[A-Za-z0-9_\-]{43}=$/", $token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testListTheTokensOfAUser(): void {
|
public function testListTheTokensOfAUser(): void {
|
||||||
|
|
|
@ -141,6 +141,14 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
||||||
return $req;
|
return $req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void {
|
||||||
|
if (method_exists(parent::class, "assertMatchesRegularExpression")) {
|
||||||
|
parent::assertMatchesRegularExpression($pattern, $string, $message);
|
||||||
|
} else {
|
||||||
|
parent::assertRegExp($pattern, $string, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function assertException($msg = "", string $prefix = "", string $type = "Exception"): void {
|
public function assertException($msg = "", string $prefix = "", string $type = "Exception"): void {
|
||||||
if (func_num_args()) {
|
if (func_num_args()) {
|
||||||
if ($msg instanceof \JKingWeb\Arsse\AbstractException) {
|
if ($msg instanceof \JKingWeb\Arsse\AbstractException) {
|
||||||
|
@ -334,7 +342,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
||||||
}
|
}
|
||||||
// compare the result set to the expectations
|
// compare the result set to the expectations
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$this->assertContains($row, $expected, "Result set contains unexpected record.");
|
$this->assertEquals($row, $expected, "Result set contains unexpected record.");
|
||||||
$found = array_search($row, $expected);
|
$found = array_search($row, $expected);
|
||||||
unset($expected[$found]);
|
unset($expected[$found]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue