Unverified Commit 5a6777a1 authored by alexpott's avatar alexpott
Browse files

Issue #3139404 by mondrake, longwave, munish.kumar, pavnish: Replace usages of...

Issue #3139404 by mondrake, longwave, munish.kumar, pavnish: Replace usages of AssertLegacyTrait::assertText, that is deprecated
parent 97b61dac
......@@ -52,9 +52,9 @@ public function testActionConfiguration() {
$action_id = $edit['id'];
// Make sure that the new complex action was saved properly.
$this->assertText('The action has been successfully saved.');
$this->assertSession()->pageTextContains('The action has been successfully saved.');
// The action label appears on the configuration page.
$this->assertText($action_label);
$this->assertSession()->pageTextContains($action_label);
// Make another POST request to the action edit page.
$this->clickLink(t('Configure'));
......@@ -67,12 +67,12 @@ public function testActionConfiguration() {
$this->assertSession()->statusCodeEquals(200);
// Make sure that the action updated properly.
$this->assertText('The action has been successfully saved.');
$this->assertSession()->pageTextContains('The action has been successfully saved.');
// The old action label does NOT appear on the configuration page.
$this->assertNoText($action_label);
// The action label appears on the configuration page after we've updated
// the complex action.
$this->assertText($new_action_label);
$this->assertSession()->pageTextContains($new_action_label);
// Make sure the URL appears when re-editing the action.
$this->clickLink(t('Configure'));
......
......@@ -37,7 +37,7 @@ public function testAddFeed() {
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertSession()->statusCodeEquals(200);
// Verify that the feed label is present in the page title.
$this->assertText($feed->label());
$this->assertSession()->pageTextContains($feed->label());
$this->assertRaw($feed->getWebsiteUrl());
// Try to add a duplicate.
......@@ -94,7 +94,7 @@ public function testAddLongFeed() {
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertSession()->statusCodeEquals(200);
// Verify that the feed label is present in the page title.
$this->assertText($feed->label());
$this->assertSession()->pageTextContains($feed->label());
// Delete feeds.
$this->deleteFeed($feed);
......
......@@ -22,9 +22,9 @@ public function testSettingsPage() {
$this->clickLink('Aggregator');
$this->clickLink('Settings');
// Make sure that test plugins are present.
$this->assertText('Test fetcher');
$this->assertText('Test parser');
$this->assertText('Test processor');
$this->assertSession()->pageTextContains('Test fetcher');
$this->assertSession()->pageTextContains('Test parser');
$this->assertSession()->pageTextContains('Test processor');
// Set new values and enable test plugins.
$edit = [
......@@ -37,7 +37,7 @@ public function testSettingsPage() {
'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor',
];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, 'Save configuration');
$this->assertText('The configuration options have been saved.');
$this->assertSession()->pageTextContains('The configuration options have been saved.');
// Check that settings have the correct default value.
foreach ($edit as $name => $value) {
......@@ -45,13 +45,13 @@ public function testSettingsPage() {
}
// Check for our test processor settings form.
$this->assertText('Dummy length setting');
$this->assertSession()->pageTextContains('Dummy length setting');
// Change its value to ensure that settingsSubmit is called.
$edit = [
'dummy_length' => 100,
];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, 'Save configuration');
$this->assertText('The configuration options have been saved.');
$this->assertSession()->pageTextContains('The configuration options have been saved.');
$this->assertSession()->fieldValueEquals('dummy_length', 100);
// Make sure settings form is still accessible even after uninstalling a module
......
......@@ -56,7 +56,7 @@ public function testBlockLinks() {
// Confirm that the block is now being displayed on pages.
$this->drupalGet('test-page');
$this->assertText($block->label());
$this->assertSession()->pageTextContains($block->label());
// Confirm items appear as links.
$items = $this->container->get('entity_type.manager')->getStorage('aggregator_item')->loadByFeed($feed->id(), 1);
......
......@@ -75,7 +75,7 @@ protected function setUp() {
public function createFeed($feed_url = NULL, array $edit = []) {
$edit = $this->getFeedEditArray($feed_url, $edit);
$this->drupalPostForm('aggregator/sources/add', $edit, 'Save');
$this->assertText('The feed ' . Html::escape($edit['title[0][value]']) . ' has been added.');
$this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been added.');
// Verify that the creation message contains a link to a feed.
$this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]');
......
......@@ -38,7 +38,7 @@ public function testDeleteFeed() {
// Delete feed.
$this->deleteFeed($feed1);
$this->assertText($feed2->label());
$this->assertSession()->pageTextContains($feed2->label());
$block_storage = $this->container->get('entity_type.manager')->getStorage('block');
$this->assertNull($block_storage->load($block->id()), 'Block for the deleted feed was deleted.');
$this->assertEquals($block2->id(), $block_storage->load($block2->id())->id(), 'Block for not deleted feed still exists.');
......
......@@ -26,8 +26,8 @@ public function testFeedUpdateFields() {
// The scheduled feed shows that it has not been updated yet and is
// scheduled.
$this->assertText('never');
$this->assertText('imminently');
$this->assertSession()->pageTextContains('never');
$this->assertSession()->pageTextContains('imminently');
$this->assertNoText('ago');
$this->assertNoText('left');
......@@ -38,8 +38,8 @@ public function testFeedUpdateFields() {
// and next update.
$this->assertNoText('never');
$this->assertNoText('imminently');
$this->assertText('ago');
$this->assertText('left');
$this->assertSession()->pageTextContains('ago');
$this->assertSession()->pageTextContains('left');
// Delete scheduled feed.
$this->deleteFeed($scheduled_feed);
......@@ -49,7 +49,7 @@ public function testFeedUpdateFields() {
$this->drupalGet('admin/config/services/aggregator');
// The non scheduled feed shows that it has not been updated yet.
$this->assertText('never');
$this->assertSession()->pageTextContains('never');
$this->assertNoText('imminently');
$this->assertNoText('ago');
$this->assertNoText('left');
......@@ -59,9 +59,9 @@ public function testFeedUpdateFields() {
// After the feed update, we still need to see "never" as next update label.
// Last update will show an interval.
$this->assertText('never');
$this->assertSession()->pageTextContains('never');
$this->assertNoText('imminently');
$this->assertText('ago');
$this->assertSession()->pageTextContains('ago');
$this->assertNoText('left');
}
......
......@@ -38,18 +38,18 @@ public function testRSS091Sample() {
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertSession()->statusCodeEquals(200);
$this->assertText('First example feed item title');
$this->assertSession()->pageTextContains('First example feed item title');
$this->assertSession()->linkByHrefExists('http://example.com/example-turns-one');
$this->assertText('First example feed item description.');
$this->assertSession()->pageTextContains('First example feed item description.');
$this->assertRaw('<img src="http://example.com/images/druplicon.png"');
// Several additional items that include elements over 255 characters.
$this->assertRaw("Second example feed item title.");
$this->assertText('Long link feed item title');
$this->assertText('Long link feed item description');
$this->assertSession()->pageTextContains('Long link feed item title');
$this->assertSession()->pageTextContains('Long link feed item description');
$this->assertSession()->linkByHrefExists('http://example.com/tomorrow/and/tomorrow/and/tomorrow/creeps/in/this/petty/pace/from/day/to/day/to/the/last/syllable/of/recorded/time/and/all/our/yesterdays/have/lighted/fools/the/way/to/dusty/death/out/out/brief/candle/life/is/but/a/walking/shadow/a/poor/player/that/struts/and/frets/his/hour/upon/the/stage/and/is/heard/no/more/it/is/a/tale/told/by/an/idiot/full/of/sound/and/fury/signifying/nothing');
$this->assertText('Long author feed item title');
$this->assertText('Long author feed item description');
$this->assertSession()->pageTextContains('Long author feed item title');
$this->assertSession()->pageTextContains('Long author feed item description');
$this->assertSession()->linkByHrefExists('http://example.com/long/author');
}
......@@ -61,9 +61,9 @@ public function testAtomSample() {
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertSession()->statusCodeEquals(200);
$this->assertText('Atom-Powered Robots Run Amok');
$this->assertSession()->pageTextContains('Atom-Powered Robots Run Amok');
$this->assertSession()->linkByHrefExists('http://example.org/2003/12/13/atom03');
$this->assertText('Some text.');
$this->assertSession()->pageTextContains('Some text.');
$item_ids = \Drupal::entityQuery('aggregator_item')
->accessCheck(FALSE)
->condition('link', 'http://example.org/2003/12/13/atom03')
......@@ -72,9 +72,9 @@ public function testAtomSample() {
$this->assertEquals('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', $item->getGuid(), 'Atom entry id element is parsed correctly.');
// Check for second feed entry.
$this->assertText('We tried to stop them, but we failed.');
$this->assertSession()->pageTextContains('We tried to stop them, but we failed.');
$this->assertSession()->linkByHrefExists('http://example.org/2003/12/14/atom03');
$this->assertText('Some other text.');
$this->assertSession()->pageTextContains('Some other text.');
$item_ids = \Drupal::entityQuery('aggregator_item')
->accessCheck(FALSE)
->condition('link', 'http://example.org/2003/12/14/atom03')
......
......@@ -46,7 +46,7 @@ public function openImportForm() {
$this->drupalPlaceBlock('help_block', ['region' => 'help']);
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->assertText('A single OPML document may contain many feeds.');
$this->assertSession()->pageTextContains('A single OPML document may contain many feeds.');
// Ensure that the file upload, remote URL, and refresh fields exist.
$this->assertSession()->fieldExists('files[upload]');
$this->assertSession()->fieldExists('remote');
......@@ -75,7 +75,7 @@ public function validateImportFormFields() {
// Error if the URL is invalid.
$edit = ['remote' => 'invalidUrl://empty'];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->assertText('The URL invalidUrl://empty is not valid.');
$this->assertSession()->pageTextContains('The URL invalidUrl://empty is not valid.');
$after = $count_query->execute();
$this->assertEquals($before, $after, 'No feeds were added during the three last form submissions.');
......@@ -91,12 +91,12 @@ protected function submitImportForm() {
// Attempting to upload invalid XML.
$form['files[upload]'] = $this->getInvalidOpml();
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, 'Import');
$this->assertText('No new feed has been added.');
$this->assertSession()->pageTextContains('No new feed has been added.');
// Attempting to load empty OPML from remote URL
$edit = ['remote' => file_create_url($this->getEmptyOpml())];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, 'Import');
$this->assertText('No new feed has been added.');
$this->assertSession()->pageTextContains('No new feed has been added.');
$after = $count_query->execute();
$this->assertEquals($before, $after, 'No feeds were added during the two last form submissions.');
......
......@@ -44,7 +44,7 @@ public function testUpdateFeedItem() {
$this->assertSession()->statusCodeEquals(200);
$this->drupalPostForm('aggregator/sources/add', $edit, 'Save');
$this->assertText('The feed ' . $edit['title[0][value]'] . ' has been added.');
$this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been added.');
// Verify that the creation message contains a link to a feed.
$this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]');
......
......@@ -30,7 +30,7 @@ public function testUpdateFeed() {
$edit[$same_field] = $feed->{$same_field}->value;
}
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, 'Save');
$this->assertText('The feed ' . $edit['title[0][value]'] . ' has been updated.');
$this->assertSession()->pageTextContains('The feed ' . $edit['title[0][value]'] . ' has been updated.');
// Verify that the creation message contains a link to a feed.
$this->assertSession()->elementExists('xpath', '//div[@data-drupal-messages]//a[contains(@href, "aggregator/sources/")]');
......@@ -42,7 +42,7 @@ public function testUpdateFeed() {
// Check feed source, the title should be on the page.
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertSession()->statusCodeEquals(200);
$this->assertText($edit['title[0][value]']);
$this->assertSession()->pageTextContains($edit['title[0][value]']);
// Set correct title so deleteFeed() will work.
$feed->title = $edit['title[0][value]'];
......
......@@ -47,25 +47,25 @@ public function testIPAddressValidation() {
$edit = [];
$edit['ip'] = '1.2.3.3';
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->assertText('This IP address is already banned.');
$this->assertSession()->pageTextContains('This IP address is already banned.');
// Try to block a reserved IP address.
$edit = [];
$edit['ip'] = '255.255.255.255';
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->assertText('Enter a valid IP address.');
$this->assertSession()->pageTextContains('Enter a valid IP address.');
// Try to block a reserved IP address.
$edit = [];
$edit['ip'] = 'test.example.com';
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->assertText('Enter a valid IP address.');
$this->assertSession()->pageTextContains('Enter a valid IP address.');
// Submit an empty form.
$edit = [];
$edit['ip'] = '';
$this->drupalPostForm('admin/config/people/ban', $edit, 'Add');
$this->assertText('Enter a valid IP address.');
$this->assertSession()->pageTextContains('Enter a valid IP address.');
// Pass an IP address as a URL parameter and submit it.
$submit_ip = '1.2.3.4';
......@@ -80,7 +80,7 @@ public function testIPAddressValidation() {
// $edit = array();
// $edit['ip'] = \Drupal::request()->getClientIP();
// $this->drupalPostForm('admin/config/people/ban', $edit, 'Save');
// $this->assertText('You may not ban your own IP address.');
// $this->assertSession()->pageTextContains('You may not ban your own IP address.');
// Test duplicate ip address are not present in the 'blocked_ips' table.
// when they are entered programmatically.
......
......@@ -48,7 +48,7 @@ public function testBasicAuth() {
// Ensure we can log in with valid authentication details.
$this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw);
$this->assertText($account->getAccountName());
$this->assertSession()->pageTextContains($account->getAccountName());
$this->assertSession()->statusCodeEquals(200);
$this->mink->resetSessions();
$this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache');
......@@ -164,7 +164,7 @@ public function testLocale() {
$url = Url::fromRoute('router_test.11');
$this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw);
$this->assertText($account->getAccountName());
$this->assertSession()->pageTextContains($account->getAccountName());
$this->assertSession()->statusCodeEquals(200);
}
......@@ -180,26 +180,26 @@ public function testUnauthorizedErrorMessage() {
$this->drupalGet($url);
$this->assertSession()->statusCodeEquals(401);
$this->assertNoText('Exception');
$this->assertText('Please log in to access this page.');
$this->assertSession()->pageTextContains('Please log in to access this page.');
// Case when empty credentials are passed, a user friendly access denied
// message is displayed.
$this->basicAuthGet($url, NULL, NULL);
$this->assertSession()->statusCodeEquals(403);
$this->assertText('Access denied');
$this->assertSession()->pageTextContains('Access denied');
// Case when wrong credentials are passed, a user friendly access denied
// message is displayed.
$this->basicAuthGet($url, $account->getAccountName(), $this->randomMachineName());
$this->assertSession()->statusCodeEquals(403);
$this->assertText('Access denied');
$this->assertSession()->pageTextContains('Access denied');
// Case when correct credentials but hasn't access to the route, an user
// friendly access denied message is displayed.
$url = Url::fromRoute('router_test.15');
$this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw);
$this->assertSession()->statusCodeEquals(403);
$this->assertText('Access denied');
$this->assertSession()->pageTextContains('Access denied');
}
/**
......
......@@ -85,21 +85,21 @@ public function testCachePerRole() {
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalLogin($this->normalUser);
$this->drupalGet('');
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
// Change the content, but the cached copy should still be served.
$old_content = $current_content;
$current_content = $this->randomMachineName();
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($old_content);
$this->assertSession()->pageTextContains($old_content);
// Clear the cache and verify that the stale data is no longer there.
Cache::invalidateTags(['block_view']);
$this->drupalGet('');
$this->assertNoText($old_content);
// Fresh block content is displayed after clearing the cache.
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
// Test whether the cached data is served for the correct users.
$old_content = $current_content;
......@@ -113,7 +113,7 @@ public function testCachePerRole() {
// User with the same roles sees per-role cached content.
$this->drupalLogin($this->normalUserAlt);
$this->drupalGet('');
$this->assertText($old_content);
$this->assertSession()->pageTextContains($old_content);
// Admin user does not see content cached per-role for normal user.
$this->drupalLogin($this->adminUser);
......@@ -123,7 +123,7 @@ public function testCachePerRole() {
// Block is served from the per-role cache.
$this->drupalLogin($this->normalUser);
$this->drupalGet('');
$this->assertText($old_content);
$this->assertSession()->pageTextContains($old_content);
}
/**
......@@ -138,7 +138,7 @@ public function testCachePermissions() {
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('');
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
$old_content = $current_content;
$current_content = $this->randomMachineName();
......@@ -146,12 +146,12 @@ public function testCachePermissions() {
// Block content served from cache.
$this->drupalGet('user');
$this->assertText($old_content);
$this->assertSession()->pageTextContains($old_content);
// Block content not served from cache.
$this->drupalLogout();
$this->drupalGet('user');
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
}
/**
......@@ -165,14 +165,14 @@ public function testNoCache() {
// If max_age = 0 has no effect, the next request would be cached.
$this->drupalGet('');
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
// A cached copy should not be served.
$current_content = $this->randomMachineName();
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('');
// Maximum age of zero prevents blocks from being cached.
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
}
/**
......@@ -186,7 +186,7 @@ public function testCachePerUser() {
$this->drupalLogin($this->normalUser);
$this->drupalGet('');
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
$old_content = $current_content;
$current_content = $this->randomMachineName();
......@@ -194,17 +194,17 @@ public function testCachePerUser() {
// Block is served from per-user cache.
$this->drupalGet('');
$this->assertText($old_content);
$this->assertSession()->pageTextContains($old_content);
// Per-user block cache is not served for other users.
$this->drupalLogin($this->normalUserAlt);
$this->drupalGet('');
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
// Per-user block cache is persistent.
$this->drupalLogin($this->normalUser);
$this->drupalGet('');
$this->assertText($old_content);
$this->assertSession()->pageTextContains($old_content);
}
/**
......@@ -217,7 +217,7 @@ public function testCachePerPage() {
\Drupal::state()->set('block_test.content', $current_content);
$this->drupalGet('test-page');
$this->assertText($current_content);
$this->assertSession()->pageTextContains($current_content);
$old_content = $current_content;
$current_content = $this->randomMachineName();
......@@ -231,7 +231,7 @@ public function testCachePerPage() {
$this->drupalGet('test-page');
$this->assertSession()->statusCodeEquals(200);
// Verify that the block content is cached for the test page.
$this->assertText($old_content);
$this->assertSession()->pageTextContains($old_content);
}
}
......@@ -43,25 +43,25 @@ public function testCachePerPage() {
// Go to "test-page" and test if the block is enabled.
$this->drupalGet('test-page');
$this->assertSession()->statusCodeEquals(200);
$this->assertText('Your .com email address.');
$this->assertSession()->pageTextContains('Your .com email address.');
// Make sure that we're currently still on /test-page after submitting the
// form.
$this->submitForm($form_values, 'Submit');
$this->assertSession()->addressEquals('test-page');
$this->assertText('Your email address is test@example.com');
$this->assertSession()->pageTextContains('Your email address is test@example.com');
// Go to a different page and see if the block is enabled there as well.
$this->drupalGet('test-render-title');
$this->assertSession()->statusCodeEquals(200);
$this->assertText('Your .com email address.');
$this->assertSession()->pageTextContains('Your .com email address.');
// Make sure that submitting the form didn't redirect us to the first page
// we submitted the form from after submitting the form from
// /test-render-title.
$this->submitForm($form_values, 'Submit');
$this->assertSession()->addressEquals('test-render-title');
$this->assertText('Your email address is test@example.com');
$this->assertSession()->pageTextContains('Your email address is test@example.com');
}
/**
......@@ -71,7 +71,7 @@ public function testPlaceholders() {
$this->drupalGet('test-multiple-forms');
$placeholder = 'form_action_' . Crypt::hashBase64('Drupal\Core\Form\FormBuilder::prepareForm');
$this->assertText('Form action: ' . $placeholder);
$this->assertSession()->pageTextContains('Form action: ' . $placeholder);
}
}
......@@ -52,7 +52,7 @@ public function testBlockNotInHiddenRegion() {
// Ensure that the search form block is displayed.
$this->drupalGet('');
$this->assertText('Search');
$this->assertSession()->pageTextContains('Search');
// Install "block_test_theme" and set it as the default theme.
$theme = 'block_test_theme';
......@@ -72,7 +72,7 @@ public function testBlockNotInHiddenRegion() {
// Ensure that the search form block is displayed.
$this->drupalGet('');
$this->assertText('Search');
$this->assertSession()->pageTextContains('Search');
}
}
......@@ -31,7 +31,7 @@ public function testCacheTagInvalidationUponInstallation() {
// invalidated the 'rendered' cache tag to make blocks show up.
$this->drupalGet('');
$this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:block_list');
$this->assertText('Powered by Drupal');
$this->assertSession()->pageTextContains('Powered by Drupal');
}
}
......@@ -68,13 +68,13 @@ public function testBlockLinks() {
$edit['label'] = $this->randomMachineName();
$edit['id'] = mb_strtolower($edit['label']);
$this->drupalPostForm('admin/structure/menu/add', $edit, 'Save');
$this->assertText('Menu ' . $edit['label'] . ' has been added.');
$this->assertSession()->pageTextContains('Menu ' . $edit['label'] . ' has been added.');
// Check that the block is listed for all languages.
foreach ($this->langcodes as $langcode) {
$this->drupalGet('admin/structure/block', ['language' => $langcode]);
$this->clickLink('Place block');
$this->assertText($edit['label']);
$this->assertSession()->pageTextContains($edit['label']);
}
}
......
......@@ -46,7 +46,7 @@ protected function setUp(): void {
$this->drupalPostForm('admin/config/regional/language/add', $edit, 'Add language');
// Verify that language was added successfully.
$this->assertText('French');
$this->assertSession()->pageTextContains('French');
}