Commit 30594448 authored by catch's avatar catch
Browse files

Issue #3217709 by sudiptadas19, mondrake: Replace usages of assertRegExp(), that is deprecated

parent 6511a439
......@@ -47,7 +47,7 @@ public function testAggregatorFeedImport() {
$this->assertNull($feed->getImage());
// As with getLastCheckedTime(), the etag can change as the fixture is
// updated normally, so assert that its format is correct.
$this->assertRegExp('/^"[a-z0-9]{32}"$/', $feed->getEtag());
$this->assertMatchesRegularExpression('/^"[a-z0-9]{32}"$/', $feed->getEtag());
$this->assertSame('0', $feed->getLastModified());
}
......
......@@ -180,7 +180,7 @@ public function test403LogEventPage() {
$message = $table[0]->findAll('xpath', "//tr/th[contains(text(), 'Message')]/../td");
$this->assertCount(1, $message);
$regex = "@Path: .+admin/reports\. Drupal\\\\Core\\\\Http\\\\Exception\\\\CacheableAccessDeniedHttpException: The 'access site reports' permission is required\. in Drupal\\\\Core\\\\Routing\\\\AccessAwareRouter->checkAccess\(\) \(line \d+ of .+/core/lib/Drupal/Core/Routing/AccessAwareRouter\.php\)\.@";
$this->assertRegExp($regex, $message[0]->getText());
$this->assertMatchesRegularExpression($regex, $message[0]->getText());
}
/**
......
......@@ -50,9 +50,9 @@ public function testEntryPoint() {
$optimized_expected_cache_contexts = \Drupal::service('cache_contexts_manager')->optimizeTokens($expected_cache_contexts);
$this->assertSame($optimized_expected_cache_contexts, explode(' ', $response->getHeader('X-Drupal-Cache-Contexts')[0]));
$links = $document['links'];
$this->assertRegExp('/.*\/jsonapi/', $links['self']['href']);
$this->assertRegExp('/.*\/jsonapi\/user\/user/', $links['user--user']['href']);
$this->assertRegExp('/.*\/jsonapi\/node_type\/node_type/', $links['node_type--node_type']['href']);
$this->assertMatchesRegularExpression('/.*\/jsonapi/', $links['self']['href']);
$this->assertMatchesRegularExpression('/.*\/jsonapi\/user\/user/', $links['user--user']['href']);
$this->assertMatchesRegularExpression('/.*\/jsonapi\/node_type\/node_type/', $links['node_type--node_type']['href']);
$this->assertArrayNotHasKey('meta', $document);
// A `me` link must be present for authenticated users.
......
......@@ -196,7 +196,7 @@ public function testRead() {
$this->assertCount(1, $non_help_links);
$link_keys = array_keys($single_output['meta']['omitted']['links']);
$this->assertSame('help', reset($link_keys));
$this->assertRegExp('/^item--[a-zA-Z0-9]{7}$/', next($link_keys));
$this->assertMatchesRegularExpression('/^item--[a-zA-Z0-9]{7}$/', next($link_keys));
$this->nodes[1]->set('status', TRUE);
$this->nodes[1]->save();
// 13. Test filtering when using short syntax.
......
......@@ -130,7 +130,7 @@ public function testRequiredFields() {
$this->assertTrue(isset($errors[$element]), "Check empty($key) '$type' field '$element'");
if (!empty($form_output)) {
// Make sure the form element is marked as required.
$this->assertRegExp($required_marker_preg, (string) $form_output, "Required '$type' field is marked as required");
$this->assertMatchesRegularExpression($required_marker_preg, (string) $form_output, "Required '$type' field is marked as required");
}
}
else {
......
......@@ -52,7 +52,7 @@ public function testAliasToEncoded() {
foreach ($route_paths as $route_name => $path) {
// The alias may be only a suffix of the generated path when the test is
// run with Drupal installed in a subdirectory.
$this->assertRegExp('@/' . rawurlencode($aliases[$route_name]) . '$@', Url::fromRoute($route_name)->toString());
$this->assertMatchesRegularExpression('@/' . rawurlencode($aliases[$route_name]) . '$@', Url::fromRoute($route_name)->toString());
$this->drupalGet(Url::fromRoute($route_name));
$this->assertSession()->pageTextContains('PathEncodedTestController works');
}
......
......@@ -732,7 +732,7 @@ protected function assertPattern($pattern, $message = '', $group = 'Other') {
if (!$message) {
$message = new FormattableMarkup('Pattern "@pattern" found', ['@pattern' => $pattern]);
}
$this->assertRegExp($pattern, $this->getRawContent(), $message);
$this->assertMatchesRegularExpression($pattern, $this->getRawContent(), $message);
return TRUE;
}
......@@ -783,7 +783,7 @@ protected function assertTextPattern($pattern, $message = NULL, $group = 'Other'
if (!isset($message)) {
$message = new FormattableMarkup('Pattern "@pattern" found', ['@pattern' => $pattern]);
}
$this->assertRegExp($pattern, $this->getTextContent(), $message);
$this->assertMatchesRegularExpression($pattern, $this->getTextContent(), $message);
return TRUE;
}
......
......@@ -161,18 +161,18 @@ public function testDbDumpCommand() {
// Table data is exported.
$pattern = preg_quote("\$connection->insert('config')");
$this->assertRegExp('/' . $pattern . '/', $command_tester->getDisplay(), 'Table data is properly exported to the script.');
$this->assertMatchesRegularExpression('/' . $pattern . '/', $command_tester->getDisplay(), 'Table data is properly exported to the script.');
// The test data are in the dump (serialized).
$pattern = preg_quote(serialize($this->data));
$this->assertRegExp('/' . $pattern . '/', $command_tester->getDisplay(), 'Generated data is found in the exported script.');
$this->assertMatchesRegularExpression('/' . $pattern . '/', $command_tester->getDisplay(), 'Generated data is found in the exported script.');
// Check that the user account name and email address was properly escaped.
// cspell:disable-next-line
$pattern = preg_quote('"q\'uote\$dollar@example.com"');
$this->assertRegExp('/' . $pattern . '/', $command_tester->getDisplay(), 'The user account email address was properly escaped in the exported script.');
$this->assertMatchesRegularExpression('/' . $pattern . '/', $command_tester->getDisplay(), 'The user account email address was properly escaped in the exported script.');
$pattern = preg_quote('\'$dollar\'');
$this->assertRegExp('/' . $pattern . '/', $command_tester->getDisplay(), 'The user account name was properly escaped in the exported script.');
$this->assertMatchesRegularExpression('/' . $pattern . '/', $command_tester->getDisplay(), 'The user account name was properly escaped in the exported script.');
}
/**
......
......@@ -113,7 +113,7 @@ public function testSiteUuidValidate() {
$expected = static::FAIL_MESSAGE . PHP_EOL . 'Site UUID in source storage does not match the target storage.';
$this->assertEquals($expected, $actual_message);
foreach ($expected_error_log as $log_row) {
$this->assertRegExp("/$log_row/", $actual_message);
$this->assertMatchesRegularExpression("/$log_row/", $actual_message);
}
}
}
......
......@@ -139,7 +139,7 @@ public function testAggregation() {
// We need to check that a character exists before and after the table,
// column and alias identifiers. These would be the quote characters
// specific for each database system.
$this->assertRegExp('/' . $aggregation_function . '\(.entity_test.\..id.\) AS .id_' . $aggregation_function . './', (string) $query, 'The argument to the aggregation function should be a quoted field.');
$this->assertMatchesRegularExpression('/' . $aggregation_function . '\(.entity_test.\..id.\) AS .id_' . $aggregation_function . './', (string) $query, 'The argument to the aggregation function should be a quoted field.');
$this->assertEquals($expected, $this->queryResult);
}
......
......@@ -360,7 +360,7 @@ public function testLoadByProperties() {
$this->fail($message);
}
catch (\InvalidArgumentException $e) {
$this->assertRegExp('/^An invalid property name, .+ was specified. Allowed property names are:/', $e->getMessage(), 'Found expected exception message.');
$this->assertMatchesRegularExpression('/^An invalid property name, .+ was specified. Allowed property names are:/', $e->getMessage(), 'Found expected exception message.');
}
}
$this->addMenuLink('test_link.1', '', 'test', [], 'menu1');
......
......@@ -32,7 +32,7 @@ public function testSetUpBeforeClass() {
* @covers ::bootEnvironment
*/
public function testBootEnvironment() {
$this->assertRegExp('/^test\d{8}$/', $this->databasePrefix);
$this->assertMatchesRegularExpression('/^test\d{8}$/', $this->databasePrefix);
$this->assertStringStartsWith('vfs://root/sites/simpletest/', $this->siteDirectory);
$this->assertEquals([
'root' => [
......@@ -226,8 +226,8 @@ public function testRenderWithTheme() {
$output = \Drupal::service('renderer')->renderRoot($build);
$this->assertEquals('core', \Drupal::theme()->getActiveTheme()->getName());
$this->assertRegExp($expected, (string) $build['#children']);
$this->assertRegExp($expected, (string) $output);
$this->assertMatchesRegularExpression($expected, (string) $build['#children']);
$this->assertMatchesRegularExpression($expected, (string) $output);
}
/**
......
......@@ -21,7 +21,7 @@ public function testEnsureComposerVersion() {
$this->assertNull(Composer::ensureComposerVersion());
}
catch (\RuntimeException $e) {
$this->assertRegExp('/Drupal core development requires Composer 1.9.0, but Composer /', $e->getMessage());
$this->assertMatchesRegularExpression('/Drupal core development requires Composer 1.9.0, but Composer /', $e->getMessage());
}
}
......
......@@ -55,7 +55,7 @@ public function testGetLockId() {
$lock_id = $this->lock->getLockId();
$this->assertIsString($lock_id);
// Example lock ID would be '7213141505232b6ee2cb967.27683891'.
$this->assertRegExp('/[\da-f]+\.\d+/', $lock_id);
$this->assertMatchesRegularExpression('/[\da-f]+\.\d+/', $lock_id);
// Test the same lock ID is returned a second time.
$this->assertSame($lock_id, $this->lock->getLockId());
}
......
......@@ -78,7 +78,7 @@ public function testToString() {
restore_error_handler();
$this->assertEquals(E_USER_ERROR, $this->lastErrorNumber);
$this->assertRegExp('/Exception thrown while calling __toString on a .*Mock_TranslatableMarkup_.* object in .*TranslatableMarkupTest.php on line [0-9]+: Yes you may./', $this->lastErrorMessage);
$this->assertMatchesRegularExpression('/Exception thrown while calling __toString on a .*Mock_TranslatableMarkup_.* object in .*TranslatableMarkupTest.php on line [0-9]+: Yes you may./', $this->lastErrorMessage);
}
/**
......
......@@ -71,7 +71,7 @@ function ($unescaped_test_classnames, $phpunit_file, &$status) {
*/
public function testPhpUnitCommand() {
$runner = new PhpUnitTestRunner($this->root, sys_get_temp_dir());
$this->assertRegExp('/phpunit/', $runner->phpUnitCommand());
$this->assertMatchesRegularExpression('/phpunit/', $runner->phpUnitCommand());
}
/**
......
......@@ -152,7 +152,7 @@ public function testInstallScript() {
$this->assertStringContainsString('Successfully installed a test site', $process->getOutput());
$this->assertSame(0, $process->getExitCode());
$regex = '/Database prefix\s+([^\s]*)/';
$this->assertRegExp($regex, $process->getOutput());
$this->assertMatchesRegularExpression($regex, $process->getOutput());
preg_match('/Database prefix\s+([^\s]*)/', $process->getOutput(), $matches);
$other_db_prefix = $matches[1];
$other_key = $this->addTestDatabase($other_db_prefix);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment