Unverified Commit e89ebbda authored by alexpott's avatar alexpott

Issue #3113077 by mondrake, Hardik_Patel_12, Neslee Canil Pinto,...

Issue #3113077 by mondrake, Hardik_Patel_12, Neslee Canil Pinto, swatichouhan012, prabha1997, neelam_wadhwani, Berdir, longwave: Replace assertContains() on strings with assertStringContainsString() or assertStringContainsStringIgnoringCase()

(cherry picked from commit 6108526c)
parent 81b4b3a9
......@@ -65,25 +65,25 @@ public function testStringFormatter() {
$build = $aggregator_feed->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => TRUE]]);
$result = $this->render($build);
$this->assertContains('testing title', $result);
$this->assertContains('href="' . $aggregator_feed->getUrl() . '"', $result);
$this->assertStringContainsString('testing title', $result);
$this->assertStringContainsString('href="' . $aggregator_feed->getUrl() . '"', $result);
$build = $aggregator_feed->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => FALSE]]);
$result = $this->render($build);
$this->assertContains('testing title', $result);
$this->assertNotContains($aggregator_feed->getUrl(), $result);
$this->assertStringContainsString('testing title', $result);
$this->assertStringNotContainsString($aggregator_feed->getUrl(), $result);
// Verify aggregator item title with and without links.
$build = $aggregator_item->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => TRUE]]);
$result = $this->render($build);
$this->assertContains('test title', $result);
$this->assertContains('href="' . $aggregator_item->getLink() . '"', $result);
$this->assertStringContainsString('test title', $result);
$this->assertStringContainsString('href="' . $aggregator_item->getLink() . '"', $result);
$build = $aggregator_item->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => FALSE]]);
$result = $this->render($build);
$this->assertContains('test title', $result);
$this->assertNotContains($aggregator_item->getLink(), $result);
$this->assertStringContainsString('test title', $result);
$this->assertStringNotContainsString($aggregator_item->getLink(), $result);
}
}
......@@ -81,7 +81,7 @@ public function testCommentPopulatedTitles() {
$comment_permalink = $this->cssSelect('.permalink');
$comment_permalink = $comment_permalink[0]->getAttribute('href');
// Tests that the comment's title link contains the url fragment.
$this->assertContains('#comment-' . $comment1->id(), $comment_permalink, "The comment's title link contains the url fragment.");
$this->assertStringContainsString('#comment-' . $comment1->id(), $comment_permalink, "The comment's title link contains the url fragment.");
$this->assertEqual($comment1->permalink()->toString(), $comment_permalink, "The comment's title has the correct link.");
}
......
......@@ -86,8 +86,8 @@ protected function copyTestingOverrides() {
*/
public function testInstalled() {
if ($this->expectedException) {
$this->assertContains('Configuration objects provided by <em class="placeholder">testing_config_overrides</em> have unmet dependencies: <em class="placeholder">system.action.user_block_user_action (does_not_exist)</em>', $this->expectedException->getMessage());
$this->assertContains('Drupal\Core\Config\UnmetDependenciesException', $this->expectedException->getMessage());
$this->assertStringContainsString('Configuration objects provided by <em class="placeholder">testing_config_overrides</em> have unmet dependencies: <em class="placeholder">system.action.user_block_user_action (does_not_exist)</em>', $this->expectedException->getMessage());
$this->assertStringContainsString('Drupal\Core\Config\UnmetDependenciesException', $this->expectedException->getMessage());
}
else {
$this->fail('Expected Drupal\Core\Config\UnmetDependenciesException exception not thrown');
......
......@@ -329,8 +329,8 @@ public function testSiteWideContact() {
$mails = $this->getMails();
$mail = array_pop($mails);
$this->assertEqual($mail['subject'], t('[@label] @subject', ['@label' => $label, '@subject' => $edit['subject[0][value]']]));
$this->assertContains($field_label, $mail['body']);
$this->assertContains($edit[$field_name . '[0][value]'], $mail['body']);
$this->assertStringContainsString($field_label, $mail['body']);
$this->assertStringContainsString($edit[$field_name . '[0][value]'], $mail['body']);
// Test messages and redirect.
/** @var \Drupal\contact\ContactFormInterface $form */
......
......@@ -71,7 +71,7 @@ public function testContentTranslationContextualLinks() {
$this->drupalLogin($this->translator);
$this->drupalGet('node/' . $node->id());
$link = $this->assertSession()->waitForElement('css', '[data-contextual-id^="node:node=1"] .contextual-links a:contains("Translate")');
$this->assertContains('node/1/translations', $link->getAttribute('href'));
$this->assertStringContainsString('node/1/translations', $link->getAttribute('href'));
}
}
......@@ -97,7 +97,7 @@ public function testDifferentPermissions() {
}
$response = $this->renderContextualLinks([], 'node');
$this->assertSame(400, $response->getStatusCode());
$this->assertContains('No contextual ids specified.', (string) $response->getBody());
$this->assertStringContainsString('No contextual ids specified.', (string) $response->getBody());
$response = $this->renderContextualLinks($ids, 'node');
$this->assertSame(200, $response->getStatusCode());
$json = Json::decode((string) $response->getBody());
......@@ -120,7 +120,7 @@ public function testDifferentPermissions() {
}
$response = $this->renderContextualLinks([], 'node');
$this->assertSame(400, $response->getStatusCode());
$this->assertContains('No contextual ids specified.', (string) $response->getBody());
$this->assertStringContainsString('No contextual ids specified.', (string) $response->getBody());
$response = $this->renderContextualLinks($ids, 'node');
$this->assertSame(200, $response->getStatusCode());
$json = Json::decode((string) $response->getBody());
......@@ -177,7 +177,7 @@ public function testTokenProtection() {
'http_errors' => FALSE,
]);
$this->assertEquals('400', $response->getStatusCode());
$this->assertContains('No contextual ID tokens specified.', (string) $response->getBody());
$this->assertStringContainsString('No contextual ID tokens specified.', (string) $response->getBody());
$response = $http_client->request('POST', $url, [
'cookies' => $this->getSessionCookies(),
......@@ -185,7 +185,7 @@ public function testTokenProtection() {
'http_errors' => FALSE,
]);
$this->assertEquals('400', $response->getStatusCode());
$this->assertContains('Invalid contextual ID specified.', (string) $response->getBody());
$this->assertStringContainsString('Invalid contextual ID specified.', (string) $response->getBody());
$response = $http_client->request('POST', $url, [
'cookies' => $this->getSessionCookies(),
......@@ -193,7 +193,7 @@ public function testTokenProtection() {
'http_errors' => FALSE,
]);
$this->assertEquals('400', $response->getStatusCode());
$this->assertContains('Invalid contextual ID specified.', (string) $response->getBody());
$this->assertStringContainsString('Invalid contextual ID specified.', (string) $response->getBody());
$response = $http_client->request('POST', $url, [
'cookies' => $this->getSessionCookies(),
......
......@@ -127,7 +127,7 @@ public function testDateField() {
$expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE);
$output = $this->renderTestEntity($id);
$expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>';
$this->assertContains($expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.', [
$this->assertStringContainsString($expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.', [
'%value' => $new_value,
'%expected' => $expected,
'%expected_iso' => $expected_iso,
......@@ -147,7 +147,7 @@ public function testDateField() {
->save();
$expected = $date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected in %timezone.', [
$this->assertStringContainsString($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected in %timezone.', [
'%expected' => $expected,
'%timezone' => $timezone,
]));
......@@ -161,7 +161,7 @@ public function testDateField() {
->save();
$expected = $date->format($this->displayOptions['settings']['date_format']);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using datetime_custom format displayed as %expected in %timezone.', [
$this->assertStringContainsString($expected, $output, new FormattableMarkup('Formatted date field using datetime_custom format displayed as %expected in %timezone.', [
'%expected' => $expected,
'%timezone' => $timezone,
]));
......@@ -174,7 +174,7 @@ public function testDateField() {
->save();
$expected = '<strong>' . $date->format('m/d/Y') . '</strong>alert(String.fromCharCode(88,83,83))';
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected in %timezone.', [
$this->assertStringContainsString($expected, $output, new FormattableMarkup('Formatted date field using daterange_custom format displayed as %expected in %timezone.', [
'%expected' => $expected,
'%timezone' => $timezone,
]));
......@@ -204,7 +204,7 @@ public function testDateField() {
'@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
]);
$output = $this->renderTestEntity($id);
$this->assertContains((string) $expected, $output, new FormattableMarkup('Formatted date field using datetime_time_ago format displayed as %expected in %timezone.', [
$this->assertStringContainsString((string) $expected, $output, new FormattableMarkup('Formatted date field using datetime_time_ago format displayed as %expected in %timezone.', [
'%expected' => $expected,
'%timezone' => $timezone,
]));
......@@ -228,7 +228,7 @@ public function testDateField() {
'@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
]);
$output = $this->renderTestEntity($id);
$this->assertContains((string) $expected, $output, new FormattableMarkup('Formatted date field using datetime_time_ago format displayed as %expected in %timezone.', [
$this->assertStringContainsString((string) $expected, $output, new FormattableMarkup('Formatted date field using datetime_time_ago format displayed as %expected in %timezone.', [
'%expected' => $expected,
'%timezone' => $timezone,
]));
......@@ -299,7 +299,7 @@ public function testDatetimeField() {
$expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC');
$output = $this->renderTestEntity($id);
$expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>';
$this->assertContains($expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso]));
$this->assertStringContainsString($expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso]));
break;
}
}
......@@ -314,7 +314,7 @@ public function testDatetimeField() {
->save();
$expected = $date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
$this->assertStringContainsString($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_custom' formatter works.
$this->displayOptions['type'] = 'datetime_custom';
......@@ -324,7 +324,7 @@ public function testDatetimeField() {
->save();
$expected = $date->format($this->displayOptions['settings']['date_format']);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected]));
$this->assertStringContainsString($expected, $output, new FormattableMarkup('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'timezone_override' setting works.
$this->displayOptions['type'] = 'datetime_custom';
......@@ -334,7 +334,7 @@ public function testDatetimeField() {
->save();
$expected = $date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected]));
$this->assertStringContainsString($expected, $output, new FormattableMarkup('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_time_ago' formatter works for intervals in the
// past. First update the test entity so that the date difference always
......@@ -361,7 +361,7 @@ public function testDatetimeField() {
'@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
]);
$output = $this->renderTestEntity($id);
$this->assertContains((string) $expected, $output, new FormattableMarkup('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected]));
$this->assertStringContainsString((string) $expected, $output, new FormattableMarkup('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected]));
// Verify that the 'datetime_time_ago' formatter works for intervals in the
// future. First update the test entity so that the date difference always
......@@ -383,7 +383,7 @@ public function testDatetimeField() {
'@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
]);
$output = $this->renderTestEntity($id);
$this->assertContains((string) $expected, $output, new FormattableMarkup('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected]));
$this->assertStringContainsString((string) $expected, $output, new FormattableMarkup('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected]));
}
/**
......
......@@ -107,7 +107,7 @@ public function testSeparatorTranslation() {
$build = $display->build($entity);
$output = $this->container->get('renderer')->renderRoot($build);
$this->verbose($output);
$this->assertContains('UNTRANSLATED', (string) $output);
$this->assertStringContainsString('UNTRANSLATED', (string) $output);
// Translate the separator.
ConfigurableLanguage::createFromLangcode('nl')->save();
......@@ -124,7 +124,7 @@ public function testSeparatorTranslation() {
$build = $display->build($entity);
$output = $this->container->get('renderer')->renderRoot($build);
$this->verbose($output);
$this->assertContains('NL_TRANSLATED!', (string) $output);
$this->assertStringContainsString('NL_TRANSLATED!', (string) $output);
}
}
......@@ -108,7 +108,7 @@ public function testEmailField() {
$display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$rendered_content = (string) \Drupal::service('renderer')->renderRoot($content);
$this->assertContains('href="mailto:test@example.com"', $rendered_content);
$this->assertStringContainsString('href="mailto:test@example.com"', $rendered_content);
}
}
......@@ -105,7 +105,7 @@ public function _testTextfieldWidgets($field_type, $widget_type) {
$display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$rendered_entity = \Drupal::service('renderer')->renderRoot($content);
$this->assertContains($value, (string) $rendered_entity);
$this->assertStringContainsString($value, (string) $rendered_entity);
}
}
......@@ -43,7 +43,7 @@ public function testUuidStringFormatter() {
// Verify default render.
$render_array = $uuid_field->view([]);
$this->assertIdentical($render_array[0]['#context']['value'], $entity->uuid(), 'The rendered UUID matches the entity UUID.');
$this->assertContains($entity->uuid(), $this->render($render_array), 'The rendered UUID found.');
$this->assertStringContainsString($entity->uuid(), $this->render($render_array), 'The rendered UUID found.');
// Verify customized render.
$render_array = $uuid_field->view(['settings' => ['link_to_entity' => TRUE]]);
......@@ -51,8 +51,8 @@ public function testUuidStringFormatter() {
$this->assertIdentical($render_array[0]['#title']['#context']['value'], $entity->uuid());
$this->assertIdentical($render_array[0]['#url']->toString(), $entity->toUrl()->toString());
$rendered = $this->render($render_array);
$this->assertContains($entity->uuid(), $rendered, 'The rendered UUID found.');
$this->assertContains($entity->toUrl()->toString(), $rendered, 'The rendered entity URL found.');
$this->assertStringContainsString($entity->uuid(), $rendered, 'The rendered UUID found.');
$this->assertStringContainsString($entity->toUrl()->toString(), $rendered, 'The rendered entity URL found.');
}
}
......@@ -254,9 +254,12 @@ public function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $tex
$output = (string) \Drupal::service('renderer')->renderRoot($element);
$this->verbose(t('Rendered node - view mode: @view_mode', ['@view_mode' => $view_mode]) . '<hr />' . $output);
$method = $not_exists ? 'assertNotContains' : 'assertContains';
$this->{$method}((string) $text, $output, $message);
if ($not_exists) {
$this->assertStringNotContainsString((string) $text, $output, $message);
}
else {
$this->assertStringContainsString((string) $text, $output, $message);
}
}
/**
......
......@@ -143,7 +143,7 @@ public function testFormatterUI() {
$field_test_format_type->setValue('field_test_multiple');
$assert_session->assertWaitOnAjaxRequest();
$plugin_summary = $page->find('css', '#field-test .field-plugin-summary');
$this->assertContains("test_formatter_setting_multiple: dummy test string", $plugin_summary->getText(), 'The expected summary is displayed.');
$this->assertStringContainsString("test_formatter_setting_multiple: dummy test string", $plugin_summary->getText(), 'The expected summary is displayed.');
// Submit the form and assert that
// hook_field_formatter_settings_summary_alter() is called.
......
......@@ -422,7 +422,7 @@ public function testWidgetElement() {
]);
$this->assertNotEquals(500, $post_request->getStatusCode());
$body = Json::decode($post_request->getBody());
$this->assertContains('Starting upload...', $body['message']);
$this->assertStringContainsString('Starting upload...', $body['message']);
}
/**
......
......@@ -55,10 +55,10 @@ public function testMultipleFileFieldWithAllFileExtensions() {
$client->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $edit);
$page = $this->getSession()->getPage();
$this->assertNotContains('Only files with the following extensions are allowed', $page->getContent());
$this->assertContains('The configuration options have been saved.', $page->getContent());
$this->assertContains('file1.wtf', $page->getContent());
$this->assertContains('file2.wtf', $page->getContent());
$this->assertStringNotContainsString('Only files with the following extensions are allowed', $page->getContent());
$this->assertStringContainsString('The configuration options have been saved.', $page->getContent());
$this->assertStringContainsString('file1.wtf', $page->getContent());
$this->assertStringContainsString('file2.wtf', $page->getContent());
}
}
......@@ -462,8 +462,8 @@ public function testInvalidUtf8FilenameUpload() {
$content = (string) $response->getBody();
$this->htmlOutput($content);
$error_text = new FormattableMarkup('The file %filename could not be uploaded because the name is invalid.', ['%filename' => $filename]);
$this->assertContains((string) $error_text, $content);
$this->assertContains('Epic upload FAIL!', $content);
$this->assertStringContainsString((string) $error_text, $content);
$this->assertStringContainsString('Epic upload FAIL!', $content);
$this->assertFileNotExists('temporary://' . $filename);
}
......
......@@ -55,8 +55,8 @@ public function testCaptionFilter() {
$input = '<img src="llama.jpg" data-caption="Loquacious llama!" />';
$expected = '<img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption>';
$output = $test($input)->getProcessedText();
$this->assertContains($expected, $output);
$this->assertContains("<!-- THEME HOOK: 'filter_caption' -->", $output);
$this->assertStringContainsString($expected, $output);
$this->assertStringContainsString("<!-- THEME HOOK: 'filter_caption' -->", $output);
}
}
......@@ -209,7 +209,7 @@ public function testForum() {
$this->assertStringStartsWith('6 new posts', $elements[0]->getText(), 'Number of unread topics found.');
// Verify that the forum name is in the unread topics text.
$elements = $this->xpath('//tr[@id=:forum]//em[@class="placeholder"]', $forum_arg);
$this->assertContains($this->forum['name'], $elements[0]->getText(), 'Forum name found in unread topics text.');
$this->assertStringContainsString($this->forum['name'], $elements[0]->getText(), 'Forum name found in unread topics text.');
// Verify total number of posts in forum.
$elements = $this->xpath('//tr[@id=:forum]//td[@class="forum__posts"]', $forum_arg);
......
......@@ -189,7 +189,7 @@ protected function verifyHelpLinks() {
// Verify theme provided help topics work and can be related.
$this->drupalGet('admin/help/topic/help_topics_test_theme.test');
$session->pageTextContains('This is a theme provided topic.');
$this->assertContains('This is a theme provided topic.', $session->elementExists('css', 'article')->getText());
$this->assertStringContainsString('This is a theme provided topic.', $session->elementExists('css', 'article')->getText());
$this->clickLink('Additional topic');
$session->linkExists('XYZ Help Test theme');
......
......@@ -192,31 +192,31 @@ protected function verifyBadTopic($id, $definitions) {
$message = $e->getMessage();
switch ($bad_topic_type) {
case 'related':
$this->assertContains('only related to topics that exist', $message);
$this->assertStringContainsString('only related to topics that exist', $message);
break;
case 'bad_html':
$this->assertContains('Unexpected end tag', $message);
$this->assertStringContainsString('Unexpected end tag', $message);
break;
case 'top_level':
$this->assertContains('is either top-level or related to at least one other top-level topic', $message);
$this->assertStringContainsString('is either top-level or related to at least one other top-level topic', $message);
break;
case 'empty':
$this->assertContains('contains some text outside of front matter', $message);
$this->assertStringContainsString('contains some text outside of front matter', $message);
break;
case 'translated':
$this->assertContains('Twig file has all of its text translated', $message);
$this->assertStringContainsString('Twig file has all of its text translated', $message);
break;
case 'h1':
$this->assertContains('has no H1 tag', $message);
$this->assertStringContainsString('has no H1 tag', $message);
break;
case 'hierarchy':
$this->assertContains('has the correct H2-H6 heading hierarchy', $message);
$this->assertStringContainsString('has the correct H2-H6 heading hierarchy', $message);
break;
default:
......
......@@ -135,7 +135,7 @@ public function testValidImageUpload() {
$this->drupalLogin($this->contentAuthorUser);
$this->uploadImage($valid_image, $node->id(), $this->fieldName, $node->language()->getId());
$this->assertContains('"fid":"1"', $this->getSession()->getPage()->getContent(), 'Valid upload completed successfully.');
$this->assertStringContainsString('"fid":"1"', $this->getSession()->getPage()->getContent(), 'Valid upload completed successfully.');
}
/**
......@@ -164,7 +164,7 @@ public function testInvalidUpload() {
$this->drupalLogin($this->contentAuthorUser);
$this->uploadImage($invalid_image, $node->id(), $this->fieldName, $node->language()->getId());
$this->assertContains('"main_error":"The image failed validation."', $this->getSession()->getPage()->getContent(), 'Invalid upload returned errors.');
$this->assertStringContainsString('"main_error":"The image failed validation."', $this->getSession()->getPage()->getContent(), 'Invalid upload returned errors.');
}
/**
......
......@@ -196,7 +196,7 @@ public function testImageFormatterUrlOptions() {
$renderer = $this->container->get('renderer');
$output = $renderer->renderRoot($build[$this->fieldName][0]);
$this->assertContains('<a href="' . $entity->toUrl()->toString() . '" data-attributes-test="test123"', (string) $output);
$this->assertStringContainsString('<a href="' . $entity->toUrl()->toString() . '" data-attributes-test="test123"', (string) $output);
}
/**
......
......@@ -107,7 +107,7 @@ public function testMissingEffectPlugin() {
$this->executeMigration('d6_imagecache_presets');
$messages = iterator_to_array($this->migration->getIdMap()->getMessages());
$this->assertCount(1, $messages);
$this->assertContains('The "image_deprecated_scale" plugin does not exist.', $messages[0]->message);
$this->assertStringContainsString('The "image_deprecated_scale" plugin does not exist.', $messages[0]->message);
$this->assertEqual($messages[0]->level, MigrationInterface::MESSAGE_ERROR);
}
......
......@@ -57,7 +57,7 @@ public function testRead() {
]));
$this->assertSession()->statusCodeEquals(200);
$this->assertEquals(OffsetPage::SIZE_MAX, count($collection_output['data']));
$this->assertContains('page%5Boffset%5D=53', $collection_output['links']['next']['href']);
$this->assertStringContainsString('page%5Boffset%5D=53', $collection_output['links']['next']['href']);
// 3. Load all articles (1st page, 2 items)
$collection_output = Json::decode($this->drupalGet('/jsonapi/node/article', [
'query' => ['page' => ['limit' => 2]] + $default_sort,
......@@ -75,7 +75,7 @@ public function testRead() {
]));
$this->assertSession()->statusCodeEquals(200);
$this->assertEquals(2, count($collection_output['data']));
$this->assertContains('page%5Boffset%5D=4', $collection_output['links']['next']['href']);
$this->assertStringContainsString('page%5Boffset%5D=4', $collection_output['links']['next']['href']);
// 5. Single article.
$uuid = $this->nodes[0]->uuid();
$single_output = Json::decode($this->drupalGet('/jsonapi/node/article/' . $uuid));
......@@ -123,7 +123,7 @@ public function testRead() {
$this->assertSession()->statusCodeEquals(200);
$this->assertEquals('taxonomy_term--tags', $single_output['data'][0]['type']);
$this->assertArrayNotHasKey('tid', $single_output['data'][0]['attributes']);
$this->assertContains(
$this->assertStringContainsString(
'/taxonomy_term/tags/',
$single_output['data'][0]['links']['self']['href']
);
......
......@@ -179,7 +179,7 @@ protected function assertElementUnclickable(NodeElement $element) {
$this->fail(new FormattableMarkup("@tag_name was clickable when it shouldn't have been", ['@tag_name' => $tag_name]));
}
catch (\Exception $e) {
$this->assertContains('is not clickable at point', $e->getMessage());
$this->assertStringContainsString('is not clickable at point', $e->getMessage());
}
}
......
......@@ -352,7 +352,7 @@ public function testLinkTitle() {
$output = $this->renderTestEntity($id);
$expected_link = (string) Link::fromTextAndUrl($value, Url::fromUri($value))->toString();
$this->assertContains($expected_link, $output);
$this->assertStringContainsString($expected_link, $output);
// Verify that a link with text is rendered using the link text.
$title = $this->randomMachineName();
......@@ -364,7 +364,7 @@ public function testLinkTitle() {
$output = $this->renderTestEntity($id);
$expected_link = (string) Link::fromTextAndUrl($title, Url::fromUri($value))->toString();
$this->assertContains($expected_link, $output);
$this->assertStringContainsString($expected_link, $output);
}
/**
......@@ -468,51 +468,51 @@ public function testLinkFormatter() {
case 'trim_length':
$url = $url1;
$title = isset($new_value) ? Unicode::truncate($title1, $new_value, FALSE, TRUE) : $title1;
$this->assertContains('<a href="' . Html::escape($url) . '">' . Html::escape($title) . '</a>', $output);
$this->assertStringContainsString('<a href="' . Html::escape($url) . '">' . Html::escape($title) . '</a>', $output);
$url = $url2;
$title = isset($new_value) ? Unicode::truncate($title2, $new_value, FALSE, TRUE) : $title2;
$this->assertContains('<a href="' . Html::escape($url) . '">' . Html::escape($title) . '</a>', $output);
$this->assertStringContainsString('<a href="' . Html::escape($url) . '">' . Html::escape($title) . '</a>', $output);