Skip to content

Commit

Permalink
fix(tests): Migrate to new method for regex matching
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Apr 10, 2024
1 parent 5402520 commit a6da603
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2929,11 +2929,11 @@ public function userGetsTheFollowingCandidateMentionsInRoomFor($user, $identifie

foreach ($expected as $key => $row) {
if ($row['id'] === 'GUEST_ID') {
Assert::assertRegExp('/^guest\/[0-9a-f]{40}$/', $mentions[$key]['id']);
Assert::assertMatchesRegularExpression('/^guest\/[0-9a-f]{40}$/', $mentions[$key]['id']);
$mentions[$key]['id'] = 'GUEST_ID';
}
if ($row['mentionId'] === 'GUEST_ID') {
Assert::assertRegExp('/^guest\/[0-9a-f]{40}$/', $mentions[$key]['mentionId']);
Assert::assertMatchesRegularExpression('/^guest\/[0-9a-f]{40}$/', $mentions[$key]['mentionId']);
$mentions[$key]['mentionId'] = 'GUEST_ID';
}
if (str_ends_with($row['id'], '@{$BASE_URL}')) {
Expand All @@ -2949,7 +2949,7 @@ public function userGetsTheFollowingCandidateMentionsInRoomFor($user, $identifie
$row['mentionId'] = str_replace('{$REMOTE_URL}', rtrim($this->baseRemoteUrl, '/'), $row['mentionId']);
}
if (array_key_exists('avatar', $row)) {
Assert::assertRegExp('/' . self::$identifierToToken[$row['avatar']] . '\/avatar/', $mentions[$key]['avatar']);
Assert::assertMatchesRegularExpression('/' . self::$identifierToToken[$row['avatar']] . '\/avatar/', $mentions[$key]['avatar']);
unset($row['avatar']);
}
unset($mentions[$key]['avatar']);
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/features/bootstrap/SharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,9 @@ private function assertFieldIsInReturnedShare(string $field, string $contentExpe
} elseif ($contentExpected === 'A_TOKEN') {
// A token is composed by 15 characters from
// ISecureRandom::CHAR_HUMAN_READABLE.
\PHPUnit\Framework\Assert::assertRegExp('/^[abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789]{15}$/', (string)$returnedShare[$field], "Field '$field' is not a token");
\PHPUnit\Framework\Assert::assertMatchesRegularExpression('/^[abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789]{15}$/', (string)$returnedShare[$field], "Field '$field' is not a token");
} elseif (strpos($contentExpected, 'REGEXP ') === 0) {
\PHPUnit\Framework\Assert::assertRegExp(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare[$field], "Field '$field' does not match");
\PHPUnit\Framework\Assert::assertMatchesRegularExpression(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare[$field], "Field '$field' does not match");
} else {
\PHPUnit\Framework\Assert::assertEquals($contentExpected, (string)$returnedShare[$field], "Field '$field' does not match");
}
Expand Down

0 comments on commit a6da603

Please sign in to comment.