Skip to content

Commit

Permalink
Issue #3139414 by cburschka, mohrerao, pavnish, jungle, ravi.shankar,…
Browse files Browse the repository at this point in the history
… daffie, mondrake, sja112: Replace usages of deprecated AssertLegacyTrait::assert(No)Link()
  • Loading branch information
alexpott committed Jun 16, 2020
1 parent 6506886 commit fceb1b7
Show file tree
Hide file tree
Showing 84 changed files with 267 additions and 267 deletions.
2 changes: 1 addition & 1 deletion modules/basic_auth/tests/src/Functional/BasicAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testBasicAuth() {

// Ensure that a route without basic auth defined doesn't allow login.
$this->basicAuthGet(Url::fromRoute('system.admin'), $account->getAccountName(), $account->pass_raw);
$this->assertNoLink('Log out', 'User is not logged in');
$this->assertSession()->linkNotExists('Log out', 'User is not logged in');
$this->assertSession()->statusCodeEquals(403);
$this->mink->resetSessions();

Expand Down
8 changes: 4 additions & 4 deletions modules/block/tests/src/Functional/BlockUiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ public function testBlockAdminUiPage() {
\Drupal::service('theme_installer')->install(['stable', 'stark']);
$this->drupalGet('admin/structure/block');
$theme_handler = \Drupal::service('theme_handler');
$this->assertLink($theme_handler->getName('classy'));
$this->assertLink($theme_handler->getName('stark'));
$this->assertNoLink($theme_handler->getName('stable'));
$this->assertSession()->linkExists($theme_handler->getName('classy'));
$this->assertSession()->linkExists($theme_handler->getName('stark'));
$this->assertSession()->linkNotExists($theme_handler->getName('stable'));

// Ensure that a hidden theme cannot use the block demo page.
$this->drupalGet('admin/structure/block/list/stable');
Expand All @@ -166,7 +166,7 @@ public function testBlockAdminUiPage() {
\Drupal::service('router.builder')->rebuildIfNeeded();
$this->drupalPlaceBlock('local_tasks_block', ['region' => 'header', 'theme' => 'stable']);
$this->drupalGet('admin/structure/block');
$this->assertLink($theme_handler->getName('stable'));
$this->assertSession()->linkExists($theme_handler->getName('stable'));
$this->drupalGet('admin/structure/block/list/stable');
$this->assertSession()->statusCodeEquals(200);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testListing() {
$new_label = 'Albatross';
// Add a new entity using the operations link.
$link_text = t('Add custom block');
$this->assertLink($link_text);
$this->assertSession()->linkExists($link_text);
$this->clickLink($link_text);
$this->assertSession()->statusCodeEquals(200);
$edit = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testListing() {
$new_label = 'Albatross';
// Add a new entity using the operations link.
$link_text = t('Add custom block');
$this->assertLink($link_text);
$this->assertSession()->linkExists($link_text);
$this->clickLink($link_text);
$this->assertSession()->statusCodeEquals(200);
$edit = [];
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testListing() {

// Confirm that the empty text is displayed.
$this->assertText('There are no custom blocks available.');
$this->assertLink('custom block');
$this->assertSession()->linkExists('custom block');

$block_content = BlockContent::create([
'info' => 'Non-reusable block',
Expand Down
6 changes: 3 additions & 3 deletions modules/book/tests/src/Functional/BookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function testBookExport() {

// Load the book and verify there is no printer-friendly version link.
$this->drupalGet('node/' . $this->book->id());
$this->assertNoLink(t('Printer-friendly version'), 'Anonymous user is not shown link to printer-friendly version.');
$this->assertSession()->linkNotExists(t('Printer-friendly version'), 'Anonymous user is not shown link to printer-friendly version.');

// Try getting the URL directly, and verify it fails.
$this->drupalGet('book/export/html/' . $this->book->id());
Expand Down Expand Up @@ -402,13 +402,13 @@ public function testBookOutline() {
// Create new node not yet a book.
$empty_book = $this->drupalCreateNode(['type' => 'book']);
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertNoLink(t('Book outline'), 'Book Author is not allowed to outline');
$this->assertSession()->linkNotExists(t('Book outline'), 'Book Author is not allowed to outline');

$this->drupalLogin($this->adminUser);
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book');
$this->assertNoLink(t('Remove from book outline'));
$this->assertSession()->linkNotExists(t('Remove from book outline'));

$edit = [];
$edit['book[bid]'] = '1';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function testRelationship() {
$this->drupalGet('test-book/' . $nodes[$i]->id());

for ($j = 0; $j < $i; $j++) {
$this->assertLink($nodes[$j]->label());
$this->assertSession()->linkExists($nodes[$j]->label());
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/comment/tests/src/Functional/CommentAnonymousTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function testAnonymous() {
// "Login or register to post comments" type link may be shown.
$this->drupalGet('node/' . $this->node->id());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertNoLink('Add new comment', 'Link to add comment was found.');
$this->assertSession()->linkNotExists('Add new comment', 'Link to add comment was found.');

// Attempt to view node-comment form while disallowed.
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
Expand All @@ -189,8 +189,8 @@ public function testAnonymous() {
]);
$this->drupalGet('node/' . $this->node->id());
$this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.');
$this->assertLink('Log in', 1, 'Link to login was found.');
$this->assertLink('register', 1, 'Link to register was found.');
$this->assertSession()->linkExists('Log in', 1, 'Link to login was found.');
$this->assertSession()->linkExists('register', 1, 'Link to register was found.');

user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => FALSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testCommentLinksAlter() {

$this->drupalGet('node/' . $this->node->id());

$this->assertLink(t('Report'));
$this->assertSession()->linkExists(t('Report'));
}

}
12 changes: 6 additions & 6 deletions modules/comment/tests/src/Functional/CommentLinksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public function testCommentLinks() {
// In teaser view, a link containing the comment count is always
// expected.
if ($path == 'node') {
$this->assertLink(t('1 comment'));
$this->assertSession()->linkExists(t('1 comment'));
}
$this->assertLink('Add new comment');
$this->assertSession()->linkExists('Add new comment');
}

$display_repository = $this->container->get('entity_display.repository');
Expand Down Expand Up @@ -133,21 +133,21 @@ public function testCommentLinks() {
->removeComponent('links')
->save();
$this->drupalGet($this->node->toUrl());
$this->assertNoLink('1 comment');
$this->assertNoLink('Add new comment');
$this->assertSession()->linkNotExists('1 comment');
$this->assertSession()->linkNotExists('Add new comment');

// Visit the full node, make sure there are links for the comment.
$this->drupalGet('node/' . $this->node->id());
$this->assertText($comment->getSubject());
$this->assertLink('Reply');
$this->assertSession()->linkExists('Reply');

// Make sure we can hide comment links.
$display_repository->getViewDisplay('comment', 'comment')
->removeComponent('links')
->save();
$this->drupalGet('node/' . $this->node->id());
$this->assertText($comment->getSubject());
$this->assertNoLink('Reply');
$this->assertSession()->linkNotExists('Reply');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function testCommentNewCommentsIndicator() {
// node.
$this->drupalLogin($this->adminUser);
$this->drupalGet('node');
$this->assertNoLink(t('@count comments', ['@count' => 0]));
$this->assertLink(t('Read more'));
$this->assertSession()->linkNotExists(t('@count comments', ['@count' => 0]));
$this->assertSession()->linkExists(t('Read more'));
// Verify the data-history-node-last-comment-timestamp attribute, which is
// used by the drupal.node-new-comments-link library to determine whether
// a "x new comments" link might be necessary or not. We do this in
Expand Down
6 changes: 3 additions & 3 deletions modules/comment/tests/src/Functional/CommentNonNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public function testCommentFunctionality() {
// Attempt to view comments while disallowed.
$this->drupalGet('entity-test/' . $this->entity->id());
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertNoLink('Add new comment', 'Link to add comment was found.');
$this->assertSession()->linkNotExists('Add new comment', 'Link to add comment was found.');

// Attempt to view test entity comment form while disallowed.
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
Expand All @@ -371,8 +371,8 @@ public function testCommentFunctionality() {
]);
$this->drupalGet('entity_test/' . $this->entity->id());
$this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.');
$this->assertLink('Log in', 0, 'Link to login was found.');
$this->assertLink('register', 0, 'Link to register was found.');
$this->assertSession()->linkExists('Log in', 0, 'Link to login was found.');
$this->assertSession()->linkExists('register', 0, 'Link to register was found.');
$this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field not found.');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function testListUI() {
$this->assertNotEmpty($elements[2]->find('xpath', '//ul'), 'Operations list found.');

// Add a new entity using the operations link.
$this->assertLink('Add test configuration');
$this->assertSession()->linkExists('Add test configuration');
$this->clickLink('Add test configuration');
$this->assertSession()->statusCodeEquals(200);
$edit = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testMapperListPage() {
$this->assertRaw('<th>' . t('Language') . '</th>');

$this->drupalGet($base_url);
$this->assertLink(t('Translate @title', ['@title' => $entity_type->getSingularLabel()]));
$this->assertSession()->linkExists(t('Translate @title', ['@title' => $entity_type->getSingularLabel()]));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public function testSourceValueDuplicateSave() {
// While translator can access the translation page, the edit link is not
// present due to lack of permissions.
$this->drupalGet($translation_base_url);
$this->assertNoLink(t('Edit'));
$this->assertSession()->linkNotExists(t('Edit'));

// Check 'Add' link for French.
$this->assertLinkByHref("$translation_base_url/fr/add");
Expand Down Expand Up @@ -331,15 +331,15 @@ public function testContactConfigEntityTranslation() {

// Make sure translate tab is present.
$this->drupalGet('admin/structure/contact/manage/feedback');
$this->assertLink(t('Translate @type', ['@type' => 'contact form']));
$this->assertSession()->linkExists(t('Translate @type', ['@type' => 'contact form']));

// Visit the form to confirm the changes.
$this->drupalGet('contact/feedback');
$this->assertText($label);

foreach ($this->langcodes as $langcode) {
$this->drupalGet($translation_base_url);
$this->assertLink(t('Translate @type', ['@type' => 'contact form']));
$this->assertSession()->linkExists(t('Translate @type', ['@type' => 'contact form']));

// 'Add' link should be present for $langcode translation.
$translation_page_url = "$translation_base_url/$langcode/add";
Expand Down Expand Up @@ -435,7 +435,7 @@ public function testContactConfigEntityTranslation() {
// While translator can access the translation page, the edit link is not
// present due to lack of permissions.
$this->drupalGet($translation_base_url);
$this->assertNoLink(t('Edit'));
$this->assertSession()->linkNotExists(t('Edit'));

// Check 'Add' link for French.
$this->assertLinkByHref("$translation_base_url/fr/add");
Expand Down Expand Up @@ -516,10 +516,10 @@ public function testAccountSettingsConfigurationTranslation() {
$this->drupalLogin($this->adminUser);

$this->drupalGet('admin/config/people/accounts');
$this->assertLink(t('Translate @type', ['@type' => 'account settings']));
$this->assertSession()->linkExists(t('Translate @type', ['@type' => 'account settings']));

$this->drupalGet('admin/config/people/accounts/translate');
$this->assertLink(t('Translate @type', ['@type' => 'account settings']));
$this->assertSession()->linkExists(t('Translate @type', ['@type' => 'account settings']));
$this->assertLinkByHref('admin/config/people/accounts/translate/fr/add');

// Update account settings fields for French.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function setUp() {
public function testSettingsUI() {
// Check for the content_translation_menu_links_discovered_alter() changes.
$this->drupalGet('admin/config');
$this->assertLink('Content language and translation');
$this->assertSession()->linkExists('Content language and translation');
$this->assertText('Configure language and translation support for content.');
// Test that the translation settings are ignored if the bundle is marked
// translatable but the entity type is not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ public function testWorkflows() {

foreach ($ops as $op => $label) {
if ($op != $current_op) {
$this->assertNoLink($label, new FormattableMarkup('No %op link found.', ['%op' => $label]));
$this->assertSession()->linkNotExists($label, new FormattableMarkup('No %op link found.', ['%op' => $label]));
}
else {
$this->assertLink($label, 0, new FormattableMarkup('%op link found.', ['%op' => $label]));
$this->assertSession()->linkExists($label, 0, new FormattableMarkup('%op link found.', ['%op' => $label]));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/dblog/tests/src/Functional/DbLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function testLogEventPageWithMissingInfo() {

// Verify location is available as plain text.
$this->assertEquals($request_uri, $this->cssSelect('table.dblog-event > tbody > tr:nth-child(4) > td')[0]->getHtml());
$this->assertNoLink($request_uri);
$this->assertSession()->linkNotExists($request_uri);
}

/**
Expand Down Expand Up @@ -782,7 +782,7 @@ protected function getSeverityConstant($class) {
*/
protected function assertLogMessage($log_message, $message) {
$message_text = Unicode::truncate(Html::decodeEntities(strip_tags($log_message)), 56, TRUE, TRUE);
$this->assertLink($message_text, 0, $message);
$this->assertSession()->linkExists($message_text, 0, $message);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function testFieldAdminHandler() {
'field_test_entity_ref_field[0][target_id]' => $node1->getTitle() . ' (' . $node1->id() . ')',
];
$this->drupalPostForm('node/add/' . $this->type, $edit, t('Save'));
$this->assertLink($node1->getTitle());
$this->assertSession()->linkExists($node1->getTitle());

// Tests adding default values to autocomplete widgets.
Vocabulary::create(['vid' => 'tags', 'name' => 'tags'])->save();
Expand Down
6 changes: 3 additions & 3 deletions modules/field/tests/src/Functional/FieldHelpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public function testFieldHelp() {
\Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();

$this->drupalGet('admin/help/field');
$this->assertLink('Options', 0, 'Options module is listed on the Field help page.');
$this->assertSession()->linkExists('Options', 0, 'Options module is listed on the Field help page.');
$this->assertText('Field API Test', 'Modules with field types that do not implement hook_help are listed.');
$this->assertNoLink('Field API Test', 'Modules with field types that do not implement hook_help are not linked.');
$this->assertNoLink('Link', 'Modules that have not been installed, are not listed.');
$this->assertSession()->linkNotExists('Field API Test', 'Modules with field types that do not implement hook_help are not linked.');
$this->assertSession()->linkNotExists('Link', 'Modules that have not been installed, are not listed.');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testEntityViewModeUI() {
$this->assertSession()->statusCodeEquals(404);

$this->drupalGet('admin/structure/display-modes/view/add');
$this->assertNoLink(t('Test entity - revisions and data table'), 'An entity type with no view builder cannot have view modes.');
$this->assertSession()->linkNotExists(t('Test entity - revisions and data table'), 'An entity type with no view builder cannot have view modes.');

// Test adding a view mode including dots in machine_name.
$this->clickLink(t('Test entity'));
Expand Down Expand Up @@ -114,7 +114,7 @@ public function testEntityFormModeUI() {
$this->assertSession()->statusCodeEquals(404);

$this->drupalGet('admin/structure/display-modes/form/add');
$this->assertNoLink(t('Entity Test without label'), 'An entity type with no form cannot have form modes.');
$this->assertSession()->linkNotExists(t('Entity Test without label'), 'An entity type with no form cannot have form modes.');

// Test adding a view mode including dots in machine_name.
$this->clickLink(t('Test entity'));
Expand Down
12 changes: 6 additions & 6 deletions modules/field_ui/tests/src/Functional/FieldUIRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testFieldUIRoutes() {

$edit = ['display_modes_custom[test]' => TRUE];
$this->drupalPostForm('admin/config/people/accounts/display', $edit, t('Save'));
$this->assertLink('Test');
$this->assertSession()->linkExists('Test');

// Create new form mode and verify it's available on the Manage Form
// Display screen after enabling it.
Expand All @@ -100,17 +100,17 @@ public function testFieldUIRoutes() {

$edit = ['display_modes_custom[test]' => TRUE];
$this->drupalPostForm('admin/config/people/accounts/form-display', $edit, t('Save'));
$this->assertLink('Test');
$this->assertSession()->linkExists('Test');
}

/**
* Asserts that local tasks exists.
*/
public function assertLocalTasks() {
$this->assertLink('Settings');
$this->assertLink('Manage fields');
$this->assertLink('Manage display');
$this->assertLink('Manage form display');
$this->assertSession()->linkExists('Settings');
$this->assertSession()->linkExists('Manage fields');
$this->assertSession()->linkExists('Manage display');
$this->assertSession()->linkExists('Manage form display');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions modules/field_ui/tests/src/Functional/ManageDisplayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ public function testViewModeCustom() {
public function testViewModeLocalTasks() {
$manage_display = 'admin/structure/types/manage/' . $this->type . '/display';
$this->drupalGet($manage_display);
$this->assertNoLink('Full content');
$this->assertLink('Teaser');
$this->assertSession()->linkNotExists('Full content');
$this->assertSession()->linkExists('Teaser');

$this->drupalGet($manage_display . '/teaser');
$this->assertNoLink('Full content');
$this->assertLink('Default');
$this->assertSession()->linkNotExists('Full content');
$this->assertSession()->linkExists('Default');
}

/**
Expand Down

0 comments on commit fceb1b7

Please sign in to comment.