diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php index 7ff11b8b..d945bf6e 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php @@ -39,7 +39,7 @@ public function testRSS091Sample() { $this->drupalGet('aggregator/sources/' . $feed->id()); $this->assertSession()->statusCodeEquals(200); $this->assertText('First example feed item title'); - $this->assertLinkByHref('http://example.com/example-turns-one'); + $this->assertSession()->linkByHrefExists('http://example.com/example-turns-one'); $this->assertText('First example feed item description.'); $this->assertRaw('assertRaw("Second example feed item title."); $this->assertText('Long link feed item title'); $this->assertText('Long link feed item description'); - $this->assertLinkByHref('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->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->assertLinkByHref('http://example.com/long/author'); + $this->assertSession()->linkByHrefExists('http://example.com/long/author'); } /** @@ -62,7 +62,7 @@ public function testAtomSample() { $this->drupalGet('aggregator/sources/' . $feed->id()); $this->assertSession()->statusCodeEquals(200); $this->assertText('Atom-Powered Robots Run Amok'); - $this->assertLinkByHref('http://example.org/2003/12/13/atom03'); + $this->assertSession()->linkByHrefExists('http://example.org/2003/12/13/atom03'); $this->assertText('Some text.'); $item_ids = \Drupal::entityQuery('aggregator_item')->condition('link', 'http://example.org/2003/12/13/atom03')->execute(); $item = Item::load(array_values($item_ids)[0]); @@ -70,7 +70,7 @@ public function testAtomSample() { // Check for second feed entry. $this->assertText('We tried to stop them, but we failed.'); - $this->assertLinkByHref('http://example.org/2003/12/14/atom03'); + $this->assertSession()->linkByHrefExists('http://example.org/2003/12/14/atom03'); $this->assertText('Some other text.'); $item_ids = \Drupal::entityQuery('aggregator_item')->condition('link', 'http://example.org/2003/12/14/atom03')->execute(); $item = Item::load(array_values($item_ids)[0]); diff --git a/core/modules/block/tests/src/Functional/BlockDemoTest.php b/core/modules/block/tests/src/Functional/BlockDemoTest.php index 167c172b..dbae1da6 100644 --- a/core/modules/block/tests/src/Functional/BlockDemoTest.php +++ b/core/modules/block/tests/src/Functional/BlockDemoTest.php @@ -39,8 +39,8 @@ public function testBlockDemo() { $default_theme = $config->get('default'); $this->drupalGet('admin/structure/block/demo/' . $default_theme); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('admin/structure/block'); - $this->assertNoLinkByHref('admin/structure/block/list/' . $default_theme); + $this->assertSession()->linkByHrefExists('admin/structure/block'); + $this->assertSession()->linkByHrefNotExists('admin/structure/block/list/' . $default_theme); // All available themes in core. $available_themes = [ @@ -60,7 +60,7 @@ public function testBlockDemo() { $this->drupalGet('admin/structure/block/demo/' . $theme); $this->assertSession()->statusCodeEquals(200); // Confirm existence of link for "Exit block region demonstration". - $this->assertLinkByHref('admin/structure/block/list/' . $theme); + $this->assertSession()->linkByHrefExists('admin/structure/block/list/' . $theme); } // Confirm access to the block demo page is denied for an invalid theme. diff --git a/core/modules/block/tests/src/Functional/BlockHookOperationTest.php b/core/modules/block/tests/src/Functional/BlockHookOperationTest.php index 0770191e..e66c8924 100644 --- a/core/modules/block/tests/src/Functional/BlockHookOperationTest.php +++ b/core/modules/block/tests/src/Functional/BlockHookOperationTest.php @@ -49,7 +49,7 @@ public function testBlockOperationAlter() { $test_operation_link = 'admin/structure/block/manage/' . $block_id . '/test_operation'; // Test if the test_operation link is on the page. - $this->assertLinkByHref($test_operation_link); + $this->assertSession()->linkByHrefExists($test_operation_link); } } diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php index 6c4c1dc5..ea5d2a14 100644 --- a/core/modules/block/tests/src/Functional/BlockTest.php +++ b/core/modules/block/tests/src/Functional/BlockTest.php @@ -481,7 +481,7 @@ public function testThemeAdminLink() { $this->drupalLogin($theme_admin); $this->drupalGet('admin/appearance'); $this->assertText('You can place blocks for each theme on the block layout page'); - $this->assertLinkByHref('admin/structure/block'); + $this->assertSession()->linkByHrefExists('admin/structure/block'); } /** diff --git a/core/modules/block_content/tests/src/Functional/BlockContentListTest.php b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php index 9dbac7ed..695987ad 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentListTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php @@ -85,7 +85,7 @@ public function testListing() { ->loadByProperties(['info' => $label]); $block = reset($blocks); if (!empty($block)) { - $this->assertLinkByHref('block/' . $block->id()); + $this->assertSession()->linkByHrefExists('block/' . $block->id()); $this->clickLink(t('Edit')); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->titleEquals("Edit custom block $label | Drupal"); @@ -101,7 +101,7 @@ public function testListing() { $this->assertFieldByXpath('//td', $new_label, 'Label found for updated custom block.'); // Delete the added entity using the operations link. - $this->assertLinkByHref('block/' . $block->id() . '/delete'); + $this->assertSession()->linkByHrefExists('block/' . $block->id() . '/delete'); $delete_text = t('Delete'); $this->clickLink($delete_text); $this->assertSession()->statusCodeEquals(200); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php b/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php index af00942a..13452491 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php @@ -97,7 +97,7 @@ public function testListing() { ->loadByProperties(['info' => $label]); $block = reset($blocks); if (!empty($block)) { - $this->assertLinkByHref('block/' . $block->id()); + $this->assertSession()->linkByHrefExists('block/' . $block->id()); $this->clickLink(t('Edit')); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->titleEquals("Edit custom block $label | Drupal"); @@ -113,7 +113,7 @@ public function testListing() { $this->assertFieldByXpath('//td/a', $new_label, 'Label found for updated custom block.'); // Delete the added entity using the operations link. - $this->assertLinkByHref('block/' . $block->id() . '/delete'); + $this->assertSession()->linkByHrefExists('block/' . $block->id() . '/delete'); $delete_text = t('Delete'); $this->clickLink($delete_text); $this->assertSession()->statusCodeEquals(200); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php index 9de7f8f9..3d765ac9 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php @@ -126,7 +126,7 @@ protected function doTestBasicTranslation() { // Check that the translate operation link is shown. $this->drupalGet('admin/structure/block/block-content'); - $this->assertLinkByHref('block/' . $entity->id() . '/translations'); + $this->assertSession()->linkByHrefExists('block/' . $entity->id() . '/translations'); } /** diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php index d166188f..ad51cc52 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php @@ -215,7 +215,7 @@ public function testsBlockContentAddTypes() { // The seven theme has markup inside the link, we cannot use clickLink(). if ($default_theme == 'seven') { $options = $theme != $default_theme ? ['query' => ['theme' => $theme]] : []; - $this->assertLinkByHref(Url::fromRoute('block_content.add_form', ['block_content_type' => 'foo'], $options)->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('block_content.add_form', ['block_content_type' => 'foo'], $options)->toString()); $this->drupalGet('block/add/foo', $options); } else { diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php index f0fbe3bd..62cc571b 100644 --- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php @@ -272,7 +272,7 @@ public function testCommentFunctionality() { // Test that default field exists. $this->drupalGet('entity_test/structure/entity_test/fields'); $this->assertText(t('Comments')); - $this->assertLinkByHref('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); + $this->assertSession()->linkByHrefExists('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); // Test widget hidden option is not visible when there's no comments. $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); $this->assertSession()->statusCodeEquals(200); diff --git a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php index 99772080..6fcbb138 100644 --- a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php +++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php @@ -207,8 +207,8 @@ public function testTranslateLinkCommentAdminPage() { // Verify translation links. $this->drupalGet('admin/content/comment'); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('comment/' . $cid_translatable . '/translations'); - $this->assertNoLinkByHref('comment/' . $cid_untranslatable . '/translations'); + $this->assertSession()->linkByHrefExists('comment/' . $cid_translatable . '/translations'); + $this->assertSession()->linkByHrefNotExists('comment/' . $cid_untranslatable . '/translations'); } /** diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php index 9e5bdfa3..0fe1c35f 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php @@ -48,7 +48,7 @@ public function testListUI() { // Get the list page. $this->drupalGet('admin/structure/config_test'); - $this->assertLinkByHref('admin/structure/config_test/manage/dotted.default'); + $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/dotted.default'); // Add a new entity using the action link. $this->clickLink('Add test configuration'); @@ -59,13 +59,13 @@ public function testListUI() { ]; $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that operations for editing the Hungarian entity appear in English. - $this->assertLinkByHref('admin/structure/config_test/manage/antilop'); + $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/antilop'); // Get the list page in Hungarian and assert Hungarian admin links // regardless of language of config entities. $this->drupalGet('hu/admin/structure/config_test'); - $this->assertLinkByHref('hu/admin/structure/config_test/manage/dotted.default'); - $this->assertLinkByHref('hu/admin/structure/config_test/manage/antilop'); + $this->assertSession()->linkByHrefExists('hu/admin/structure/config_test/manage/dotted.default'); + $this->assertSession()->linkByHrefExists('hu/admin/structure/config_test/manage/antilop'); } } diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php index 91860e4d..c4911834 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php @@ -213,7 +213,7 @@ public function testListUI() { $this->assertFieldByXpath('//td', 'antelope', "Machine name found for added 'Antelope' entity."); // Edit the entity using the operations link. - $this->assertLinkByHref('admin/structure/config_test/manage/antelope'); + $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/antelope'); $this->clickLink('Edit', 1); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->titleEquals('Edit Antelope | Drupal'); @@ -227,7 +227,7 @@ public function testListUI() { $this->assertFieldByXpath('//td', 'albatross', "Machine name found for updated 'Albatross' entity."); // Delete the added entity using the operations link. - $this->assertLinkByHref('admin/structure/config_test/manage/albatross/delete'); + $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/albatross/delete'); $this->clickLink('Delete', 1); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->titleEquals('Are you sure you want to delete the test configuration Albatross? | Drupal'); diff --git a/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php b/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php index 30c71f1e..57e5abd8 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php @@ -42,17 +42,17 @@ public function testCRUD() { // Disable an entity. $disable_url = $entity->toUrl('disable'); - $this->assertLinkByHref($disable_url->toString()); + $this->assertSession()->linkByHrefExists($disable_url->toString()); $this->drupalGet($disable_url); $this->assertSession()->statusCodeEquals(200); - $this->assertNoLinkByHref($disable_url->toString()); + $this->assertSession()->linkByHrefNotExists($disable_url->toString()); // Enable an entity. $enable_url = $entity->toUrl('enable'); - $this->assertLinkByHref($enable_url->toString()); + $this->assertSession()->linkByHrefExists($enable_url->toString()); $this->drupalGet($enable_url); $this->assertSession()->statusCodeEquals(200); - $this->assertNoLinkByHref($enable_url->toString()); + $this->assertSession()->linkByHrefNotExists($enable_url->toString()); } } diff --git a/core/modules/config/tests/src/Functional/ConfigEntityTest.php b/core/modules/config/tests/src/Functional/ConfigEntityTest.php index 6ba24672..c51e41c9 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityTest.php @@ -248,7 +248,7 @@ public function testCRUDUI() { $this->assertSession()->statusCodeEquals(200); $this->assertRaw($message_insert); $this->assertNoRaw($message_update); - $this->assertLinkByHref("admin/structure/config_test/manage/$id"); + $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id"); // Update the configuration entity. $edit = [ @@ -259,8 +259,8 @@ public function testCRUDUI() { $this->assertSession()->statusCodeEquals(200); $this->assertNoRaw($message_insert); $this->assertRaw($message_update); - $this->assertLinkByHref("admin/structure/config_test/manage/$id"); - $this->assertLinkByHref("admin/structure/config_test/manage/$id/delete"); + $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id"); + $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id/delete"); // Delete the configuration entity. $this->drupalGet("admin/structure/config_test/manage/$id"); @@ -272,7 +272,7 @@ public function testCRUDUI() { $this->assertNoRaw($message_update); $this->assertRaw($message_delete); $this->assertNoText($label1); - $this->assertNoLinkByHref("admin/structure/config_test/manage/$id"); + $this->assertSession()->linkByHrefNotExists("admin/structure/config_test/manage/$id"); // Re-create a configuration entity. $edit = [ @@ -283,7 +283,7 @@ public function testCRUDUI() { $this->assertUrl('admin/structure/config_test'); $this->assertSession()->statusCodeEquals(200); $this->assertText($label1); - $this->assertLinkByHref("admin/structure/config_test/manage/$id"); + $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id"); // Rename the configuration entity's ID/machine name. $edit = [ @@ -296,9 +296,9 @@ public function testCRUDUI() { $this->assertNoText($label1); $this->assertNoText($label2); $this->assertText($label3); - $this->assertNoLinkByHref("admin/structure/config_test/manage/$id"); + $this->assertSession()->linkByHrefNotExists("admin/structure/config_test/manage/$id"); $id = $edit['id']; - $this->assertLinkByHref("admin/structure/config_test/manage/$id"); + $this->assertSession()->linkByHrefExists("admin/structure/config_test/manage/$id"); // Create a configuration entity with '0' machine name. $edit = [ @@ -309,8 +309,8 @@ public function testCRUDUI() { $this->assertSession()->statusCodeEquals(200); $message_insert = new FormattableMarkup('%label configuration has been created.', ['%label' => $edit['label']]); $this->assertRaw($message_insert); - $this->assertLinkByHref('admin/structure/config_test/manage/0'); - $this->assertLinkByHref('admin/structure/config_test/manage/0/delete'); + $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/0'); + $this->assertSession()->linkByHrefExists('admin/structure/config_test/manage/0/delete'); $this->drupalPostForm('admin/structure/config_test/manage/0/delete', [], 'Delete'); $storage = \Drupal::entityTypeManager()->getStorage('config_test'); $this->assertNull($storage->load(0), 'Test entity deleted'); diff --git a/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php b/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php index b2f19e57..01d02e7a 100644 --- a/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigExportImportUITest.php @@ -282,17 +282,17 @@ public function testExportImportCollections() { $this->assertText(t('@collection configuration collection', ['@collection' => 'collection.test1'])); $this->assertText(t('@collection configuration collection', ['@collection' => 'collection.test2'])); $this->assertText('config_test.create'); - $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.create'); + $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.create'); $this->assertText('config_test.update'); - $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.update'); + $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.update'); $this->assertText('config_test.delete'); - $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.delete'); + $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.delete'); $this->assertText('config_test.another_create'); - $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_create'); + $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_create'); $this->assertText('config_test.another_update'); - $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_update'); + $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_update'); $this->assertText('config_test.another_delete'); - $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_delete'); + $this->assertSession()->linkByHrefExists('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_delete'); $this->drupalPostForm(NULL, [], 'Import all'); $this->assertText(t('There are no configuration changes to import.')); diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php index fbc2bd47..be4d46da 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php @@ -46,10 +46,10 @@ public function testDateFormatUI() { $this->drupalGet('admin/config/regional/date-time'); // Assert translation link unlocked date format. - $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium/translate'); + $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/medium/translate'); // Assert translation link locked date format. - $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_datetime/translate'); + $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/html_datetime/translate'); // Date pattern is visible on unlocked date formats. $this->drupalGet('admin/config/regional/date-time/formats/manage/medium/translate/de/add'); diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php index 8de59f80..edb5fc2f 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php @@ -106,7 +106,7 @@ protected function doBlockListTest() { $translate_link = 'admin/structure/block/manage/' . $id . '/translate'; // Test if the link to translate the block is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -136,7 +136,7 @@ protected function doMenuListTest() { $translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate'; // Test if the link to translate the menu is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Check if the Link is not added if you are missing 'translate // configuration' permission. @@ -150,7 +150,7 @@ protected function doMenuListTest() { $translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate'; // Test if the link to translate the menu is NOT on the page. - $this->assertNoLinkByHref($translate_link); + $this->assertSession()->linkByHrefNotExists($translate_link); // Log in as Admin again otherwise the rest will fail. $this->drupalLogin($this->adminUser); @@ -178,7 +178,7 @@ protected function doVocabularyListTest() { $translate_link = 'admin/structure/taxonomy/manage/' . $vocabulary->id() . '/translate'; // Test if the link to translate the vocabulary is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -203,7 +203,7 @@ public function doCustomContentTypeListTest() { $translate_link = 'admin/structure/block/block-content/manage/' . $block_content_type->id() . '/translate'; // Test if the link to translate the custom block type is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -227,7 +227,7 @@ public function doContactFormsListTest() { $translate_link = 'admin/structure/contact/manage/' . $contact_form->id() . '/translate'; // Test if the link to translate the contact form is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -250,7 +250,7 @@ public function doContentTypeListTest() { $translate_link = 'admin/structure/types/manage/' . $content_type->id() . '/translate'; // Test if the link to translate the content type is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -274,7 +274,7 @@ public function doFormatsListTest() { $translate_link = 'admin/config/content/formats/manage/' . $filter_format->id() . '/translate'; // Test if the link to translate the format is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -298,7 +298,7 @@ public function doShortcutListTest() { $translate_link = 'admin/config/user-interface/shortcut/manage/' . $shortcut->id() . '/translate'; // Test if the link to translate the shortcut is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -319,7 +319,7 @@ public function doUserRoleListTest() { $translate_link = 'admin/people/roles/manage/' . $role_id . '/translate'; // Test if the link to translate the role is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -339,7 +339,7 @@ public function doLanguageListTest() { $translate_link = 'admin/config/regional/language/edit/ga/translate'; // Test if the link to translate the language is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -355,7 +355,7 @@ public function doImageStyleListTest() { $translate_link = 'admin/config/media/image-styles/manage/medium/translate'; // Test if the link to translate the style is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -379,7 +379,7 @@ public function doResponsiveImageListTest() { $translate_link = 'admin/config/media/responsive-image-style/' . $edit['id'] . '/translate'; // Test if the link to translate the style is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -431,7 +431,7 @@ public function doFieldListTest() { $translate_link = $values['list'] . '/' . $values['field'] . '/translate'; // Test if the link to translate the field is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -448,7 +448,7 @@ public function doDateFormatListTest() { $translate_link = 'admin/config/regional/date-time/formats/manage/long/translate'; // Test if the link to translate the format is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); @@ -467,7 +467,7 @@ public function doSettingsPageTest($link) { $translate_link = $link . '/translate'; // Test if the link to translate the settings page is present. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php index 00d5bc3d..e77b8c77 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php @@ -82,8 +82,8 @@ protected function setUp(): void { */ public function testMapperListPage() { $this->drupalGet('admin/config/regional/config-translation'); - $this->assertLinkByHref('admin/config/regional/config-translation/config_test'); - $this->assertLinkByHref('admin/config/people/accounts/translate'); + $this->assertSession()->linkByHrefExists('admin/config/regional/config-translation/config_test'); + $this->assertSession()->linkByHrefExists('admin/config/people/accounts/translate'); // Make sure there is only a single operation for each dropbutton, either // 'List' or 'Translate'. foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) { @@ -107,7 +107,7 @@ public function testMapperListPage() { $base_url = 'admin/structure/config_test/manage/' . $test_entity->id(); $this->drupalGet('admin/config/regional/config-translation/config_test'); - $this->assertLinkByHref($base_url . '/translate'); + $this->assertSession()->linkByHrefExists($base_url . '/translate'); $this->assertSession()->assertEscaped($test_entity->label()); // Make sure there is only a single 'Translate' operation for each @@ -138,17 +138,17 @@ public function testHiddenEntities() { // configuration translation listings. $this->drupalGet('admin/config/regional/config-translation/configurable_language'); $this->assertText('Not applicable'); - $this->assertLinkByHref('admin/config/regional/language/edit/zxx/translate'); + $this->assertSession()->linkByHrefExists('admin/config/regional/language/edit/zxx/translate'); $this->assertText('Not specified'); - $this->assertLinkByHref('admin/config/regional/language/edit/und/translate'); + $this->assertSession()->linkByHrefExists('admin/config/regional/language/edit/und/translate'); // Hidden date formats are only available to translate through the // configuration translation listings. Test a couple of them. $this->drupalGet('admin/config/regional/config-translation/date_format'); $this->assertText('HTML Date'); - $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_date/translate'); + $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/html_date/translate'); $this->assertText('HTML Year'); - $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_year/translate'); + $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/html_year/translate'); } /** @@ -200,7 +200,7 @@ public function testListingFieldsPage() { $this->drupalGet('admin/config/regional/config-translation/node_fields'); $this->assertText('Body'); $this->assertText('Basic'); - $this->assertLinkByHref('admin/structure/types/manage/basic/fields/node.basic.body/translate'); + $this->assertSession()->linkByHrefExists('admin/structure/types/manage/basic/fields/node.basic.body/translate'); } } diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php index ca687db5..2e9fb987 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php @@ -145,7 +145,7 @@ public function testSiteInformationTranslationUi() { $this->drupalGet('admin/config/system/site-information'); // Check translation tab exist. - $this->assertLinkByHref($translation_base_url); + $this->assertSession()->linkByHrefExists($translation_base_url); $this->drupalGet($translation_base_url); @@ -157,7 +157,7 @@ public function testSiteInformationTranslationUi() { $this->assertUrl($translation_base_url); // Check 'Add' link of French to visit add page. - $this->assertLinkByHref("$translation_base_url/fr/add"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/add"); $this->clickLink(t('Add')); // Make sure original text is present on this page. @@ -174,9 +174,9 @@ public function testSiteInformationTranslationUi() { $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French'])); // Check for edit, delete links (and no 'add' link) for French language. - $this->assertNoLinkByHref("$translation_base_url/fr/add"); - $this->assertLinkByHref("$translation_base_url/fr/edit"); - $this->assertLinkByHref("$translation_base_url/fr/delete"); + $this->assertSession()->linkByHrefNotExists("$translation_base_url/fr/add"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/edit"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/delete"); // Check translation saved proper. $this->drupalGet("$translation_base_url/fr/edit"); @@ -302,7 +302,7 @@ public function testSourceValueDuplicateSave() { $this->assertSession()->linkNotExists('Edit'); // Check 'Add' link for French. - $this->assertLinkByHref("$translation_base_url/fr/add"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/add"); } /** @@ -314,7 +314,7 @@ public function testContactConfigEntityTranslation() { $this->drupalGet('admin/structure/contact'); // Check for default contact form configuration entity from Contact module. - $this->assertLinkByHref('admin/structure/contact/manage/feedback'); + $this->assertSession()->linkByHrefExists('admin/structure/contact/manage/feedback'); // Save default language configuration. $label = 'Send your feedback'; @@ -327,7 +327,7 @@ public function testContactConfigEntityTranslation() { // Ensure translation link is present. $translation_base_url = 'admin/structure/contact/manage/feedback/translate'; - $this->assertLinkByHref($translation_base_url); + $this->assertSession()->linkByHrefExists($translation_base_url); // Make sure translate tab is present. $this->drupalGet('admin/structure/contact/manage/feedback'); @@ -343,7 +343,7 @@ public function testContactConfigEntityTranslation() { // 'Add' link should be present for $langcode translation. $translation_page_url = "$translation_base_url/$langcode/add"; - $this->assertLinkByHref($translation_page_url); + $this->assertSession()->linkByHrefExists($translation_page_url); // Make sure original text is present on this page. $this->drupalGet($translation_page_url); @@ -367,9 +367,9 @@ public function testContactConfigEntityTranslation() { $this->assertEqual($expected, $override->get()); // Check for edit, delete links (and no 'add' link) for $langcode. - $this->assertNoLinkByHref("$translation_base_url/$langcode/add"); - $this->assertLinkByHref("$translation_base_url/$langcode/edit"); - $this->assertLinkByHref("$translation_base_url/$langcode/delete"); + $this->assertSession()->linkByHrefNotExists("$translation_base_url/$langcode/add"); + $this->assertSession()->linkByHrefExists("$translation_base_url/$langcode/edit"); + $this->assertSession()->linkByHrefExists("$translation_base_url/$langcode/delete"); // Visit language specific version of form to check label. $this->drupalGet($langcode . '/contact/feedback'); @@ -413,13 +413,13 @@ public function testContactConfigEntityTranslation() { $this->drupalGet("$translation_base_url/$langcode/delete"); $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements)); // Assert link back to list page to cancel delete is present. - $this->assertLinkByHref($translation_base_url); + $this->assertSession()->linkByHrefExists($translation_base_url); $this->drupalPostForm(NULL, [], t('Delete')); $this->assertRaw(t('@language translation of %label was deleted', $replacements)); - $this->assertLinkByHref("$translation_base_url/$langcode/add"); - $this->assertNoLinkByHref("translation_base_url/$langcode/edit"); - $this->assertNoLinkByHref("$translation_base_url/$langcode/delete"); + $this->assertSession()->linkByHrefExists("$translation_base_url/$langcode/add"); + $this->assertSession()->linkByHrefNotExists("translation_base_url/$langcode/edit"); + $this->assertSession()->linkByHrefNotExists("$translation_base_url/$langcode/delete"); // Expect no language specific file present anymore. $override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.form.feedback'); @@ -438,7 +438,7 @@ public function testContactConfigEntityTranslation() { $this->assertSession()->linkNotExists('Edit'); // Check 'Add' link for French. - $this->assertLinkByHref("$translation_base_url/fr/add"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/add"); } /** @@ -450,7 +450,7 @@ public function testDateFormatTranslation() { $this->drupalGet('admin/config/regional/date-time'); // Check for medium format. - $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium'); + $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/medium'); // Save default language configuration for a new format. $edit = [ @@ -472,7 +472,7 @@ public function testDateFormatTranslation() { // 'Add' link should be present for French translation. $translation_page_url = "$translation_base_url/fr/add"; - $this->assertLinkByHref($translation_page_url); + $this->assertSession()->linkByHrefExists($translation_page_url); // Make sure original text is present on this page. $this->drupalGet($translation_page_url); @@ -520,7 +520,7 @@ public function testAccountSettingsConfigurationTranslation() { $this->drupalGet('admin/config/people/accounts/translate'); $this->assertSession()->linkExists('Translate account settings'); - $this->assertLinkByHref('admin/config/people/accounts/translate/fr/add'); + $this->assertSession()->linkByHrefExists('admin/config/people/accounts/translate/fr/add'); // Update account settings fields for French. $edit = [ @@ -558,10 +558,10 @@ public function testSourceAndTargetLanguage() { // make sure source language edit goes to original configuration page // not the translation specific edit page. $this->drupalGet('admin/config/system/site-information/translate'); - $this->assertNoLinkByHref('admin/config/system/site-information/translate/en/edit'); - $this->assertNoLinkByHref('admin/config/system/site-information/translate/en/add'); - $this->assertNoLinkByHref('admin/config/system/site-information/translate/en/delete'); - $this->assertLinkByHref('admin/config/system/site-information'); + $this->assertSession()->linkByHrefNotExists('admin/config/system/site-information/translate/en/edit'); + $this->assertSession()->linkByHrefNotExists('admin/config/system/site-information/translate/en/add'); + $this->assertSession()->linkByHrefNotExists('admin/config/system/site-information/translate/en/delete'); + $this->assertSession()->linkByHrefExists('admin/config/system/site-information'); // Translation addition to source language should return 403. $this->drupalGet('admin/config/system/site-information/translate/en/add'); @@ -582,7 +582,7 @@ public function testSourceAndTargetLanguage() { // Make sure translation tab does not exist on the configuration page. $this->drupalGet('admin/config/system/site-information'); - $this->assertNoLinkByHref('admin/config/system/site-information/translate'); + $this->assertSession()->linkByHrefNotExists('admin/config/system/site-information/translate'); // If source language is not specified, translation page should be 403. $this->drupalGet('admin/config/system/site-information/translate'); @@ -604,7 +604,7 @@ public function testViewsTranslationUI() { $this->drupalGet($translation_base_url); // Check 'Add' link of French to visit add page. - $this->assertLinkByHref("$translation_base_url/fr/add"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/add"); $this->clickLink(t('Add')); // Make sure original text is present on this page. @@ -622,9 +622,9 @@ public function testViewsTranslationUI() { $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French'])); // Check for edit, delete links (and no 'add' link) for French language. - $this->assertNoLinkByHref("$translation_base_url/fr/add"); - $this->assertLinkByHref("$translation_base_url/fr/edit"); - $this->assertLinkByHref("$translation_base_url/fr/delete"); + $this->assertSession()->linkByHrefNotExists("$translation_base_url/fr/add"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/edit"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/delete"); // Check translation saved proper. $this->drupalGet("$translation_base_url/fr/edit"); @@ -963,7 +963,7 @@ public function testTextFormatTranslation() { // 'Add' link should be present for French translation. $translation_page_url = "$translation_base_url/fr/add"; - $this->assertLinkByHref($translation_page_url); + $this->assertSession()->linkByHrefExists($translation_page_url); $this->drupalGet($translation_page_url); diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php index f338ca8e..69b20f1c 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php @@ -78,7 +78,7 @@ public function testThemeDiscovery() { $translation_base_url = 'admin/config/development/performance/translate'; $this->drupalGet($translation_base_url); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref("$translation_base_url/fr/add"); + $this->assertSession()->linkByHrefExists("$translation_base_url/fr/add"); } } diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php index 50e169f0..88fb7f56 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php @@ -50,14 +50,14 @@ public function testTranslateOperationInViewListUi() { $this->drupalGet('admin/structure/views'); $translate_link = 'admin/structure/views/view/test_view/translate'; // Test if the link to translate the test_view is on the page. - $this->assertLinkByHref($translate_link); + $this->assertSession()->linkByHrefExists($translate_link); // Test if the link to translate actually goes to the translate page. $this->drupalGet($translate_link); $this->assertRaw('' . t('Language') . ''); // Test that the 'Edit' tab appears. - $this->assertLinkByHref('admin/structure/views/view/test_view'); + $this->assertSession()->linkByHrefExists('admin/structure/views/view/test_view'); } } diff --git a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php index 8d517813..291f7c95 100644 --- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php +++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php @@ -152,7 +152,7 @@ public function testPersonalContactAccess() { $this->drupalGet('user/' . $this->contactUser->id()); $contact_link = '/user/' . $this->contactUser->id() . '/contact'; $this->assertSession()->statusCodeEquals(200); - $this->assertNoLinkByHref($contact_link, 'The "contact" tab is hidden on profiles for users with no email address'); + $this->assertSession()->linkByHrefNotExists($contact_link, 'The "contact" tab is hidden on profiles for users with no email address'); // Restore original email address. $this->contactUser->setEmail($original_email)->save(); diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php index f40f3332..7b420e70 100644 --- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php +++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php @@ -111,7 +111,7 @@ public function testSiteWideContact() { $this->drupalGet('admin/structure/contact'); // Default form exists. - $this->assertLinkByHref('admin/structure/contact/manage/feedback/delete'); + $this->assertSession()->linkByHrefExists('admin/structure/contact/manage/feedback/delete'); // User form could not be changed or deleted. // Cannot use ::assertNoLinkByHref as it does partial url matching and with // field_ui enabled admin/structure/contact/manage/personal/fields exists. @@ -122,7 +122,7 @@ public function testSiteWideContact() { $this->assertTrue(empty($edit_link), new FormattableMarkup('No link containing href %href found.', ['%href' => 'admin/structure/contact/manage/personal'] )); - $this->assertNoLinkByHref('admin/structure/contact/manage/personal/delete'); + $this->assertSession()->linkByHrefNotExists('admin/structure/contact/manage/personal/delete'); $this->drupalGet('admin/structure/contact/manage/personal'); $this->assertSession()->statusCodeEquals(403); @@ -131,7 +131,7 @@ public function testSiteWideContact() { $this->deleteContactForms(); $this->drupalGet('admin/structure/contact'); $this->assertText('Personal', 'Personal form was not deleted'); - $this->assertNoLinkByHref('admin/structure/contact/manage/feedback'); + $this->assertSession()->linkByHrefNotExists('admin/structure/contact/manage/feedback'); // Ensure that the contact form won't be shown without forms. user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php index 5c4b70a4..44c714dd 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php @@ -89,7 +89,7 @@ public function testEnablingOnExistingContent() { $node = reset($nodes); $this->drupalGet('node/' . $node->id()); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('node/' . $node->id() . '/edit'); + $this->assertSession()->linkByHrefExists('node/' . $node->id() . '/edit'); $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->optionExists('moderation_state[0][state]', 'draft'); diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php index fc0433eb..82562d94 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php @@ -136,7 +136,7 @@ protected function createContentTypeFromUi($content_type_name, $content_type_id, */ public function enableModerationThroughUi($content_type_id, $workflow_id = 'editorial') { $this->drupalGet('/admin/config/workflow/workflows'); - $this->assertLinkByHref('admin/config/workflow/workflows/manage/' . $workflow_id); + $this->assertSession()->linkByHrefExists('admin/config/workflow/workflows/manage/' . $workflow_id); $edit['bundles[' . $content_type_id . ']'] = TRUE; $this->drupalPostForm('admin/config/workflow/workflows/manage/' . $workflow_id . '/type/node', $edit, t('Save')); // Ensure the parent environment is up-to-date. diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php index 5bc5c703..94de9378 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php @@ -79,13 +79,13 @@ public function testOperationTranslateLink() { // permission. $this->drupalLogin($this->baseUser1); $this->drupalGet('admin/content'); - $this->assertNoLinkByHref('node/' . $node->id() . '/translations'); + $this->assertSession()->linkByHrefNotExists('node/' . $node->id() . '/translations'); $this->drupalLogout(); // Verify there's a translation operation link for users with enough // permissions. $this->drupalLogin($this->baseUser2); $this->drupalGet('admin/content'); - $this->assertLinkByHref('node/' . $node->id() . '/translations'); + $this->assertSession()->linkByHrefExists('node/' . $node->id() . '/translations'); // Ensure that an unintended misconfiguration of permissions does not open // access to the translation form, see https://www.drupal.org/node/2558905. @@ -128,10 +128,10 @@ public function testOperationTranslateLink() { $this->drupalPlaceBlock('local_tasks_block'); $this->drupalLogin($this->baseUser2); $this->drupalGet('node/' . $node->id()); - $this->assertLinkByHref('node/' . $node->id() . '/translations'); + $this->assertSession()->linkByHrefExists('node/' . $node->id() . '/translations'); $this->drupalPostForm('admin/config/regional/content-language', ['settings[node][article][translatable]' => FALSE], t('Save configuration')); $this->drupalGet('node/' . $node->id()); - $this->assertNoLinkByHref('node/' . $node->id() . '/translations'); + $this->assertSession()->linkByHrefNotExists('node/' . $node->id() . '/translations'); } /** diff --git a/core/modules/content_translation/tests/src/Functional/Views/TranslationLinkTest.php b/core/modules/content_translation/tests/src/Functional/Views/TranslationLinkTest.php index 274a65b6..f8b76af2 100644 --- a/core/modules/content_translation/tests/src/Functional/Views/TranslationLinkTest.php +++ b/core/modules/content_translation/tests/src/Functional/Views/TranslationLinkTest.php @@ -67,8 +67,8 @@ protected function getTranslatorPermissions() { */ public function testTranslationLink() { $this->drupalGet('test-entity-translations-link'); - $this->assertLinkByHref('user/1/translations'); - $this->assertNoLinkByHref('user/2/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.'); + $this->assertSession()->linkByHrefExists('user/1/translations'); + $this->assertSession()->linkByHrefNotExists('user/2/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.'); } } diff --git a/core/modules/dblog/tests/src/Functional/DbLogTest.php b/core/modules/dblog/tests/src/Functional/DbLogTest.php index bda74010..33eec9c6 100644 --- a/core/modules/dblog/tests/src/Functional/DbLogTest.php +++ b/core/modules/dblog/tests/src/Functional/DbLogTest.php @@ -129,8 +129,8 @@ public function testLogEventPage() { // Verify the links appear correctly. $this->drupalGet('admin/reports/dblog/event/' . $wid); - $this->assertLinkByHref($context['request_uri']); - $this->assertLinkByHref($context['referer']); + $this->assertSession()->linkByHrefExists($context['request_uri']); + $this->assertSession()->linkByHrefExists($context['referer']); // Verify hostname. $this->assertRaw($context['ip'], 'Found hostname on the detail page.'); diff --git a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php index 1c7be085..f9317e34 100644 --- a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php +++ b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php @@ -53,8 +53,8 @@ public function testEntityViewModeUI() { $this->drupalGet('admin/structure/display-modes/view'); $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Add view mode')); - $this->assertLinkByHref('admin/structure/display-modes/view/add'); - $this->assertLinkByHref('admin/structure/display-modes/view/add/entity_test'); + $this->assertSession()->linkByHrefExists('admin/structure/display-modes/view/add'); + $this->assertSession()->linkByHrefExists('admin/structure/display-modes/view/add/entity_test'); $this->drupalGet('admin/structure/display-modes/view/add/entity_test_mulrev'); $this->assertSession()->statusCodeEquals(404); @@ -108,7 +108,7 @@ public function testEntityFormModeUI() { $this->drupalGet('admin/structure/display-modes/form'); $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Add form mode')); - $this->assertLinkByHref('admin/structure/display-modes/form/add'); + $this->assertSession()->linkByHrefExists('admin/structure/display-modes/form/add'); $this->drupalGet('admin/structure/display-modes/form/add/entity_test_no_label'); $this->assertSession()->statusCodeEquals(404); diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php index 07a6222e..8aec455a 100644 --- a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php @@ -292,9 +292,9 @@ public function cardinalitySettings() { // Check that tabs displayed. $this->assertSession()->linkExists('Edit'); - $this->assertLinkByHref('admin/structure/types/manage/article/fields/node.article.body'); + $this->assertSession()->linkByHrefExists('admin/structure/types/manage/article/fields/node.article.body'); $this->assertSession()->linkExists('Field settings'); - $this->assertLinkByHref($field_edit_path); + $this->assertSession()->linkByHrefExists($field_edit_path); // Add two entries in the body. $edit = ['title[0][value]' => 'Cardinality', 'body[0][value]' => 'Body 1', 'body[1][value]' => 'Body 2']; @@ -754,7 +754,7 @@ public function testHelpDescriptions() { public function fieldListAdminPage() { $this->drupalGet('admin/reports/fields'); $this->assertText($this->fieldName, 'Field name is displayed in field list.'); - $this->assertLinkByHref('admin/structure/types/manage/' . $this->contentType . '/fields'); + $this->assertSession()->linkByHrefExists('admin/structure/types/manage/' . $this->contentType . '/fields'); } /** diff --git a/core/modules/file/tests/src/Functional/FileListingTest.php b/core/modules/file/tests/src/Functional/FileListingTest.php index 04eac5d4..4a9a4f33 100644 --- a/core/modules/file/tests/src/Functional/FileListingTest.php +++ b/core/modules/file/tests/src/Functional/FileListingTest.php @@ -116,8 +116,8 @@ public function testFileListingPages() { foreach ($nodes as $node) { $file = File::load($node->file->target_id); $this->assertText($file->getFilename()); - $this->assertLinkByHref(file_create_url($file->getFileUri())); - $this->assertLinkByHref('admin/content/files/usage/' . $file->id()); + $this->assertSession()->linkByHrefExists(file_create_url($file->getFileUri())); + $this->assertSession()->linkByHrefExists('admin/content/files/usage/' . $file->id()); } $this->assertSession()->elementTextNotContains('css', 'table.views-table', 'Temporary'); $this->assertSession()->elementTextContains('css', 'table.views-table', 'Permanent'); @@ -156,7 +156,7 @@ public function testFileListingPages() { } } } - $this->assertLinkByHref('node/' . $node->id(), 0, 'Link to registering entity found on usage page.'); + $this->assertSession()->linkByHrefExists('node/' . $node->id(), 0, 'Link to registering entity found on usage page.'); } } diff --git a/core/modules/filter/tests/src/Functional/FilterAdminTest.php b/core/modules/filter/tests/src/Functional/FilterAdminTest.php index 87c62eaf..49dd7a69 100644 --- a/core/modules/filter/tests/src/Functional/FilterAdminTest.php +++ b/core/modules/filter/tests/src/Functional/FilterAdminTest.php @@ -160,7 +160,7 @@ public function testFormatAdmin() { $this->assertFieldByName("formats[$format_id][weight]", 5, 'Text format weight was retained.'); // Disable text format. - $this->assertLinkByHref('admin/config/content/formats/manage/' . $format_id . '/disable'); + $this->assertSession()->linkByHrefExists('admin/config/content/formats/manage/' . $format_id . '/disable'); $this->drupalGet('admin/config/content/formats/manage/' . $format_id . '/disable'); $this->drupalPostForm(NULL, [], t('Disable')); diff --git a/core/modules/forum/tests/src/Functional/ForumBlockTest.php b/core/modules/forum/tests/src/Functional/ForumBlockTest.php index ce124c9e..21a42473 100644 --- a/core/modules/forum/tests/src/Functional/ForumBlockTest.php +++ b/core/modules/forum/tests/src/Functional/ForumBlockTest.php @@ -59,7 +59,7 @@ public function testNewForumTopicsBlock() { $topics = $this->createForumTopics(); $this->assertSession()->linkExists('More', 0, 'New forum topics block has a "more"-link.'); - $this->assertLinkByHref('forum', 0, 'New forum topics block has a "more"-link.'); + $this->assertSession()->linkByHrefExists('forum', 0, 'New forum topics block has a "more"-link.'); // We expect all 5 forum topics to appear in the "New forum topics" block. foreach ($topics as $topic) { @@ -114,7 +114,7 @@ public function testActiveForumTopicsBlock() { $block = $this->drupalPlaceBlock('forum_active_block'); $this->drupalGet(''); $this->assertSession()->linkExists('More', 0, 'Active forum topics block has a "more"-link.'); - $this->assertLinkByHref('forum', 0, 'Active forum topics block has a "more"-link.'); + $this->assertSession()->linkByHrefExists('forum', 0, 'Active forum topics block has a "more"-link.'); // We expect the first 5 forum topics to appear in the "Active forum topics" // block. diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php index 193e28c6..394fd4d7 100644 --- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @@ -123,9 +123,9 @@ public function testStyle() { // Ensure that the expected entity operations are there. $this->drupalGet($admin_path); - $this->assertLinkByHref($style_path); - $this->assertLinkByHref($style_path . '/flush'); - $this->assertLinkByHref($style_path . '/delete'); + $this->assertSession()->linkByHrefExists($style_path); + $this->assertSession()->linkByHrefExists($style_path . '/flush'); + $this->assertSession()->linkByHrefExists($style_path . '/delete'); // Add effect form. @@ -255,7 +255,7 @@ public function testStyle() { $image_crop_effect = $style->getEffect($uuids['image_crop']); $this->assertRaw(t('The image effect %name has been deleted.', ['%name' => $image_crop_effect->label()])); // Confirm that there is no longer a link to the effect. - $this->assertNoLinkByHref($style_path . '/effects/' . $uuids['image_crop'] . '/delete'); + $this->assertSession()->linkByHrefNotExists($style_path . '/effects/' . $uuids['image_crop'] . '/delete'); // Refresh the image style information and verify that the effect was // actually deleted. $entity_type_manager = $this->container->get('entity_type.manager'); @@ -443,7 +443,7 @@ public function testFlushUserInterface() { // exists. $this->drupalGet($admin_path); $flush_path = $admin_path . '/manage/' . $style_name . '/flush'; - $this->assertLinkByHref($flush_path); + $this->assertSession()->linkByHrefExists($flush_path); // Flush the image style derivatives using the user interface. $this->drupalPostForm($flush_path, [], t('Flush')); diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php index 4a3bc8e2..568db12d 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -71,7 +71,7 @@ public function _testImageFieldFormatters($scheme) { // Test for existence of link to image styles configuration. $this->drupalPostForm(NULL, [], "{$field_name}_settings_edit"); - $this->assertLinkByHref(Url::fromRoute('entity.image_style.collection')->toString(), 0, 'Link to image styles configuration is found'); + $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.image_style.collection')->toString(), 0, 'Link to image styles configuration is found'); // Remove 'administer image styles' permission from testing admin user. $admin_user_roles = $this->adminUser->getRoles(TRUE); @@ -82,7 +82,7 @@ public function _testImageFieldFormatters($scheme) { // Test for absence of link to image styles configuration. $this->drupalPostForm(NULL, [], "{$field_name}_settings_edit"); - $this->assertNoLinkByHref(Url::fromRoute('entity.image_style.collection')->toString(), 'Link to image styles configuration is absent when permissions are insufficient'); + $this->assertSession()->linkByHrefNotExists(Url::fromRoute('entity.image_style.collection')->toString(), 'Link to image styles configuration is absent when permissions are insufficient'); // Restore 'administer image styles' permission to testing admin user user_role_change_permissions(reset($admin_user_roles), ['administer image styles' => TRUE]); diff --git a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php index 680ddb4e..b8770354 100644 --- a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php +++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionTest.php @@ -33,7 +33,7 @@ public function testUIBrowserLanguageMappings() { // Check that the configure link exists. $this->drupalGet('admin/config/regional/language/detection'); - $this->assertLinkByHref('admin/config/regional/language/detection/browser'); + $this->assertSession()->linkByHrefExists('admin/config/regional/language/detection/browser'); // Check that defaults are loaded from language.mappings.yml. $this->drupalGet('admin/config/regional/language/detection/browser'); diff --git a/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php b/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php index fa533c8e..e37b892c 100644 --- a/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php +++ b/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php @@ -71,7 +71,7 @@ public function testPageLinks() { $this->drupalGet('admin/config'); // Verify that links in this page do not have a 'fr/' prefix. - $this->assertNoLinkByHref('/fr/', 'Links do not contain language prefix'); + $this->assertSession()->linkByHrefNotExists('/fr/', 'Links do not contain language prefix'); // Verify that links in this page can be followed and work. $this->clickLink(t('Languages')); diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php index d002423a..816b158a 100644 --- a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php @@ -94,7 +94,7 @@ public function testTranslatedUpdate() { $this->updateRequirementsProblem(); $this->drupalGet($update_url . '/selection', ['external' => TRUE]); $this->assertRaw('messages--status', 'No pending updates.'); - $this->assertNoLinkByHref('fr/update.php/run', 'No link to run updates.'); + $this->assertSession()->linkByHrefNotExists('fr/update.php/run', 'No link to run updates.'); } } diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php index 1d02ee9f..83252777 100644 --- a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php @@ -39,7 +39,7 @@ public function testEnglishTranslation() { $this->drupalLogin($admin_user); $this->drupalPostForm('admin/config/regional/language/edit/en', ['locale_translate_english' => TRUE], t('Save language')); - $this->assertLinkByHref('/admin/config/regional/translate?langcode=en', 0, 'Enabled interface translation to English.'); + $this->assertSession()->linkByHrefExists('/admin/config/regional/translate?langcode=en', 0, 'Enabled interface translation to English.'); } /** diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php index 7aabe80a..d07345da 100644 --- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php +++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentDeleteFormTest.php @@ -54,14 +54,14 @@ public function testMenuLinkContentDeleteForm() { $this->assertRaw(t('Are you sure you want to delete the custom menu link %name?', ['%name' => $menu_link->label()])); $this->assertSession()->linkExists('Cancel'); // Make sure cancel link points to link edit - $this->assertLinkByHref($menu_link->toUrl('edit-form')->toString()); + $this->assertSession()->linkByHrefExists($menu_link->toUrl('edit-form')->toString()); \Drupal::service('module_installer')->install(['menu_ui']); // Make sure cancel URL points to menu_ui route now. $this->drupalGet($menu_link->toUrl('delete-form')); $menu = Menu::load($menu_link->getMenuName()); - $this->assertLinkByHref($menu->toUrl('edit-form')->toString()); + $this->assertSession()->linkByHrefExists($menu->toUrl('edit-form')->toString()); $this->drupalPostForm(NULL, [], t('Delete')); $this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $menu_link->label()])); } diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php index 6c30e433..06842b06 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php @@ -135,8 +135,8 @@ public function testMenu() { // Verify delete link exists and reset link does not exist. $this->drupalGet('admin/structure/menu/manage/' . $this->menu->id()); - $this->assertLinkByHref(Url::fromRoute('entity.menu_link_content.delete_form', ['menu_link_content' => $this->items[0]->id()])->toString()); - $this->assertNoLinkByHref(Url::fromRoute('menu_ui.link_reset', ['menu_link_plugin' => $this->items[0]->getPluginId()])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.menu_link_content.delete_form', ['menu_link_content' => $this->items[0]->id()])->toString()); + $this->assertSession()->linkByHrefNotExists(Url::fromRoute('menu_ui.link_reset', ['menu_link_plugin' => $this->items[0]->getPluginId()])->toString()); // Check delete and reset access. $this->drupalGet('admin/structure/menu/item/' . $this->items[0]->id() . '/delete'); $this->assertSession()->statusCodeEquals(200); @@ -317,7 +317,7 @@ public function doMenuTests() { // Verify add link button. $this->drupalGet('admin/structure/menu'); - $this->assertLinkByHref('admin/structure/menu/manage/' . $menu_name . '/add', 0, "The add menu link button URL is correct"); + $this->assertSession()->linkByHrefExists('admin/structure/menu/manage/' . $menu_name . '/add', 0, "The add menu link button URL is correct"); // Verify form defaults. $this->doMenuLinkFormDefaultsTest(); diff --git a/core/modules/node/tests/src/Functional/NodeAdminTest.php b/core/modules/node/tests/src/Functional/NodeAdminTest.php index a4055a33..ad3c7cf3 100644 --- a/core/modules/node/tests/src/Functional/NodeAdminTest.php +++ b/core/modules/node/tests/src/Functional/NodeAdminTest.php @@ -149,9 +149,9 @@ public function testContentAdminPages() { $node_type_labels = $this->xpath('//td[contains(@class, "views-field-type")]'); $delta = 0; foreach ($nodes as $node) { - $this->assertLinkByHref('node/' . $node->id()); - $this->assertLinkByHref('node/' . $node->id() . '/edit'); - $this->assertLinkByHref('node/' . $node->id() . '/delete'); + $this->assertSession()->linkByHrefExists('node/' . $node->id()); + $this->assertSession()->linkByHrefExists('node/' . $node->id() . '/edit'); + $this->assertSession()->linkByHrefExists('node/' . $node->id() . '/delete'); // Verify that we can see the content type label. $this->assertEqual(trim($node_type_labels[$delta]->getText()), $node->type->entity->label()); $delta++; @@ -160,32 +160,32 @@ public function testContentAdminPages() { // Verify filtering by publishing status. $this->drupalGet('admin/content', ['query' => ['status' => TRUE]]); - $this->assertLinkByHref('node/' . $nodes['published_page']->id() . '/edit'); - $this->assertLinkByHref('node/' . $nodes['published_article']->id() . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/edit'); + $this->assertSession()->linkByHrefExists('node/' . $nodes['published_page']->id() . '/edit'); + $this->assertSession()->linkByHrefExists('node/' . $nodes['published_article']->id() . '/edit'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_1']->id() . '/edit'); // Verify filtering by status and content type. $this->drupalGet('admin/content', ['query' => ['status' => TRUE, 'type' => 'page']]); - $this->assertLinkByHref('node/' . $nodes['published_page']->id() . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['published_article']->id() . '/edit'); + $this->assertSession()->linkByHrefExists('node/' . $nodes['published_page']->id() . '/edit'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['published_article']->id() . '/edit'); // Verify no operation links are displayed for regular users. $this->drupalLogout(); $this->drupalLogin($this->baseUser1); $this->drupalGet('admin/content'); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('node/' . $nodes['published_page']->id()); - $this->assertLinkByHref('node/' . $nodes['published_article']->id()); - $this->assertNoLinkByHref('node/' . $nodes['published_page']->id() . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['published_page']->id() . '/delete'); - $this->assertNoLinkByHref('node/' . $nodes['published_article']->id() . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['published_article']->id() . '/delete'); + $this->assertSession()->linkByHrefExists('node/' . $nodes['published_page']->id()); + $this->assertSession()->linkByHrefExists('node/' . $nodes['published_article']->id()); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['published_page']->id() . '/edit'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['published_page']->id() . '/delete'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['published_article']->id() . '/edit'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['published_article']->id() . '/delete'); // Verify no unpublished content is displayed without permission. - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id()); - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/delete'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_1']->id()); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_1']->id() . '/edit'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_1']->id() . '/delete'); // Verify no tableselect. $this->assertNoFieldByName('nodes[' . $nodes['published_page']->id() . ']', '', 'No tableselect found.'); @@ -195,15 +195,15 @@ public function testContentAdminPages() { $this->drupalLogin($this->baseUser2); $this->drupalGet('admin/content'); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('node/' . $nodes['unpublished_page_2']->id()); + $this->assertSession()->linkByHrefExists('node/' . $nodes['unpublished_page_2']->id()); // Verify no operation links are displayed. - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_2']->id() . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_2']->id() . '/delete'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_2']->id() . '/edit'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_2']->id() . '/delete'); // Verify user cannot see unpublished content of other users. - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id()); - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/edit'); - $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/delete'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_1']->id()); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_1']->id() . '/edit'); + $this->assertSession()->linkByHrefNotExists('node/' . $nodes['unpublished_page_1']->id() . '/delete'); // Verify no tableselect. $this->assertNoFieldByName('nodes[' . $nodes['unpublished_page_2']->id() . ']', '', 'No tableselect found.'); @@ -214,9 +214,9 @@ public function testContentAdminPages() { $this->drupalGet('admin/content'); $this->assertSession()->statusCodeEquals(200); foreach ($nodes as $node) { - $this->assertLinkByHref('node/' . $node->id()); - $this->assertLinkByHref('node/' . $node->id() . '/edit'); - $this->assertLinkByHref('node/' . $node->id() . '/delete'); + $this->assertSession()->linkByHrefExists('node/' . $node->id()); + $this->assertSession()->linkByHrefExists('node/' . $node->id() . '/edit'); + $this->assertSession()->linkByHrefExists('node/' . $node->id() . '/delete'); } } diff --git a/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php index 5e083222..f28819b6 100644 --- a/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php +++ b/core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php @@ -220,7 +220,7 @@ public function testRecentNodeBlock() { $this->drupalGet('admin/structure/block'); $this->assertText($label, 'Block was displayed on the admin/structure/block page.'); - $this->assertLinkByHref($block->toUrl()->toString()); + $this->assertSession()->linkByHrefExists($block->toUrl()->toString()); } } diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php index 9c7ba270..6feb0bdb 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -254,7 +254,7 @@ public function testAuthorAutocomplete() { public function testNodeAddWithoutContentTypes() { $this->drupalGet('node/add'); $this->assertSession()->statusCodeEquals(200); - $this->assertNoLinkByHref('/admin/structure/types/add'); + $this->assertSession()->linkByHrefNotExists('/admin/structure/types/add'); // Test /node/add page without content types. foreach (\Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple() as $entity) { @@ -271,7 +271,7 @@ public function testNodeAddWithoutContentTypes() { $this->drupalGet('node/add'); - $this->assertLinkByHref('/admin/structure/types/add'); + $this->assertSession()->linkByHrefExists('/admin/structure/types/add'); } /** diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php index 9ebcaf31..ce1403e0 100644 --- a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php +++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php @@ -168,7 +168,7 @@ public function testNodeRevisionsTabWithDefaultRevision() { // Verify that the latest affected revision having been a default revision // is displayed as the current one. - $this->assertNoLinkByHref('/node/' . $node_id . '/revisions/1/revert'); + $this->assertSession()->linkByHrefNotExists('/node/' . $node_id . '/revisions/1/revert'); $elements = $this->xpath('//tr[contains(@class, "revision-current")]/td/a[1]'); // The site may be installed in a subdirectory, so check if the URL is // contained in the retrieved one. @@ -177,13 +177,13 @@ public function testNodeRevisionsTabWithDefaultRevision() { // Verify that the default revision can be an older revision than the latest // one. // Assert that the revisions with translations changes are shown. - $this->assertLinkByHref('/node/' . $node_id . '/revisions/4/revert'); + $this->assertSession()->linkByHrefExists('/node/' . $node_id . '/revisions/4/revert'); // Assert that the revisions without translations changes are filtered out: // 2, 3 and 5. - $this->assertNoLinkByHref('/node/' . $node_id . '/revisions/2/revert'); - $this->assertNoLinkByHref('/node/' . $node_id . '/revisions/3/revert'); - $this->assertNoLinkByHref('/node/' . $node_id . '/revisions/5/revert'); + $this->assertSession()->linkByHrefNotExists('/node/' . $node_id . '/revisions/2/revert'); + $this->assertSession()->linkByHrefNotExists('/node/' . $node_id . '/revisions/3/revert'); + $this->assertSession()->linkByHrefNotExists('/node/' . $node_id . '/revisions/5/revert'); } } diff --git a/core/modules/node/tests/src/Functional/NodeTypeTest.php b/core/modules/node/tests/src/Functional/NodeTypeTest.php index c9c477c4..3871d6bc 100644 --- a/core/modules/node/tests/src/Functional/NodeTypeTest.php +++ b/core/modules/node/tests/src/Functional/NodeTypeTest.php @@ -238,8 +238,8 @@ public function testNodeTypeFieldUiPermissions() { // Test that the user only sees the actions available to them. $this->drupalGet('admin/structure/types'); - $this->assertLinkByHref('admin/structure/types/manage/article/fields'); - $this->assertNoLinkByHref('admin/structure/types/manage/article/display'); + $this->assertSession()->linkByHrefExists('admin/structure/types/manage/article/fields'); + $this->assertSession()->linkByHrefNotExists('admin/structure/types/manage/article/display'); // Create another admin user who can manage node fields display. $admin_user_2 = $this->drupalCreateUser([ @@ -250,8 +250,8 @@ public function testNodeTypeFieldUiPermissions() { // Test that the user only sees the actions available to them. $this->drupalGet('admin/structure/types'); - $this->assertNoLinkByHref('admin/structure/types/manage/article/fields'); - $this->assertLinkByHref('admin/structure/types/manage/article/display'); + $this->assertSession()->linkByHrefNotExists('admin/structure/types/manage/article/fields'); + $this->assertSession()->linkByHrefExists('admin/structure/types/manage/article/display'); } /** diff --git a/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php b/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php index 64b930bb..b28a791a 100644 --- a/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php +++ b/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php @@ -58,21 +58,21 @@ public function testRevisionLinks() { // The first node revision should link to the node directly as you get an // access denied if you link to the revision. $url = $nodes[0]->toUrl()->toString(); - $this->assertLinkByHref($url); - $this->assertNoLinkByHref($url . '/revisions/' . $nodes[0]->getRevisionId() . '/view'); - $this->assertNoLinkByHref($url . '/revisions/' . $nodes[0]->getRevisionId() . '/delete'); - $this->assertNoLinkByHref($url . '/revisions/' . $nodes[0]->getRevisionId() . '/revert'); + $this->assertSession()->linkByHrefExists($url); + $this->assertSession()->linkByHrefNotExists($url . '/revisions/' . $nodes[0]->getRevisionId() . '/view'); + $this->assertSession()->linkByHrefNotExists($url . '/revisions/' . $nodes[0]->getRevisionId() . '/delete'); + $this->assertSession()->linkByHrefNotExists($url . '/revisions/' . $nodes[0]->getRevisionId() . '/revert'); // For the second node the current revision got set to the last revision, so // the first one should also link to the node page itself. $url = $nodes[1]->toUrl()->toString(); - $this->assertLinkByHref($url); - $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/view'); - $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/delete'); - $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/revert'); - $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/view'); - $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/delete'); - $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/revert'); + $this->assertSession()->linkByHrefExists($url); + $this->assertSession()->linkByHrefExists($url . '/revisions/' . $first_revision . '/view'); + $this->assertSession()->linkByHrefExists($url . '/revisions/' . $first_revision . '/delete'); + $this->assertSession()->linkByHrefExists($url . '/revisions/' . $first_revision . '/revert'); + $this->assertSession()->linkByHrefNotExists($url . '/revisions/' . $second_revision . '/view'); + $this->assertSession()->linkByHrefNotExists($url . '/revisions/' . $second_revision . '/delete'); + $this->assertSession()->linkByHrefNotExists($url . '/revisions/' . $second_revision . '/revert'); $accounts = [ 'view' => $this->drupalCreateUser(['view all revisions']), @@ -94,10 +94,10 @@ public function testRevisionLinks() { // Check expected links. foreach (['revert', 'delete'] as $operation) { if ($operation == $allowed_operation) { - $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/' . $operation); + $this->assertSession()->linkByHrefExists($url . '/revisions/' . $first_revision . '/' . $operation); } else { - $this->assertNoLinkByHref($url . '/revisions/' . $first_revision . '/' . $operation); + $this->assertSession()->linkByHrefNotExists($url . '/revisions/' . $first_revision . '/' . $operation); } } } diff --git a/core/modules/path/tests/src/Functional/PathAdminTest.php b/core/modules/path/tests/src/Functional/PathAdminTest.php index b227fd94..21fc34ed 100644 --- a/core/modules/path/tests/src/Functional/PathAdminTest.php +++ b/core/modules/path/tests/src/Functional/PathAdminTest.php @@ -70,41 +70,41 @@ public function testPathFiltering() { 'filter' => $alias1, ]; $this->drupalPostForm(NULL, $edit, t('Filter')); - $this->assertLinkByHref($alias1); - $this->assertNoLinkByHref($alias2); - $this->assertNoLinkByHref($alias3); + $this->assertSession()->linkByHrefExists($alias1); + $this->assertSession()->linkByHrefNotExists($alias2); + $this->assertSession()->linkByHrefNotExists($alias3); // Filter by the second alias. $edit = [ 'filter' => $alias2, ]; $this->drupalPostForm(NULL, $edit, t('Filter')); - $this->assertNoLinkByHref($alias1); - $this->assertLinkByHref($alias2); - $this->assertNoLinkByHref($alias3); + $this->assertSession()->linkByHrefNotExists($alias1); + $this->assertSession()->linkByHrefExists($alias2); + $this->assertSession()->linkByHrefNotExists($alias3); // Filter by the third alias which has a slash. $edit = [ 'filter' => $alias3, ]; $this->drupalPostForm(NULL, $edit, t('Filter')); - $this->assertNoLinkByHref($alias1); - $this->assertNoLinkByHref($alias2); - $this->assertLinkByHref($alias3); + $this->assertSession()->linkByHrefNotExists($alias1); + $this->assertSession()->linkByHrefNotExists($alias2); + $this->assertSession()->linkByHrefExists($alias3); // Filter by a random string with a different length. $edit = [ 'filter' => $this->randomMachineName(10), ]; $this->drupalPostForm(NULL, $edit, t('Filter')); - $this->assertNoLinkByHref($alias1); - $this->assertNoLinkByHref($alias2); + $this->assertSession()->linkByHrefNotExists($alias1); + $this->assertSession()->linkByHrefNotExists($alias2); // Reset the filter. $edit = []; $this->drupalPostForm(NULL, $edit, t('Reset')); - $this->assertLinkByHref($alias1); - $this->assertLinkByHref($alias2); + $this->assertSession()->linkByHrefExists($alias1); + $this->assertSession()->linkByHrefExists($alias2); } } diff --git a/core/modules/rdf/tests/src/Functional/CommentAttributesTest.php b/core/modules/rdf/tests/src/Functional/CommentAttributesTest.php index dd913bfa..67091357 100644 --- a/core/modules/rdf/tests/src/Functional/CommentAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/CommentAttributesTest.php @@ -169,7 +169,7 @@ public function testCommentRdfAuthorMarkup() { // is modified by the RDF module. $this->drupalGet('node/' . $this->node->id()); $this->assertSession()->linkExistsExact($this->webUser->getDisplayName()); - $this->assertLinkByHref('user/' . $this->webUser->id()); + $this->assertSession()->linkByHrefExists('user/' . $this->webUser->id()); } /** diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php index cc1d570d..23881f2d 100644 --- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php +++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php @@ -458,7 +458,7 @@ public function testUIFieldAlias() { // Test the UI settings for adding field ID aliases. $this->drupalGet('admin/structure/views/view/test_serializer_display_field/edit/rest_export_1'); $row_options = 'admin/structure/views/nojs/display/test_serializer_display_field/rest_export_1/row_options'; - $this->assertLinkByHref($row_options); + $this->assertSession()->linkByHrefExists($row_options); // Test an empty string for an alias, this should not be used. This also // tests that the form can be submitted with no aliases. @@ -525,7 +525,7 @@ public function testFieldRawOutput() { // Test the UI settings for adding field ID aliases. $this->drupalGet('admin/structure/views/view/test_serializer_display_field/edit/rest_export_1'); $row_options = 'admin/structure/views/nojs/display/test_serializer_display_field/rest_export_1/row_options'; - $this->assertLinkByHref($row_options); + $this->assertSession()->linkByHrefExists($row_options); // Test an empty string for an alias, this should not be used. This also // tests that the form can be submitted with no aliases. diff --git a/core/modules/search/tests/src/Functional/SearchBlockTest.php b/core/modules/search/tests/src/Functional/SearchBlockTest.php index 810d51a5..d58bf0d3 100644 --- a/core/modules/search/tests/src/Functional/SearchBlockTest.php +++ b/core/modules/search/tests/src/Functional/SearchBlockTest.php @@ -53,7 +53,7 @@ public function testSearchFormBlock() { // Test availability of the search block in the admin "Place blocks" list. $this->drupalGet('admin/structure/block'); $this->getSession()->getPage()->findLink('Place block')->click(); - $this->assertLinkByHref('/admin/structure/block/add/search_form_block/classy', 0, + $this->assertSession()->linkByHrefExists('/admin/structure/block/add/search_form_block/classy', 0, 'Did not find the search block in block candidate list.'); $block = $this->drupalPlaceBlock('search_form_block'); diff --git a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php index 4f5cacd0..3833e173 100644 --- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php @@ -370,28 +370,28 @@ public function testRouteProtection() { */ protected function verifySearchPageOperations($id, $edit, $delete, $disable, $enable) { if ($edit) { - $this->assertLinkByHref("admin/config/search/pages/manage/$id"); + $this->assertSession()->linkByHrefExists("admin/config/search/pages/manage/$id"); } else { - $this->assertNoLinkByHref("admin/config/search/pages/manage/$id"); + $this->assertSession()->linkByHrefNotExists("admin/config/search/pages/manage/$id"); } if ($delete) { - $this->assertLinkByHref("admin/config/search/pages/manage/$id/delete"); + $this->assertSession()->linkByHrefExists("admin/config/search/pages/manage/$id/delete"); } else { - $this->assertNoLinkByHref("admin/config/search/pages/manage/$id/delete"); + $this->assertSession()->linkByHrefNotExists("admin/config/search/pages/manage/$id/delete"); } if ($disable) { - $this->assertLinkByHref("admin/config/search/pages/manage/$id/disable"); + $this->assertSession()->linkByHrefExists("admin/config/search/pages/manage/$id/disable"); } else { - $this->assertNoLinkByHref("admin/config/search/pages/manage/$id/disable"); + $this->assertSession()->linkByHrefNotExists("admin/config/search/pages/manage/$id/disable"); } if ($enable) { - $this->assertLinkByHref("admin/config/search/pages/manage/$id/enable"); + $this->assertSession()->linkByHrefExists("admin/config/search/pages/manage/$id/enable"); } else { - $this->assertNoLinkByHref("admin/config/search/pages/manage/$id/enable"); + $this->assertSession()->linkByHrefNotExists("admin/config/search/pages/manage/$id/enable"); } } diff --git a/core/modules/search/tests/src/Functional/SearchExactTest.php b/core/modules/search/tests/src/Functional/SearchExactTest.php index 1b77e703..4b7544a2 100644 --- a/core/modules/search/tests/src/Functional/SearchExactTest.php +++ b/core/modules/search/tests/src/Functional/SearchExactTest.php @@ -58,16 +58,16 @@ public function testExactQuery() { // Test that the correct number of pager links are found for keyword search. $edit = ['keys' => 'love pizza']; $this->drupalPostForm('search/node', $edit, t('Search')); - $this->assertLinkByHref('page=1', 0, '2nd page link is found for keyword search.'); - $this->assertLinkByHref('page=2', 0, '3rd page link is found for keyword search.'); - $this->assertLinkByHref('page=3', 0, '4th page link is found for keyword search.'); - $this->assertNoLinkByHref('page=4', '5th page link is not found for keyword search.'); + $this->assertSession()->linkByHrefExists('page=1', 0, '2nd page link is found for keyword search.'); + $this->assertSession()->linkByHrefExists('page=2', 0, '3rd page link is found for keyword search.'); + $this->assertSession()->linkByHrefExists('page=3', 0, '4th page link is found for keyword search.'); + $this->assertSession()->linkByHrefNotExists('page=4', '5th page link is not found for keyword search.'); // Test that the correct number of pager links are found for exact phrase search. $edit = ['keys' => '"love pizza"']; $this->drupalPostForm('search/node', $edit, t('Search')); - $this->assertLinkByHref('page=1', 0, '2nd page link is found for exact phrase search.'); - $this->assertNoLinkByHref('page=2', '3rd page link is not found for exact phrase search.'); + $this->assertSession()->linkByHrefExists('page=1', 0, '2nd page link is found for exact phrase search.'); + $this->assertSession()->linkByHrefNotExists('page=2', '3rd page link is not found for exact phrase search.'); // Check that with post settings turned on the post information is displayed. $node_type_config = \Drupal::configFactory()->getEditable('node.type.page'); diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php index 8525b7c0..ec68e36e 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php @@ -259,7 +259,7 @@ public function testShortcutLinkChangePath() { $saved_set = ShortcutSet::load($set->id()); $paths = $this->getShortcutInformation($saved_set, 'link'); $this->assertContains('internal:' . $new_link_path, $paths, 'Shortcut path changed: ' . $new_link_path); - $this->assertLinkByHref($new_link_path, 0, 'Shortcut with new path appears on the page.'); + $this->assertSession()->linkByHrefExists($new_link_path, 0, 'Shortcut with new path appears on the page.'); $this->assertText(t('The shortcut @link has been updated.', ['@link' => $shortcut->getTitle()])); } diff --git a/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php b/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php index a9220bbd..d367ce4a 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php @@ -41,7 +41,7 @@ public function testEntityOperationAlter() { $this->drupalGet('admin/people/roles'); $roles = user_roles(); foreach ($roles as $role) { - $this->assertLinkByHref($role->toUrl()->toString() . '/test_operation'); + $this->assertSession()->linkByHrefExists($role->toUrl()->toString() . '/test_operation'); $this->assertSession()->linkExists(new FormattableMarkup('Test Operation: @label', ['@label' => $role->label()])); } } diff --git a/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php b/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php index c5bab02d..57415a37 100644 --- a/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php +++ b/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php @@ -54,9 +54,9 @@ public function testMenuBlockLinksAccessCheck() { // Check for access to a restricted local task from a default local task. $this->drupalGet('foo/asdf'); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('foo/asdf'); - $this->assertLinkByHref('foo/asdf/b'); - $this->assertNoLinkByHref('foo/asdf/c'); + $this->assertSession()->linkByHrefExists('foo/asdf'); + $this->assertSession()->linkByHrefExists('foo/asdf/b'); + $this->assertSession()->linkByHrefNotExists('foo/asdf/c'); // Attempt to access a restricted local task. $this->drupalGet('foo/asdf/c'); @@ -66,8 +66,8 @@ public function testMenuBlockLinksAccessCheck() { ':href' => Url::fromRoute('menu_test.router_test1', ['bar' => 'asdf'])->toString(), ]); $this->assertTrue(empty($elements), 'No tab linking to foo/asdf found'); - $this->assertNoLinkByHref('foo/asdf/b'); - $this->assertNoLinkByHref('foo/asdf/c'); + $this->assertSession()->linkByHrefNotExists('foo/asdf/b'); + $this->assertSession()->linkByHrefNotExists('foo/asdf/c'); } } diff --git a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php index 1a7726df..f646fe8b 100644 --- a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php +++ b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php @@ -70,8 +70,8 @@ protected function doTestHookMenuIntegration() { $this->assertSession()->linkNotExists('Local task C'); $this->assertSession()->assertEscaped(""); // Confirm correct local task href. - $this->assertLinkByHref(Url::fromRoute('menu_test.router_test1', ['bar' => $machine_name])->toString()); - $this->assertLinkByHref(Url::fromRoute('menu_test.router_test2', ['bar' => $machine_name])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('menu_test.router_test1', ['bar' => $machine_name])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('menu_test.router_test2', ['bar' => $machine_name])->toString()); } /** @@ -180,10 +180,10 @@ protected function doTestMenuOnRoute() { $this->resetAll(); $this->drupalGet('router_test/test2'); - $this->assertLinkByHref('menu_no_title_callback'); - $this->assertLinkByHref('menu-title-test/case1'); - $this->assertLinkByHref('menu-title-test/case2'); - $this->assertLinkByHref('menu-title-test/case3'); + $this->assertSession()->linkByHrefExists('menu_no_title_callback'); + $this->assertSession()->linkByHrefExists('menu-title-test/case1'); + $this->assertSession()->linkByHrefExists('menu-title-test/case2'); + $this->assertSession()->linkByHrefExists('menu-title-test/case3'); } /** diff --git a/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php index 682e9e40..d07f7704 100644 --- a/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php @@ -73,7 +73,7 @@ public function testUninstall() { // Check that Taxonomy cannot be uninstalled yet. $this->drupalGet('admin/modules/uninstall'); $this->assertText('Remove content items'); - $this->assertLinkByHref('admin/modules/uninstall/entity/taxonomy_term'); + $this->assertSession()->linkByHrefExists('admin/modules/uninstall/entity/taxonomy_term'); // Delete Taxonomy term data. $this->drupalGet('admin/modules/uninstall/entity/taxonomy_term'); @@ -95,7 +95,7 @@ public function testUninstall() { // Check that there is no more data to be deleted, Taxonomy is ready to be // uninstalled. $this->assertText('Enables the categorization of content.'); - $this->assertNoLinkByHref('admin/modules/uninstall/entity/taxonomy_term'); + $this->assertSession()->linkByHrefNotExists('admin/modules/uninstall/entity/taxonomy_term'); // Uninstall the Taxonomy module. $this->drupalPostForm('admin/modules/uninstall', ['uninstall[taxonomy]' => TRUE], t('Uninstall')); @@ -106,7 +106,7 @@ public function testUninstall() { // Check Node cannot be uninstalled yet, there is content to be removed. $this->drupalGet('admin/modules/uninstall'); $this->assertText('Remove content items'); - $this->assertLinkByHref('admin/modules/uninstall/entity/node'); + $this->assertSession()->linkByHrefExists('admin/modules/uninstall/entity/node'); // Delete Node data. $this->drupalGet('admin/modules/uninstall/entity/node'); @@ -143,7 +143,7 @@ public function testUninstall() { // Check there is no more data to be deleted, Node is ready to be // uninstalled. $this->assertText('Allows content to be submitted to the site and displayed on pages.'); - $this->assertNoLinkByHref('admin/modules/uninstall/entity/node'); + $this->assertSession()->linkByHrefNotExists('admin/modules/uninstall/entity/node'); // Uninstall Node module. $this->drupalPostForm('admin/modules/uninstall', ['uninstall[node]' => TRUE], t('Uninstall')); diff --git a/core/modules/system/tests/src/Functional/System/AdminTest.php b/core/modules/system/tests/src/Functional/System/AdminTest.php index a0abdf5f..bb312282 100644 --- a/core/modules/system/tests/src/Functional/System/AdminTest.php +++ b/core/modules/system/tests/src/Functional/System/AdminTest.php @@ -64,7 +64,7 @@ public function testAdminPages() { // the main administration page. foreach ($this->getTopLevelMenuLinks() as $item) { $this->assertSession()->linkExists($item->getTitle()); - $this->assertLinkByHref($item->getUrlObject()->toString()); + $this->assertSession()->linkByHrefExists($item->getUrlObject()->toString()); // The description should appear below the link. $this->assertText($item->getDescription()); } @@ -86,34 +86,34 @@ public function testAdminPages() { // pages. $this->drupalLogin($this->adminUser); $this->drupalGet($page); - $this->assertLinkByHref('admin/config'); - $this->assertLinkByHref('admin/config/regional/settings'); - $this->assertLinkByHref('admin/config/regional/date-time'); - $this->assertLinkByHref('admin/config/regional/language'); - $this->assertNoLinkByHref('admin/config/regional/language/detection/session'); - $this->assertNoLinkByHref('admin/config/regional/language/detection/url'); - $this->assertLinkByHref('admin/config/regional/translate'); + $this->assertSession()->linkByHrefExists('admin/config'); + $this->assertSession()->linkByHrefExists('admin/config/regional/settings'); + $this->assertSession()->linkByHrefExists('admin/config/regional/date-time'); + $this->assertSession()->linkByHrefExists('admin/config/regional/language'); + $this->assertSession()->linkByHrefNotExists('admin/config/regional/language/detection/session'); + $this->assertSession()->linkByHrefNotExists('admin/config/regional/language/detection/url'); + $this->assertSession()->linkByHrefExists('admin/config/regional/translate'); // On admin/index only, the administrator should also see a "Configure // permissions" link for the Locale module. if ($page == 'admin/index') { - $this->assertLinkByHref("admin/people/permissions#module-locale"); + $this->assertSession()->linkByHrefExists("admin/people/permissions#module-locale"); } // For a less privileged user, verify that there are no links to Locale's // primary configuration pages, but a link to the translate page exists. $this->drupalLogin($this->webUser); $this->drupalGet($page); - $this->assertLinkByHref('admin/config'); - $this->assertNoLinkByHref('admin/config/regional/settings'); - $this->assertNoLinkByHref('admin/config/regional/date-time'); - $this->assertNoLinkByHref('admin/config/regional/language'); - $this->assertNoLinkByHref('admin/config/regional/language/detection/session'); - $this->assertNoLinkByHref('admin/config/regional/language/detection/url'); - $this->assertLinkByHref('admin/config/regional/translate'); + $this->assertSession()->linkByHrefExists('admin/config'); + $this->assertSession()->linkByHrefNotExists('admin/config/regional/settings'); + $this->assertSession()->linkByHrefNotExists('admin/config/regional/date-time'); + $this->assertSession()->linkByHrefNotExists('admin/config/regional/language'); + $this->assertSession()->linkByHrefNotExists('admin/config/regional/language/detection/session'); + $this->assertSession()->linkByHrefNotExists('admin/config/regional/language/detection/url'); + $this->assertSession()->linkByHrefExists('admin/config/regional/translate'); // This user cannot configure permissions, so even on admin/index should // not see a "Configure permissions" link for the Locale module. if ($page == 'admin/index') { - $this->assertNoLinkByHref("admin/people/permissions#module-locale"); + $this->assertSession()->linkByHrefNotExists("admin/people/permissions#module-locale"); } } } diff --git a/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php b/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php index 69fb3c28..ed2b467f 100644 --- a/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php +++ b/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php @@ -26,8 +26,8 @@ public function testDateLocking() { // formats are clearly marked as such; unlocked formats are not marked as // "locked". $this->drupalGet('admin/config/regional/date-time'); - $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/short'); - $this->assertNoLinkByHref('admin/config/regional/date-time/formats/manage/html_date'); + $this->assertSession()->linkByHrefExists('admin/config/regional/date-time/formats/manage/short'); + $this->assertSession()->linkByHrefNotExists('admin/config/regional/date-time/formats/manage/html_date'); $this->assertText('Fallback date format'); $this->assertNoText('short (locked)'); diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php index a55f6635..5656c237 100644 --- a/core/modules/system/tests/src/Functional/System/StatusTest.php +++ b/core/modules/system/tests/src/Functional/System/StatusTest.php @@ -54,10 +54,10 @@ public function testStatusPage() { $this->assertText($phpversion, 'Php version is shown on the page.'); if (function_exists('phpinfo')) { - $this->assertLinkByHref(Url::fromRoute('system.php')->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('system.php')->toString()); } else { - $this->assertNoLinkByHref(Url::fromRoute('system.php')->toString()); + $this->assertSession()->linkByHrefNotExists(Url::fromRoute('system.php')->toString()); } // If a module is fully installed no pending updates exists. diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php index b58176ed..7db2827f 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php @@ -637,8 +637,8 @@ public function testSuccessfulMultilingualUpdateFunctionality() { // Visit status report page and ensure, that link to update.php has no path prefix set. $this->drupalGet('en/admin/reports/status', ['external' => TRUE]); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('/update.php'); - $this->assertNoLinkByHref('en/update.php'); + $this->assertSession()->linkByHrefExists('/update.php'); + $this->assertSession()->linkByHrefNotExists('en/update.php'); // Click through update.php with 'access administration pages' and // 'access site reports' permissions. diff --git a/core/modules/taxonomy/tests/src/Functional/RssTest.php b/core/modules/taxonomy/tests/src/Functional/RssTest.php index ac3bc2a9..7701e94b 100644 --- a/core/modules/taxonomy/tests/src/Functional/RssTest.php +++ b/core/modules/taxonomy/tests/src/Functional/RssTest.php @@ -115,7 +115,7 @@ public function testTaxonomyRss() { // Test that the feed icon exists for the term. $this->drupalGet("taxonomy/term/{$term1->id()}"); - $this->assertLinkByHref("taxonomy/term/{$term1->id()}/feed"); + $this->assertSession()->linkByHrefExists("taxonomy/term/{$term1->id()}/feed"); // Test that the feed page exists for the term. $this->drupalGet("taxonomy/term/{$term1->id()}/feed"); diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php index 2aca19e7..908ac310 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php @@ -136,13 +136,13 @@ public function testTranslateLinkVocabularyAdminPage() { // Verify translation links. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('term/' . $translatable_tid . '/translations', 0, 'The translations link exists for a translatable vocabulary.'); - $this->assertLinkByHref('term/' . $translatable_tid . '/edit', 0, 'The edit link exists for a translatable vocabulary.'); + $this->assertSession()->linkByHrefExists('term/' . $translatable_tid . '/translations', 0, 'The translations link exists for a translatable vocabulary.'); + $this->assertSession()->linkByHrefExists('term/' . $translatable_tid . '/edit', 0, 'The edit link exists for a translatable vocabulary.'); $this->drupalGet('admin/structure/taxonomy/manage/' . $untranslatable_vocabulary->id() . '/overview'); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('term/' . $untranslatable_tid . '/edit'); - $this->assertNoLinkByHref('term/' . $untranslatable_tid . '/translations'); + $this->assertSession()->linkByHrefExists('term/' . $untranslatable_tid . '/edit'); + $this->assertSession()->linkByHrefNotExists('term/' . $untranslatable_tid . '/translations'); } /** diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php index b2854e5a..aa5e1e80 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php @@ -53,7 +53,7 @@ public function testVocabularyInterface() { $this->drupalGet('admin/structure/taxonomy'); $this->assertText($edit['name'], 'Vocabulary name found in the vocabulary overview listing.'); $this->assertText($edit['description'], 'Vocabulary description found in the vocabulary overview listing.'); - $this->assertLinkByHref(Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $edit['vid']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $edit['vid']])->toString()); $this->clickLink(t('Edit vocabulary')); $edit = []; $edit['name'] = $this->randomMachineName(); diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php index 92a6aacb..5d43c43d 100644 --- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php +++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php @@ -93,11 +93,11 @@ public function testUploadModule() { // Ensure the links are relative to the site root and not // core/authorize.php. $this->assertSession()->linkExists('Install another module'); - $this->assertLinkByHref(Url::fromRoute('update.module_install')->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('update.module_install')->toString()); $this->assertSession()->linkExists('Enable newly added modules'); - $this->assertLinkByHref(Url::fromRoute('system.modules_list')->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('system.modules_list')->toString()); $this->assertSession()->linkExists('Administration pages'); - $this->assertLinkByHref(Url::fromRoute('system.admin')->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('system.admin')->toString()); // Ensure we can reach the "Install another module" link. $this->clickLink(t('Install another module')); $this->assertSession()->statusCodeEquals(200); diff --git a/core/modules/user/tests/src/Functional/UserAccountLinksTest.php b/core/modules/user/tests/src/Functional/UserAccountLinksTest.php index e68d64e0..dd0c0422 100644 --- a/core/modules/user/tests/src/Functional/UserAccountLinksTest.php +++ b/core/modules/user/tests/src/Functional/UserAccountLinksTest.php @@ -138,7 +138,7 @@ public function testAccountPageTitles() { $this->drupalLogin($this->drupalCreateUser()); // After login, the client is redirected to /user. $this->assertSession()->linkExists('My account', 0, "Page title of /user is 'My Account' in menus for registered users"); - $this->assertLinkByHref(\Drupal::urlGenerator()->generate('user.page'), 0); + $this->assertSession()->linkByHrefExists(\Drupal::urlGenerator()->generate('user.page'), 0); } /** diff --git a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php index 282a9828..56242c5d 100644 --- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php @@ -89,7 +89,7 @@ public function testRoleAdministration() { $this->clickLink(t('Delete')); $this->drupalPostForm(NULL, [], t('Delete')); $this->assertRaw(t('The role %label has been deleted.', ['%label' => $role_name])); - $this->assertNoLinkByHref("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.'); + $this->assertSession()->linkByHrefNotExists("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.'); \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]); $this->assertNull(Role::load($role->id()), 'A deleted role can no longer be loaded.'); diff --git a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php index 874b0d61..a4608013 100644 --- a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php +++ b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php @@ -70,9 +70,9 @@ public function testClickSorting() { $this->assertSession()->statusCodeEquals(200); // Only the id and name should be click sortable, but not the name. - $this->assertLinkByHref(Url::fromRoute('', [], ['query' => ['order' => 'id', 'sort' => 'asc']])->toString()); - $this->assertLinkByHref(Url::fromRoute('', [], ['query' => ['order' => 'name', 'sort' => 'desc']])->toString()); - $this->assertNoLinkByHref(Url::fromRoute('', [], ['query' => ['order' => 'created']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('', [], ['query' => ['order' => 'id', 'sort' => 'asc']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('', [], ['query' => ['order' => 'name', 'sort' => 'desc']])->toString()); + $this->assertSession()->linkByHrefNotExists(Url::fromRoute('', [], ['query' => ['order' => 'created']])->toString()); // Check that the view returns the click sorting cache contexts. $expected_contexts = [ @@ -85,7 +85,7 @@ public function testClickSorting() { // Clicking a click sort should change the order. $this->clickLink(t('ID')); $href = Url::fromRoute('', [], ['query' => ['order' => 'id', 'sort' => 'desc']])->toString(); - $this->assertLinkByHref($href); + $this->assertSession()->linkByHrefExists($href); // Check that the output has the expected order (asc). $ids = $this->clickSortLoadIdsFromOutput(); $this->assertEqual($ids, range(1, 5)); diff --git a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php index 79b6ed8c..0fa19953 100644 --- a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php +++ b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php @@ -256,7 +256,7 @@ public function testRelationshipUI() { $handler_options_path = 'admin/structure/views/nojs/handler/test_handler_relationships/default/field/title'; $view_edit_path = 'admin/structure/views/view/test_handler_relationships/edit'; $this->drupalGet($view_edit_path); - $this->assertLinkByHref($handler_options_path); + $this->assertSession()->linkByHrefExists($handler_options_path); // The test view has a relationship to node_revision so the field should // show a relationship selection. diff --git a/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php b/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php index a6de0c9b..c84c857e 100644 --- a/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/StyleSummaryTest.php @@ -142,7 +142,7 @@ public function testSummaryView() { $this->drupalPostForm('admin/structure/views/nojs/handler/test_summary/page_1/argument/type', $edit, t('Apply')); $this->drupalPostForm(NULL, [], t('Save')); $this->drupalGet('test-summary'); - $this->assertLinkByHref('/'); + $this->assertSession()->linkByHrefExists('/'); } } diff --git a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php index acc6a9ca..1ac7cae3 100644 --- a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php @@ -44,9 +44,9 @@ public function testViewsWizardAndListing() { $this->drupalGet('admin/structure/views'); $this->assertText($view1['label']); $this->assertText($view1['description']); - $this->assertLinkByHref(Url::fromRoute('entity.view.edit_form', ['view' => $view1['id']])->toString()); - $this->assertLinkByHref(Url::fromRoute('entity.view.delete_form', ['view' => $view1['id']])->toString()); - $this->assertLinkByHref(Url::fromRoute('entity.view.duplicate_form', ['view' => $view1['id']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.view.edit_form', ['view' => $view1['id']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.view.delete_form', ['view' => $view1['id']])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.view.duplicate_form', ['view' => $view1['id']])->toString()); // The view should not have a REST export display. $this->assertNoText('REST export', 'When no options are enabled in the wizard, the resulting view does not have a REST export display.'); @@ -81,7 +81,7 @@ public function testViewsWizardAndListing() { $this->assertText($node2->label()); // Check if we have the feed. - $this->assertLinkByHref(Url::fromRoute('view.' . $view2['id'] . '.feed_1')->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('view.' . $view2['id'] . '.feed_1')->toString()); $elements = $this->cssSelect('link[href="' . Url::fromRoute('view.' . $view2['id'] . '.feed_1', [], ['absolute' => TRUE])->toString() . '"]'); $this->assertCount(1, $elements, 'Feed found.'); $this->drupalGet($view2['page[feed_properties][path]']); @@ -99,7 +99,7 @@ public function testViewsWizardAndListing() { $this->drupalGet('admin/structure/views'); $this->assertText($view2['label']); $this->assertText($view2['description']); - $this->assertLinkByHref(Url::fromRoute('view.' . $view2['id'] . '.page_1')->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('view.' . $view2['id'] . '.page_1')->toString()); // The view should not have a REST export display. $this->assertNoText('REST export', 'If only the page option was enabled in the wizard, the resulting view does not have a REST export display.'); @@ -134,7 +134,7 @@ public function testViewsWizardAndListing() { $this->drupalGet('admin/structure/views'); $this->assertText($view3['label']); $this->assertText($view3['description']); - $this->assertLinkByHref(Url::fromRoute('view.' . $view3['id'] . '.page_1')->toString()); + $this->assertSession()->linkByHrefExists(Url::fromRoute('view.' . $view3['id'] . '.page_1')->toString()); // The view should not have a REST export display. $this->assertNoText('REST export', 'If only the page and block options were enabled in the wizard, the resulting view does not have a REST export display.'); diff --git a/core/modules/views/tests/src/Functional/Wizard/MenuTest.php b/core/modules/views/tests/src/Functional/Wizard/MenuTest.php index e9483c30..09a012ae 100644 --- a/core/modules/views/tests/src/Functional/Wizard/MenuTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/MenuTest.php @@ -41,7 +41,7 @@ public function testMenus() { $this->drupalGet(''); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->linkExists($view['page[link_properties][title]']); - $this->assertLinkByHref(Url::fromUri('base:' . $view['page[path]'])->toString()); + $this->assertSession()->linkByHrefExists(Url::fromUri('base:' . $view['page[path]'])->toString()); // Make sure the link is associated with the main menu. /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ diff --git a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php index 37fad2a9..456b3b2a 100644 --- a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php +++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php @@ -58,7 +58,7 @@ public function testCacheData() { $this->assertNoFieldById('edit-actions-submit', t('Save')); $this->assertNoFieldById('edit-actions-cancel', t('Cancel')); // Test we have the break lock link. - $this->assertLinkByHref('admin/structure/views/view/test_view/break-lock'); + $this->assertSession()->linkByHrefExists('admin/structure/views/view/test_view/break-lock'); // Break the lock. $this->clickLink(t('break this lock')); $this->drupalPostForm(NULL, [], t('Break lock')); diff --git a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php index cb3cb291..640acdad 100644 --- a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php +++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php @@ -42,20 +42,20 @@ public function testDefaultViews() { $this->drupalGet('admin/structure/views'); // @todo Disabled default views do now appear on the front page. Test this // behavior with templates instead. - // $this->assertNoLinkByHref($edit_href); + // $this->assertSession()->linkByHrefNotExists($edit_href); // Enable the view, and make sure it is now visible on the main listing // page. $this->drupalGet('admin/structure/views'); $this->clickViewsOperationLink('Enable', '/glossary/'); $this->assertUrl('admin/structure/views'); - $this->assertLinkByHref($edit_href); + $this->assertSession()->linkByHrefExists($edit_href); // It should not be possible to revert the view yet. // @todo Figure out how to handle this with the new configuration system. // $this->assertSession()->linkNotExists('Revert'); // $revert_href = 'admin/structure/views/view/glossary/revert'; - // $this->assertNoLinkByHref($revert_href); + // $this->assertSession()->linkByHrefNotExists($revert_href); // Edit the view and change the title. Make sure that the new title is // displayed. @@ -74,7 +74,7 @@ public function testDefaultViews() { // Check there is an enable link. i.e. The view has not been enabled after // editing. $this->drupalGet('admin/structure/views'); - $this->assertLinkByHref('admin/structure/views/view/archive/enable'); + $this->assertSession()->linkByHrefExists('admin/structure/views/view/archive/enable'); // Enable it again so it can be tested for access permissions. $this->clickViewsOperationLink('Enable', '/archive/'); @@ -82,7 +82,7 @@ public function testDefaultViews() { // view title we added above no longer is displayed. // $this->drupalGet('admin/structure/views'); // $this->assertSession()->linkExists('Revert'); - // $this->assertLinkByHref($revert_href); + // $this->assertSession()->linkByHrefExists($revert_href); // $this->drupalPostForm($revert_href, array(), t('Revert')); // $this->drupalGet('glossary'); // $this->assertNoText($new_title); @@ -111,13 +111,13 @@ public function testDefaultViews() { $this->drupalGet('admin/structure/views'); $this->clickViewsOperationLink('Disable', '/glossary/'); // $this->assertUrl('admin/structure/views'); - // $this->assertNoLinkByHref($edit_href); + // $this->assertSession()->linkByHrefNotExists($edit_href); // The easiest way to verify it appears on the disabled views listing page // is to try to click the "enable" link from there again. $this->drupalGet('admin/structure/views'); $this->clickViewsOperationLink('Enable', '/glossary/'); $this->assertUrl('admin/structure/views'); - $this->assertLinkByHref($edit_href); + $this->assertSession()->linkByHrefExists($edit_href); // Clear permissions for anonymous users to check access for default views. Role::load(RoleInterface::ANONYMOUS_ID)->revokePermission('access content')->save(); @@ -137,7 +137,7 @@ public function testDefaultViews() { $this->drupalPostForm(NULL, [], t('Delete')); // Ensure the view is no longer listed. $this->assertUrl('admin/structure/views'); - $this->assertNoLinkByHref($edit_href); + $this->assertSession()->linkByHrefNotExists($edit_href); // Ensure the view is no longer available. $this->drupalGet($edit_href); $this->assertSession()->statusCodeEquals(404); @@ -204,13 +204,13 @@ public function testPathDestination() { $this->drupalGet('admin/structure/views'); // Check that links to views on default tabs are rendered correctly. - $this->assertLinkByHref('test_page_display_menu'); - $this->assertNoLinkByHref('test_page_display_menu/default'); - $this->assertLinkByHref('test_page_display_menu/local'); + $this->assertSession()->linkByHrefExists('test_page_display_menu'); + $this->assertSession()->linkByHrefNotExists('test_page_display_menu/default'); + $this->assertSession()->linkByHrefExists('test_page_display_menu/local'); // Check that a dynamic path is shown as text. $this->assertRaw('test_route_with_suffix/%/suffix'); - $this->assertNoLinkByHref(Url::fromUri('base:test_route_with_suffix/%/suffix')->toString()); + $this->assertSession()->linkByHrefNotExists(Url::fromUri('base:test_route_with_suffix/%/suffix')->toString()); } /** diff --git a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php index e4b3e0b6..06438396 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php @@ -45,7 +45,7 @@ public function testAddDisplay() { // Add a new display. $this->drupalPostForm(NULL, [], 'Add Page'); - $this->assertLinkByHref($path_prefix . '/page_1', 0, 'Make sure after adding a display the new display appears in the UI'); + $this->assertSession()->linkByHrefExists($path_prefix . '/page_1', 0, 'Make sure after adding a display the new display appears in the UI'); $this->assertSession()->linkNotExists('Master*', 'Make sure the master display is not marked as changed.'); $this->assertSession()->linkExists('Page*', 0, 'Make sure the added display is marked as changed.'); @@ -85,7 +85,7 @@ public function testRemoveDisplay() { $this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page'); $this->drupalPostForm(NULL, [], t('Save')); - $this->assertNoLinkByHref($path_prefix . '/page_1', 'Make sure there is no display tab for the deleted display.'); + $this->assertSession()->linkByHrefNotExists($path_prefix . '/page_1', 'Make sure there is no display tab for the deleted display.'); // Test deleting a display that has a modified machine name. $view = $this->randomView(); @@ -95,7 +95,7 @@ public function testRemoveDisplay() { $this->drupalPostForm(NULL, [], 'Delete Page'); $this->drupalPostForm(NULL, [], t('Save')); $this->assertSession()->statusCodeEquals(200); - $this->assertNoLinkByHref($path_prefix . '/new_machine_name', 'Make sure there is no display tab for the deleted display.'); + $this->assertSession()->linkByHrefNotExists($path_prefix . '/new_machine_name', 'Make sure there is no display tab for the deleted display.'); } /** @@ -118,7 +118,7 @@ public function testDuplicateDisplay() { $this->drupalGet($path_prefix); $this->drupalPostForm(NULL, [], 'Duplicate Page'); // Verify that the user got redirected to the new display. - $this->assertLinkByHref($path_prefix . '/page_2', 0, 'Make sure after duplicating the new display appears in the UI'); + $this->assertSession()->linkByHrefExists($path_prefix . '/page_2', 0, 'Make sure after duplicating the new display appears in the UI'); $this->assertUrl($path_prefix . '/page_2'); // Set the title and override the css classes. @@ -129,7 +129,7 @@ public function testDuplicateDisplay() { // Duplicate as a different display type. $this->drupalPostForm(NULL, [], 'Duplicate as Block'); - $this->assertLinkByHref($path_prefix . '/block_1', 0, 'Make sure after duplicating the new display appears in the UI'); + $this->assertSession()->linkByHrefExists($path_prefix . '/block_1', 0, 'Make sure after duplicating the new display appears in the UI'); $this->assertUrl($path_prefix . '/block_1'); $this->assertText(t('Block settings')); $this->assertNoText('Page settings'); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayExtenderUITest.php b/core/modules/views_ui/tests/src/Functional/DisplayExtenderUITest.php index 5b01e7f5..5c2c5dd1 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayExtenderUITest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayExtenderUITest.php @@ -34,7 +34,7 @@ public function testDisplayExtenderUI() { $display_option_url = 'admin/structure/views/nojs/display/test_view/default/test_extender_test_option'; $this->drupalGet($view_edit_url); - $this->assertLinkByHref($display_option_url, 0, 'Make sure the option defined by the test display extender appears in the UI.'); + $this->assertSession()->linkByHrefExists($display_option_url, 0, 'Make sure the option defined by the test display extender appears in the UI.'); $random_text = $this->randomMachineName(); $this->drupalPostForm($display_option_url, ['test_extender_test_option' => $random_text], t('Apply')); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php index e3e43f35..69d8ee3d 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -161,7 +161,7 @@ public function testMenuOptions() { $this->drupalGet('admin/structure/views/view/test_view'); $this->assertSession()->linkExists('Tab: Test tab title'); // If it's a default tab, it should also have an additional settings link. - $this->assertLinkByHref('admin/structure/views/nojs/display/test_view/page_1/tab_options'); + $this->assertSession()->linkByHrefExists('admin/structure/views/nojs/display/test_view/page_1/tab_options'); // Ensure that you can select a parent in case the parent does not exist. $this->drupalGet('admin/structure/views/nojs/display/test_page_display_menu/page_5/menu'); diff --git a/core/modules/views_ui/tests/src/Functional/FieldUITest.php b/core/modules/views_ui/tests/src/Functional/FieldUITest.php index 4c52aea7..4183deb5 100644 --- a/core/modules/views_ui/tests/src/Functional/FieldUITest.php +++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php @@ -64,7 +64,7 @@ public function testFieldUI() { // Ensure that dialog titles are not escaped. $edit_groupby_url = 'admin/structure/views/nojs/handler/test_view/default/field/name'; - $this->assertNoLinkByHref($edit_groupby_url, 0, 'No aggregation link found.'); + $this->assertSession()->linkByHrefNotExists($edit_groupby_url, 0, 'No aggregation link found.'); // Enable aggregation on the view. $edit = [ @@ -72,7 +72,7 @@ public function testFieldUI() { ]; $this->drupalPostForm('/admin/structure/views/nojs/display/test_view/default/group_by', $edit, t('Apply')); - $this->assertLinkByHref($edit_groupby_url, 0, 'Aggregation link found.'); + $this->assertSession()->linkByHrefExists($edit_groupby_url, 0, 'Aggregation link found.'); $edit_handler_url = '/admin/structure/views/ajax/handler-group/test_view/default/field/name'; $this->drupalGet($edit_handler_url); diff --git a/core/modules/views_ui/tests/src/Functional/GroupByTest.php b/core/modules/views_ui/tests/src/Functional/GroupByTest.php index b393411d..7d707cce 100644 --- a/core/modules/views_ui/tests/src/Functional/GroupByTest.php +++ b/core/modules/views_ui/tests/src/Functional/GroupByTest.php @@ -30,7 +30,7 @@ public function testGroupBySave() { $this->drupalGet('admin/structure/views/view/test_views_groupby_save/edit'); $edit_groupby_url = 'admin/structure/views/nojs/handler-group/test_views_groupby_save/default/field/id'; - $this->assertNoLinkByHref($edit_groupby_url, 0, 'No aggregation link found.'); + $this->assertSession()->linkByHrefNotExists($edit_groupby_url, 0, 'No aggregation link found.'); // Enable aggregation on the view. $edit = [ @@ -38,7 +38,7 @@ public function testGroupBySave() { ]; $this->drupalPostForm('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by', $edit, t('Apply')); - $this->assertLinkByHref($edit_groupby_url, 0, 'Aggregation link found.'); + $this->assertSession()->linkByHrefExists($edit_groupby_url, 0, 'Aggregation link found.'); // Change the groupby type in the UI. $this->drupalPostForm($edit_groupby_url, ['options[group_type]' => 'count'], t('Apply')); diff --git a/core/modules/views_ui/tests/src/Functional/HandlerTest.php b/core/modules/views_ui/tests/src/Functional/HandlerTest.php index 6307502d..feabb5b9 100644 --- a/core/modules/views_ui/tests/src/Functional/HandlerTest.php +++ b/core/modules/views_ui/tests/src/Functional/HandlerTest.php @@ -126,7 +126,7 @@ public function testUICRUD() { // Verify that the user got redirected to the views edit form. $this->assertUrl('admin/structure/views/view/test_view_empty/edit/default'); - $this->assertLinkByHref($edit_handler_url, 0, 'The handler edit link appears in the UI.'); + $this->assertSession()->linkByHrefExists($edit_handler_url, 0, 'The handler edit link appears in the UI.'); $links = $this->xpath('//a[starts-with(normalize-space(text()), :label)]', [':label' => $random_label]); $this->assertTrue(isset($links[0]), 'The handler edit link has the right label'); @@ -138,7 +138,7 @@ public function testUICRUD() { // Remove the item and check that it's removed $this->drupalPostForm($edit_handler_url, [], t('Remove')); - $this->assertNoLinkByHref($edit_handler_url, 0, 'The handler edit link does not appears in the UI after removing.'); + $this->assertSession()->linkByHrefNotExists($edit_handler_url, 0, 'The handler edit link does not appears in the UI after removing.'); $this->drupalPostForm(NULL, [], t('Save')); $view = $this->container->get('entity_type.manager')->getStorage('view')->load('test_view_empty'); diff --git a/core/modules/views_ui/tests/src/Functional/SettingsTest.php b/core/modules/views_ui/tests/src/Functional/SettingsTest.php index f14bb90e..2acd732d 100644 --- a/core/modules/views_ui/tests/src/Functional/SettingsTest.php +++ b/core/modules/views_ui/tests/src/Functional/SettingsTest.php @@ -39,7 +39,7 @@ public function testEditUI() { // Test the settings tab exists. $this->drupalGet('admin/structure/views'); - $this->assertLinkByHref('admin/structure/views/settings'); + $this->assertSession()->linkNotExists('admin/structure/views/settings'); // Test the confirmation message. $this->drupalPostForm('admin/structure/views/settings', [], t('Save configuration')); diff --git a/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php b/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php index be5d1387..6086aa5f 100644 --- a/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php +++ b/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php @@ -76,7 +76,7 @@ public function testUnsavedPageDisplayPreview() { $this->drupalPostForm(NULL, [], t('Update preview')); $this->assertSession()->statusCodeEquals(200); - $this->assertLinkByHref('foobarbaz'); + $this->assertSession()->linkByHrefExists('foobarbaz'); } } diff --git a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php index b7d7b4c5..d036595b 100644 --- a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php +++ b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php @@ -135,7 +135,7 @@ public function testEditFormLanguageOptions() { $this->drupalGet('admin/structure/views/view/' . $view_name); $this->assertSession()->statusCodeEquals(200); $langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language'; - $this->assertNoLinkByHref($langcode_url); + $this->assertSession()->linkByHrefNotExists($langcode_url); $assert_session->linkNotExistsExact('Content language selected for page'); $this->assertSession()->linkNotExists('Content language of view row'); } @@ -152,12 +152,12 @@ public function testEditFormLanguageOptions() { $this->assertSession()->statusCodeEquals(200); $langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language'; if ($view_name == 'test_view') { - $this->assertNoLinkByHref($langcode_url); + $this->assertSession()->linkByHrefNotExists($langcode_url); $assert_session->linkNotExistsExact('Content language selected for page'); $this->assertSession()->linkNotExists('Content language of view row'); } else { - $this->assertLinkByHref($langcode_url); + $this->assertSession()->linkByHrefExists($langcode_url); $assert_session->linkNotExistsExact('Content language selected for page'); $this->assertSession()->linkExists('Content language of view row'); } diff --git a/core/modules/views_ui/tests/src/Functional/ViewsListTest.php b/core/modules/views_ui/tests/src/Functional/ViewsListTest.php index 2753674d..cebbf94f 100644 --- a/core/modules/views_ui/tests/src/Functional/ViewsListTest.php +++ b/core/modules/views_ui/tests/src/Functional/ViewsListTest.php @@ -57,7 +57,7 @@ public function testViewsListLimit() { $this->drupalGet('admin/structure/views'); $links = $this->getSession()->getPage()->findAll('xpath', "//a[contains(@href, 'admin/structure/views/view/content')]"); $this->assertStringEndsWith('admin/structure/views/view/content', $links[0]->getAttribute('href')); - $this->assertLinkByHref('admin/structure/views/view/content/delete?destination'); + $this->assertSession()->linkByHrefExists('admin/structure/views/view/content/delete?destination'); // Count default views to be subtracted from the limit. $views = count(Views::getEnabledViews()); diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php index 513e4417..14b25404 100644 --- a/core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php @@ -235,7 +235,7 @@ public function testPreviewSortLink() { $this->assertTrue(!empty($elements), 'The header label is present.'); // Verify link. - $this->assertLinkByHref('preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=desc', 0, 'The output URL is as expected.'); + $this->assertSession()->linkByHrefExists('preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=desc', 0, 'The output URL is as expected.'); // Click link to sort. $elements[0]->click(); @@ -244,7 +244,7 @@ public function testPreviewSortLink() { $this->assertNotEmpty($sort_link); // Verify link. - $this->assertLinkByHref('preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=asc', 0, 'The output URL is as expected.'); + $this->assertSession()->linkByHrefExists('preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=asc', 0, 'The output URL is as expected.'); } /** diff --git a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php index 29125b62..63c62f5e 100644 --- a/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php +++ b/core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php @@ -237,6 +237,30 @@ public function testPass() { $this->pass('Passed.'); } + /** + * @covers ::assertLinkByHref + * @expectedDeprecation AssertLegacyTrait::assertLinkByHref() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->linkByHrefExists() instead. See https://www.drupal.org/node/3129738 + */ + public function testAssertLinkByHref() { + $this->webAssert + ->linkByHrefExists('boo', 0) + ->shouldBeCalled(); + + $this->assertLinkByHref('boo', 0); + } + + /** + * @covers ::assertNoLinkByHref + * @expectedDeprecation AssertLegacyTrait::assertNoLinkByHref() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->linkByHrefNotExists() instead. See https://www.drupal.org/node/3129738 + */ + public function testAssertNoLinkByHref() { + $this->webAssert + ->linkByHrefNotExists('boo') + ->shouldBeCalled(); + + $this->testAssertNoLinkByHref('boo'); + } + /** * @covers ::constructFieldXpath * @expectedDeprecation AssertLegacyTrait::constructFieldXpath() is deprecated in drupal:8.5.0 and is removed from drupal:10.0.0. Use $this->getSession()->getPage()->findField() instead. See https://www.drupal.org/node/3129738 diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 1ab62580..5a28b4aa 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -134,8 +134,6 @@ public static function getSkippedDeprecations() { 'AssertLegacyTrait::assertFieldById() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertNoRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() instead. See https://www.drupal.org/node/3129738', - 'AssertLegacyTrait::assertLinkByHref() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->linkByHrefExists() instead. See https://www.drupal.org/node/3129738', - 'AssertLegacyTrait::assertNoLinkByHref() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->linkByHrefNotExists() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertNoFieldById() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists() or $this->assertSession()->fieldValueNotEquals() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertUrl() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertFieldByXPath() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and check the values directly in the test. See https://www.drupal.org/node/3129738',