Skip to content
Snippets Groups Projects
Unverified Commit 6108526c authored by Alex Pott's avatar Alex Pott
Browse files

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()
parent 396a950c
No related branches found
No related tags found
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
Showing
with 93 additions and 90 deletions
...@@ -65,25 +65,25 @@ public function testStringFormatter() { ...@@ -65,25 +65,25 @@ public function testStringFormatter() {
$build = $aggregator_feed->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => TRUE]]); $build = $aggregator_feed->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => TRUE]]);
$result = $this->render($build); $result = $this->render($build);
$this->assertContains('testing title', $result); $this->assertStringContainsString('testing title', $result);
$this->assertContains('href="' . $aggregator_feed->getUrl() . '"', $result); $this->assertStringContainsString('href="' . $aggregator_feed->getUrl() . '"', $result);
$build = $aggregator_feed->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => FALSE]]); $build = $aggregator_feed->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => FALSE]]);
$result = $this->render($build); $result = $this->render($build);
$this->assertContains('testing title', $result); $this->assertStringContainsString('testing title', $result);
$this->assertNotContains($aggregator_feed->getUrl(), $result); $this->assertStringNotContainsString($aggregator_feed->getUrl(), $result);
// Verify aggregator item title with and without links. // Verify aggregator item title with and without links.
$build = $aggregator_item->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => TRUE]]); $build = $aggregator_item->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => TRUE]]);
$result = $this->render($build); $result = $this->render($build);
$this->assertContains('test title', $result); $this->assertStringContainsString('test title', $result);
$this->assertContains('href="' . $aggregator_item->getLink() . '"', $result); $this->assertStringContainsString('href="' . $aggregator_item->getLink() . '"', $result);
$build = $aggregator_item->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => FALSE]]); $build = $aggregator_item->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => FALSE]]);
$result = $this->render($build); $result = $this->render($build);
$this->assertContains('test title', $result); $this->assertStringContainsString('test title', $result);
$this->assertNotContains($aggregator_item->getLink(), $result); $this->assertStringNotContainsString($aggregator_item->getLink(), $result);
} }
} }
...@@ -81,7 +81,7 @@ public function testCommentPopulatedTitles() { ...@@ -81,7 +81,7 @@ public function testCommentPopulatedTitles() {
$comment_permalink = $this->cssSelect('.permalink'); $comment_permalink = $this->cssSelect('.permalink');
$comment_permalink = $comment_permalink[0]->getAttribute('href'); $comment_permalink = $comment_permalink[0]->getAttribute('href');
// Tests that the comment's title link contains the url fragment. // 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."); $this->assertEqual($comment1->permalink()->toString(), $comment_permalink, "The comment's title has the correct link.");
} }
......
...@@ -86,8 +86,8 @@ protected function copyTestingOverrides() { ...@@ -86,8 +86,8 @@ protected function copyTestingOverrides() {
*/ */
public function testInstalled() { public function testInstalled() {
if ($this->expectedException) { 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->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->assertContains('Drupal\Core\Config\UnmetDependenciesException', $this->expectedException->getMessage()); $this->assertStringContainsString('Drupal\Core\Config\UnmetDependenciesException', $this->expectedException->getMessage());
} }
else { else {
$this->fail('Expected Drupal\Core\Config\UnmetDependenciesException exception not thrown'); $this->fail('Expected Drupal\Core\Config\UnmetDependenciesException exception not thrown');
......
...@@ -329,8 +329,8 @@ public function testSiteWideContact() { ...@@ -329,8 +329,8 @@ public function testSiteWideContact() {
$mails = $this->getMails(); $mails = $this->getMails();
$mail = array_pop($mails); $mail = array_pop($mails);
$this->assertEqual($mail['subject'], t('[@label] @subject', ['@label' => $label, '@subject' => $edit['subject[0][value]']])); $this->assertEqual($mail['subject'], t('[@label] @subject', ['@label' => $label, '@subject' => $edit['subject[0][value]']]));
$this->assertContains($field_label, $mail['body']); $this->assertStringContainsString($field_label, $mail['body']);
$this->assertContains($edit[$field_name . '[0][value]'], $mail['body']); $this->assertStringContainsString($edit[$field_name . '[0][value]'], $mail['body']);
// Test messages and redirect. // Test messages and redirect.
/** @var \Drupal\contact\ContactFormInterface $form */ /** @var \Drupal\contact\ContactFormInterface $form */
......
...@@ -71,7 +71,7 @@ public function testContentTranslationContextualLinks() { ...@@ -71,7 +71,7 @@ public function testContentTranslationContextualLinks() {
$this->drupalLogin($this->translator); $this->drupalLogin($this->translator);
$this->drupalGet('node/' . $node->id()); $this->drupalGet('node/' . $node->id());
$link = $this->assertSession()->waitForElement('css', '[data-contextual-id^="node:node=1"] .contextual-links a:contains("Translate")'); $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() { ...@@ -97,7 +97,7 @@ public function testDifferentPermissions() {
} }
$response = $this->renderContextualLinks([], 'node'); $response = $this->renderContextualLinks([], 'node');
$this->assertSame(400, $response->getStatusCode()); $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'); $response = $this->renderContextualLinks($ids, 'node');
$this->assertSame(200, $response->getStatusCode()); $this->assertSame(200, $response->getStatusCode());
$json = Json::decode((string) $response->getBody()); $json = Json::decode((string) $response->getBody());
...@@ -120,7 +120,7 @@ public function testDifferentPermissions() { ...@@ -120,7 +120,7 @@ public function testDifferentPermissions() {
} }
$response = $this->renderContextualLinks([], 'node'); $response = $this->renderContextualLinks([], 'node');
$this->assertSame(400, $response->getStatusCode()); $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'); $response = $this->renderContextualLinks($ids, 'node');
$this->assertSame(200, $response->getStatusCode()); $this->assertSame(200, $response->getStatusCode());
$json = Json::decode((string) $response->getBody()); $json = Json::decode((string) $response->getBody());
...@@ -177,7 +177,7 @@ public function testTokenProtection() { ...@@ -177,7 +177,7 @@ public function testTokenProtection() {
'http_errors' => FALSE, 'http_errors' => FALSE,
]); ]);
$this->assertEquals('400', $response->getStatusCode()); $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, [ $response = $http_client->request('POST', $url, [
'cookies' => $this->getSessionCookies(), 'cookies' => $this->getSessionCookies(),
...@@ -185,7 +185,7 @@ public function testTokenProtection() { ...@@ -185,7 +185,7 @@ public function testTokenProtection() {
'http_errors' => FALSE, 'http_errors' => FALSE,
]); ]);
$this->assertEquals('400', $response->getStatusCode()); $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, [ $response = $http_client->request('POST', $url, [
'cookies' => $this->getSessionCookies(), 'cookies' => $this->getSessionCookies(),
...@@ -193,7 +193,7 @@ public function testTokenProtection() { ...@@ -193,7 +193,7 @@ public function testTokenProtection() {
'http_errors' => FALSE, 'http_errors' => FALSE,
]); ]);
$this->assertEquals('400', $response->getStatusCode()); $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, [ $response = $http_client->request('POST', $url, [
'cookies' => $this->getSessionCookies(), 'cookies' => $this->getSessionCookies(),
......
...@@ -127,7 +127,7 @@ public function testDateField() { ...@@ -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); $expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE);
$output = $this->renderTestEntity($id); $output = $this->renderTestEntity($id);
$expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>'; $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, '%value' => $new_value,
'%expected' => $expected, '%expected' => $expected,
'%expected_iso' => $expected_iso, '%expected_iso' => $expected_iso,
...@@ -147,7 +147,7 @@ public function testDateField() { ...@@ -147,7 +147,7 @@ public function testDateField() {
->save(); ->save();
$expected = $date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT); $expected = $date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT);
$output = $this->renderTestEntity($id); $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, '%expected' => $expected,
'%timezone' => $timezone, '%timezone' => $timezone,
])); ]));
...@@ -161,7 +161,7 @@ public function testDateField() { ...@@ -161,7 +161,7 @@ public function testDateField() {
->save(); ->save();
$expected = $date->format($this->displayOptions['settings']['date_format']); $expected = $date->format($this->displayOptions['settings']['date_format']);
$output = $this->renderTestEntity($id); $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, '%expected' => $expected,
'%timezone' => $timezone, '%timezone' => $timezone,
])); ]));
...@@ -174,7 +174,7 @@ public function testDateField() { ...@@ -174,7 +174,7 @@ public function testDateField() {
->save(); ->save();
$expected = '<strong>' . $date->format('m/d/Y') . '</strong>alert(String.fromCharCode(88,83,83))'; $expected = '<strong>' . $date->format('m/d/Y') . '</strong>alert(String.fromCharCode(88,83,83))';
$output = $this->renderTestEntity($id); $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, '%expected' => $expected,
'%timezone' => $timezone, '%timezone' => $timezone,
])); ]));
...@@ -204,7 +204,7 @@ public function testDateField() { ...@@ -204,7 +204,7 @@ public function testDateField() {
'@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]), '@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
]); ]);
$output = $this->renderTestEntity($id); $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, '%expected' => $expected,
'%timezone' => $timezone, '%timezone' => $timezone,
])); ]));
...@@ -228,7 +228,7 @@ public function testDateField() { ...@@ -228,7 +228,7 @@ public function testDateField() {
'@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]), '@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
]); ]);
$output = $this->renderTestEntity($id); $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, '%expected' => $expected,
'%timezone' => $timezone, '%timezone' => $timezone,
])); ]));
...@@ -299,7 +299,7 @@ public function testDatetimeField() { ...@@ -299,7 +299,7 @@ public function testDatetimeField() {
$expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); $expected_iso = $date_formatter->format($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC');
$output = $this->renderTestEntity($id); $output = $this->renderTestEntity($id);
$expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>'; $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; break;
} }
} }
...@@ -314,7 +314,7 @@ public function testDatetimeField() { ...@@ -314,7 +314,7 @@ public function testDatetimeField() {
->save(); ->save();
$expected = $date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT); $expected = $date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
$output = $this->renderTestEntity($id); $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. // Verify that the 'datetime_custom' formatter works.
$this->displayOptions['type'] = 'datetime_custom'; $this->displayOptions['type'] = 'datetime_custom';
...@@ -324,7 +324,7 @@ public function testDatetimeField() { ...@@ -324,7 +324,7 @@ public function testDatetimeField() {
->save(); ->save();
$expected = $date->format($this->displayOptions['settings']['date_format']); $expected = $date->format($this->displayOptions['settings']['date_format']);
$output = $this->renderTestEntity($id); $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. // Verify that the 'timezone_override' setting works.
$this->displayOptions['type'] = 'datetime_custom'; $this->displayOptions['type'] = 'datetime_custom';
...@@ -334,7 +334,7 @@ public function testDatetimeField() { ...@@ -334,7 +334,7 @@ public function testDatetimeField() {
->save(); ->save();
$expected = $date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); $expected = $date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']);
$output = $this->renderTestEntity($id); $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 // Verify that the 'datetime_time_ago' formatter works for intervals in the
// past. First update the test entity so that the date difference always // past. First update the test entity so that the date difference always
...@@ -361,7 +361,7 @@ public function testDatetimeField() { ...@@ -361,7 +361,7 @@ public function testDatetimeField() {
'@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]), '@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
]); ]);
$output = $this->renderTestEntity($id); $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 // Verify that the 'datetime_time_ago' formatter works for intervals in the
// future. First update the test entity so that the date difference always // future. First update the test entity so that the date difference always
...@@ -383,7 +383,7 @@ public function testDatetimeField() { ...@@ -383,7 +383,7 @@ public function testDatetimeField() {
'@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]), '@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
]); ]);
$output = $this->renderTestEntity($id); $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() { ...@@ -107,7 +107,7 @@ public function testSeparatorTranslation() {
$build = $display->build($entity); $build = $display->build($entity);
$output = $this->container->get('renderer')->renderRoot($build); $output = $this->container->get('renderer')->renderRoot($build);
$this->verbose($output); $this->verbose($output);
$this->assertContains('UNTRANSLATED', (string) $output); $this->assertStringContainsString('UNTRANSLATED', (string) $output);
// Translate the separator. // Translate the separator.
ConfigurableLanguage::createFromLangcode('nl')->save(); ConfigurableLanguage::createFromLangcode('nl')->save();
...@@ -124,7 +124,7 @@ public function testSeparatorTranslation() { ...@@ -124,7 +124,7 @@ public function testSeparatorTranslation() {
$build = $display->build($entity); $build = $display->build($entity);
$output = $this->container->get('renderer')->renderRoot($build); $output = $this->container->get('renderer')->renderRoot($build);
$this->verbose($output); $this->verbose($output);
$this->assertContains('NL_TRANSLATED!', (string) $output); $this->assertStringContainsString('NL_TRANSLATED!', (string) $output);
} }
} }
...@@ -108,7 +108,7 @@ public function testEmailField() { ...@@ -108,7 +108,7 @@ public function testEmailField() {
$display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full'); $display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity); $content = $display->build($entity);
$rendered_content = (string) \Drupal::service('renderer')->renderRoot($content); $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) { ...@@ -105,7 +105,7 @@ public function _testTextfieldWidgets($field_type, $widget_type) {
$display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full'); $display = $display_repository->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity); $content = $display->build($entity);
$rendered_entity = \Drupal::service('renderer')->renderRoot($content); $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() { ...@@ -43,7 +43,7 @@ public function testUuidStringFormatter() {
// Verify default render. // Verify default render.
$render_array = $uuid_field->view([]); $render_array = $uuid_field->view([]);
$this->assertIdentical($render_array[0]['#context']['value'], $entity->uuid(), 'The rendered UUID matches the entity UUID.'); $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. // Verify customized render.
$render_array = $uuid_field->view(['settings' => ['link_to_entity' => TRUE]]); $render_array = $uuid_field->view(['settings' => ['link_to_entity' => TRUE]]);
...@@ -51,8 +51,8 @@ public function testUuidStringFormatter() { ...@@ -51,8 +51,8 @@ public function testUuidStringFormatter() {
$this->assertIdentical($render_array[0]['#title']['#context']['value'], $entity->uuid()); $this->assertIdentical($render_array[0]['#title']['#context']['value'], $entity->uuid());
$this->assertIdentical($render_array[0]['#url']->toString(), $entity->toUrl()->toString()); $this->assertIdentical($render_array[0]['#url']->toString(), $entity->toUrl()->toString());
$rendered = $this->render($render_array); $rendered = $this->render($render_array);
$this->assertContains($entity->uuid(), $rendered, 'The rendered UUID found.'); $this->assertStringContainsString($entity->uuid(), $rendered, 'The rendered UUID found.');
$this->assertContains($entity->toUrl()->toString(), $rendered, 'The rendered entity URL found.'); $this->assertStringContainsString($entity->toUrl()->toString(), $rendered, 'The rendered entity URL found.');
} }
} }
...@@ -254,9 +254,12 @@ public function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $tex ...@@ -254,9 +254,12 @@ public function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $tex
$output = (string) \Drupal::service('renderer')->renderRoot($element); $output = (string) \Drupal::service('renderer')->renderRoot($element);
$this->verbose(t('Rendered node - view mode: @view_mode', ['@view_mode' => $view_mode]) . '<hr />' . $output); $this->verbose(t('Rendered node - view mode: @view_mode', ['@view_mode' => $view_mode]) . '<hr />' . $output);
$method = $not_exists ? 'assertNotContains' : 'assertContains'; if ($not_exists) {
$this->assertStringNotContainsString((string) $text, $output, $message);
$this->{$method}((string) $text, $output, $message); }
else {
$this->assertStringContainsString((string) $text, $output, $message);
}
} }
/** /**
......
...@@ -143,7 +143,7 @@ public function testFormatterUI() { ...@@ -143,7 +143,7 @@ public function testFormatterUI() {
$field_test_format_type->setValue('field_test_multiple'); $field_test_format_type->setValue('field_test_multiple');
$assert_session->assertWaitOnAjaxRequest(); $assert_session->assertWaitOnAjaxRequest();
$plugin_summary = $page->find('css', '#field-test .field-plugin-summary'); $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 // Submit the form and assert that
// hook_field_formatter_settings_summary_alter() is called. // hook_field_formatter_settings_summary_alter() is called.
......
...@@ -422,7 +422,7 @@ public function testWidgetElement() { ...@@ -422,7 +422,7 @@ public function testWidgetElement() {
]); ]);
$this->assertNotEquals(500, $post_request->getStatusCode()); $this->assertNotEquals(500, $post_request->getStatusCode());
$body = Json::decode($post_request->getBody()); $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() { ...@@ -55,10 +55,10 @@ public function testMultipleFileFieldWithAllFileExtensions() {
$client->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $edit); $client->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $edit);
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$this->assertNotContains('Only files with the following extensions are allowed', $page->getContent()); $this->assertStringNotContainsString('Only files with the following extensions are allowed', $page->getContent());
$this->assertContains('The configuration options have been saved.', $page->getContent()); $this->assertStringContainsString('The configuration options have been saved.', $page->getContent());
$this->assertContains('file1.wtf', $page->getContent()); $this->assertStringContainsString('file1.wtf', $page->getContent());
$this->assertContains('file2.wtf', $page->getContent()); $this->assertStringContainsString('file2.wtf', $page->getContent());
} }
} }
...@@ -462,8 +462,8 @@ public function testInvalidUtf8FilenameUpload() { ...@@ -462,8 +462,8 @@ public function testInvalidUtf8FilenameUpload() {
$content = (string) $response->getBody(); $content = (string) $response->getBody();
$this->htmlOutput($content); $this->htmlOutput($content);
$error_text = new FormattableMarkup('The file %filename could not be uploaded because the name is invalid.', ['%filename' => $filename]); $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->assertStringContainsString((string) $error_text, $content);
$this->assertContains('Epic upload FAIL!', $content); $this->assertStringContainsString('Epic upload FAIL!', $content);
$this->assertFileNotExists('temporary://' . $filename); $this->assertFileNotExists('temporary://' . $filename);
} }
......
...@@ -55,8 +55,8 @@ public function testCaptionFilter() { ...@@ -55,8 +55,8 @@ public function testCaptionFilter() {
$input = '<img src="llama.jpg" data-caption="Loquacious llama!" />'; $input = '<img src="llama.jpg" data-caption="Loquacious llama!" />';
$expected = '<img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption>'; $expected = '<img src="llama.jpg" /><figcaption>Loquacious llama!</figcaption>';
$output = $test($input)->getProcessedText(); $output = $test($input)->getProcessedText();
$this->assertContains($expected, $output); $this->assertStringContainsString($expected, $output);
$this->assertContains("<!-- THEME HOOK: 'filter_caption' -->", $output); $this->assertStringContainsString("<!-- THEME HOOK: 'filter_caption' -->", $output);
} }
} }
...@@ -209,7 +209,7 @@ public function testForum() { ...@@ -209,7 +209,7 @@ public function testForum() {
$this->assertStringStartsWith('6 new posts', $elements[0]->getText(), 'Number of unread topics found.'); $this->assertStringStartsWith('6 new posts', $elements[0]->getText(), 'Number of unread topics found.');
// Verify that the forum name is in the unread topics text. // Verify that the forum name is in the unread topics text.
$elements = $this->xpath('//tr[@id=:forum]//em[@class="placeholder"]', $forum_arg); $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. // Verify total number of posts in forum.
$elements = $this->xpath('//tr[@id=:forum]//td[@class="forum__posts"]', $forum_arg); $elements = $this->xpath('//tr[@id=:forum]//td[@class="forum__posts"]', $forum_arg);
......
...@@ -189,7 +189,7 @@ protected function verifyHelpLinks() { ...@@ -189,7 +189,7 @@ protected function verifyHelpLinks() {
// Verify theme provided help topics work and can be related. // Verify theme provided help topics work and can be related.
$this->drupalGet('admin/help/topic/help_topics_test_theme.test'); $this->drupalGet('admin/help/topic/help_topics_test_theme.test');
$session->pageTextContains('This is a theme provided topic.'); $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'); $this->clickLink('Additional topic');
$session->linkExists('XYZ Help Test theme'); $session->linkExists('XYZ Help Test theme');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment