diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php index 224a69c7ddcd740778bb695af50ef0f3f8d14255..ef0dffe7b0cddf6db00025f0c58ecd0721bb3154 100644 --- a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php @@ -35,7 +35,7 @@ public function testAddFeed() { // Check feed source. $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, 'Feed source exists.'); + $this->assertResponse(200); $this->assertText($feed->label(), 'Page title'); $this->assertRaw($feed->getWebsiteUrl()); @@ -91,7 +91,7 @@ public function testAddLongFeed() { // Check feed source. $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, 'Long URL feed source exists.'); + $this->assertResponse(200); $this->assertText($feed->label(), 'Page title'); // Delete feeds. diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php index ae3ef759a93eaa1df0eaa05620c098b75812d7fa..09c05073c036a61f8ddef947af2345b4f6acb445 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php @@ -181,7 +181,7 @@ public function getDefaultFeedItemCount() { public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) { // First, let's ensure we can get to the rss xml. $this->drupalGet($feed->getUrl()); - $this->assertResponse(200, new FormattableMarkup(':url is reachable.', [':url' => $feed->getUrl()])); + $this->assertResponse(200); // Attempt to access the update link directly without an access token. $this->drupalGet('admin/config/services/aggregator/update/' . $feed->id()); diff --git a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php index ceecc857078d86816cf3e3b2cea0e8b4d778c3ac..192ef47133e0bc0ccd419d74d2ded25d7d045667 100644 --- a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php @@ -45,7 +45,7 @@ public function testDeleteFeed() { // Check feed source. $this->drupalGet('aggregator/sources/' . $feed1->id()); - $this->assertResponse(404, 'Deleted feed source does not exist.'); + $this->assertResponse(404); // Check database for feed. $result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed1->label())->condition('url', $feed1->getUrl())->count()->execute(); diff --git a/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php b/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php index ec327a595e72e870c1adcc89c4fbae67645139c9..e83128c05cdc7cddb37a022b95c8b84374ddd220 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php @@ -22,7 +22,7 @@ public function testFeedUpdateFields() { $scheduled_feed = $this->createFeed(NULL, ['refresh' => '900']); $this->drupalGet('admin/config/services/aggregator'); - $this->assertResponse(200, 'Aggregator feed overview page exists.'); + $this->assertResponse(200); // The scheduled feed shows that it has not been updated yet and is // scheduled. diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php index 2926c8ae7013b70bcc5427621544510488692007..63c7ac1706207b3f1aa1918906460d5b34e78e24 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\aggregator\Functional; -use Drupal\Component\Render\FormattableMarkup; use Drupal\aggregator\FeedStorageInterface; use Drupal\Core\Url; use Drupal\aggregator\Entity\Feed; @@ -38,7 +37,7 @@ public function testRSS091Sample() { $feed = $this->createFeed($this->getRSS091Sample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, new FormattableMarkup('Feed %name exists.', ['%name' => $feed->label()])); + $this->assertResponse(200); $this->assertText('First example feed item title'); $this->assertLinkByHref('http://example.com/example-turns-one'); $this->assertText('First example feed item description.'); @@ -61,7 +60,7 @@ public function testAtomSample() { $feed = $this->createFeed($this->getAtomSample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, new FormattableMarkup('Feed %name exists.', ['%name' => $feed->label()])); + $this->assertResponse(200); $this->assertText('Atom-Powered Robots Run Amok'); $this->assertLinkByHref('http://example.org/2003/12/13/atom03'); $this->assertText('Some text.'); @@ -85,7 +84,7 @@ public function testHtmlEntitiesSample() { $feed = $this->createFeed($this->getHtmlEntitiesSample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, new FormattableMarkup('Feed %name exists.', ['%name' => $feed->label()])); + $this->assertResponse(200); $this->assertRaw("Quote" Amp&"); } diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php index a7ee2436cadf590ac6337ebaf760d40823c4feaa..8f17ceb0a6d46e33f9a9ff0123af6740f691b83e 100644 --- a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php @@ -44,7 +44,7 @@ public function testUpdateFeed() { // Check feed source. $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, 'Feed source exists.'); + $this->assertResponse(200); $this->assertText($edit['title[0][value]'], 'Page title'); // Set correct title so deleteFeed() will work. diff --git a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php index d2ebf8d6b5b45d5791677863d3b8d40e7326bcf9..47282b52616a95f794b7c70392128eed5d914f75 100644 --- a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php +++ b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php @@ -47,31 +47,37 @@ public function testBasicAuth() { $account = $this->drupalCreateUser(); $url = Url::fromRoute('router_test.11'); + // Ensure we can log in with valid authentication details. $this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw); $this->assertText($account->getAccountName(), 'Account name is displayed.'); - $this->assertResponse('200', 'HTTP response is OK'); + $this->assertResponse(200); $this->mink->resetSessions(); $this->assertNull($this->drupalGetHeader('X-Drupal-Cache')); // Check that Cache-Control is not set to public. $this->assertSession()->responseHeaderNotContains('Cache-Control', 'public'); + // Ensure that invalid authentication details give access denied. $this->basicAuthGet($url, $account->getAccountName(), $this->randomMachineName()); $this->assertNoText($account->getAccountName(), 'Bad basic auth credentials do not authenticate the user.'); - $this->assertResponse('403', 'Access is not granted.'); + $this->assertResponse(403); $this->mink->resetSessions(); + // Ensure that the user is prompted to authenticate if they are not yet + // authenticated and the route only allows basic auth. $this->drupalGet($url); $this->assertEqual($this->drupalGetHeader('WWW-Authenticate'), new FormattableMarkup('Basic realm="@realm"', ['@realm' => \Drupal::config('system.site')->get('name')])); - $this->assertResponse('401', 'Not authenticated on the route that allows only basic_auth. Prompt to authenticate received.'); + $this->assertResponse(401); + // Ensure that a route without basic auth defined doesn't prompt for auth. $this->drupalGet('admin'); - $this->assertResponse('403', 'No authentication prompt for routes not explicitly defining authentication providers.'); + $this->assertResponse(403); $account = $this->drupalCreateUser(['access administration pages']); + // Ensure that a route without basic auth defined doesn't allow login. $this->basicAuthGet(Url::fromRoute('system.admin'), $account->getAccountName(), $account->pass_raw); $this->assertNoLink('Log out', 'User is not logged in'); - $this->assertResponse('403', 'No basic authentication for routes not explicitly defining authentication providers.'); + $this->assertResponse(403); $this->mink->resetSessions(); // Ensure that pages already in the page cache aren't returned from page @@ -107,7 +113,7 @@ public function testGlobalLoginFloodControl() { // IP limit has reached to its limit. Even valid user credentials will fail. $this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw); - $this->assertResponse('403', 'Access is blocked because of IP based flood prevention.'); + $this->assertResponse(403); } /** @@ -131,7 +137,7 @@ public function testPerUserLoginFloodControl() { // A successful login will reset the per-user flood control count. $this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw); - $this->assertResponse('200', 'Per user flood prevention gets reset on a successful login.'); + $this->assertResponse(200); // Try 2 failed logins for a user. They will trigger flood control. for ($i = 0; $i < 2; $i++) { @@ -140,12 +146,12 @@ public function testPerUserLoginFloodControl() { // Now the user account is blocked. $this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw); - $this->assertResponse('403', 'The user account is blocked due to per user flood prevention.'); + $this->assertResponse(403); // Try one successful attempt for a different user, it should not trigger // any flood control. $this->basicAuthGet($url, $user2->getAccountName(), $user2->pass_raw); - $this->assertResponse('200', 'Per user flood prevention does not block access for other users.'); + $this->assertResponse(200); } /** @@ -160,7 +166,7 @@ public function testLocale() { $this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw); $this->assertText($account->getAccountName(), 'Account name is displayed.'); - $this->assertResponse('200', 'HTTP response is OK'); + $this->assertResponse(200); } /** @@ -172,24 +178,24 @@ public function testUnauthorizedErrorMessage() { // Case when no credentials are passed. $this->drupalGet($url); - $this->assertResponse('401', 'The user is blocked when no credentials are passed.'); + $this->assertResponse(401); $this->assertNoText('Exception', "No raw exception is displayed on the page."); $this->assertText('Please log in to access this page.', "A user friendly access unauthorized message is displayed."); // Case when empty credentials are passed. $this->basicAuthGet($url, NULL, NULL); - $this->assertResponse('403', 'The user is blocked when empty credentials are passed.'); + $this->assertResponse(403); $this->assertText('Access denied', "A user friendly access denied message is displayed"); // Case when wrong credentials are passed. $this->basicAuthGet($url, $account->getAccountName(), $this->randomMachineName()); - $this->assertResponse('403', 'The user is blocked when wrong credentials are passed.'); + $this->assertResponse(403); $this->assertText('Access denied', "A user friendly access denied message is displayed"); // Case when correct credentials but hasn't access to the route. $url = Url::fromRoute('router_test.15'); $this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw); - $this->assertResponse('403', 'The used authentication method is not allowed on this route.'); + $this->assertResponse(403); $this->assertText('Access denied', "A user friendly access denied message is displayed"); } diff --git a/core/modules/block/tests/src/Functional/BlockUiTest.php b/core/modules/block/tests/src/Functional/BlockUiTest.php index dd65d2f3d90aff162d45fd8351b055d86f3738cf..185e1c198e7ad838d1c82a7d75d2875bd1a5f686 100644 --- a/core/modules/block/tests/src/Functional/BlockUiTest.php +++ b/core/modules/block/tests/src/Functional/BlockUiTest.php @@ -94,13 +94,15 @@ public function testBlockDemoUiPage() { $elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', [':title' => 'Highlighted']); $this->assertTrue(!empty($elements), 'Block demo regions are shown.'); + // Ensure that other themes can use the block demo page. \Drupal::service('theme_installer')->install(['test_theme']); $this->drupalGet('admin/structure/block/demo/test_theme'); $this->assertEscaped('<strong>Test theme</strong>'); + // Ensure that a hidden theme cannot use the block demo page. \Drupal::service('theme_installer')->install(['stable']); $this->drupalGet('admin/structure/block/demo/stable'); - $this->assertResponse(404, 'Hidden themes that are not the default theme are not supported by the block demo screen'); + $this->assertResponse(404); } /** @@ -159,16 +161,19 @@ public function testBlockAdminUiPage() { $this->assertLink($theme_handler->getName('stark')); $this->assertNoLink($theme_handler->getName('stable')); + // Ensure that a hidden theme cannot use the block demo page. $this->drupalGet('admin/structure/block/list/stable'); - $this->assertResponse(404, 'Placing blocks through UI is not possible for a hidden base theme.'); + $this->assertResponse(404); + // Ensure that a hidden theme set as the admin theme can use the block demo + // page. \Drupal::configFactory()->getEditable('system.theme')->set('admin', 'stable')->save(); \Drupal::service('router.builder')->rebuildIfNeeded(); $this->drupalPlaceBlock('local_tasks_block', ['region' => 'header', 'theme' => 'stable']); $this->drupalGet('admin/structure/block'); $this->assertLink($theme_handler->getName('stable')); $this->drupalGet('admin/structure/block/list/stable'); - $this->assertResponse(200, 'Placing blocks through UI is possible for a hidden base theme that is the admin theme.'); + $this->assertResponse(200); } /** diff --git a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php index 79771cc82a427ebbedc6e759291fd512e425388c..b77fe3e01c89bce74042778e4fec7b5f51419ba5 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php @@ -31,8 +31,8 @@ public function testPageEdit() { // Attempt to view the block. $this->drupalGet('block-content/' . $block->id()); - // Assert response was '200' and not '403 Access denied'. - $this->assertResponse('200', 'User was able the view the block'); + // Ensure user was able to view the block. + $this->assertResponse(200); $this->drupalGet('<front>'); $this->assertRaw(t('This block is broken or missing. You may be missing content or you might need to enable the original module.')); } diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 4f413c45dfadc44b931df89679e68dae865f37d9..f5e0248cc0827a9045ac285ed9335a6e6b349321 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -214,11 +214,11 @@ public function testBookExport() { // Make sure we can't export an unsupported format. $this->drupalGet('book/export/foobar/' . $this->book->id()); - $this->assertResponse('404', 'Unsupported export format returned "not found".'); + $this->assertResponse(404); // Make sure we get a 404 on a not existing book node. $this->drupalGet('book/export/html/123'); - $this->assertResponse('404', 'Not existing book node returned "not found".'); + $this->assertResponse(404); // Make sure an anonymous user cannot view printer-friendly version. $this->drupalLogout(); @@ -229,14 +229,14 @@ public function testBookExport() { // Try getting the URL directly, and verify it fails. $this->drupalGet('book/export/html/' . $this->book->id()); - $this->assertResponse('403', 'Anonymous user properly forbidden.'); + $this->assertResponse(403); // Now grant anonymous users permission to view the printer-friendly // version and verify that node access restrictions still prevent them from // seeing it. user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access printer-friendly version']); $this->drupalGet('book/export/html/' . $this->book->id()); - $this->assertResponse('403', 'Anonymous user properly forbidden from seeing the printer-friendly version when denied by node access.'); + $this->assertResponse(403); } /** @@ -356,9 +356,11 @@ public function testBookDelete() { $this->drupalLogin($this->adminUser); $edit = []; - // Test access to delete top-level and child book nodes. + // Ensure that the top-level book node cannot be deleted. $this->drupalGet('node/' . $this->book->id() . '/outline/remove'); - $this->assertResponse('403', 'Deleting top-level book node properly forbidden.'); + $this->assertResponse(403); + + // Ensure that a child book node can be deleted. $this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove')); $node_storage->resetCache([$nodes[4]->id()]); $node4 = $node_storage->load($nodes[4]->id()); diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php index ee14db28ff290a90de29a97cf8b272465608a19d..08d65f9df4e885c4b31d9307a0d4a69b895da015 100644 --- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php @@ -156,12 +156,14 @@ public function testApprovalNodeInterface() { $this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.'); - // Approve comment. + // Ensure comments cannot be approved without a valid token. $this->drupalLogin($this->adminUser); $this->drupalGet('comment/1/approve'); - $this->assertResponse(403, 'Forged comment approval was denied.'); + $this->assertResponse(403); $this->drupalGet('comment/1/approve', ['query' => ['token' => 'forged']]); - $this->assertResponse(403, 'Forged comment approval was denied.'); + $this->assertResponse(403); + + // Approve comment. $this->drupalGet('comment/1/edit'); $this->assertFieldChecked('edit-status-0'); $this->drupalGet('node/' . $this->node->id()); diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php index f6568ca93421fd00ad03219b957913fde98ab583..5d02fb8532bbc92602cff60fe1a3b2082969a103 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -64,8 +64,9 @@ public function testCommentTypeCreation() { // Log in a test user. $this->drupalLogin($this->adminUser); + // Ensure that the new comment type admin page can be accessed. $this->drupalGet('admin/structure/comment/manage/' . $type->id()); - $this->assertResponse(200, 'The new comment type can be accessed at the edit form.'); + $this->assertResponse(200); // Create a comment type via the user interface. $edit = [ diff --git a/core/modules/config/tests/src/Functional/ConfigExportUITest.php b/core/modules/config/tests/src/Functional/ConfigExportUITest.php index 46afdf6479c472763ad005aaa324937610282785..5598cca7802d3ace2184332b9550b5efb0c24b86 100644 --- a/core/modules/config/tests/src/Functional/ConfigExportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigExportUITest.php @@ -53,7 +53,7 @@ public function testExport() { // Submit the export form and verify response. This will create a file in // temporary directory with the default name config.tar.gz. $this->drupalPostForm('admin/config/development/configuration/full/export', [], t('Export')); - $this->assertResponse(200, 'User can access the download callback.'); + $this->assertResponse(200); // Test if header contains file name with hostname and timestamp. $request = \Drupal::request(); diff --git a/core/modules/contact/tests/src/Functional/ContactLanguageTest.php b/core/modules/contact/tests/src/Functional/ContactLanguageTest.php index 7b3afeefe4df7f2e27864272b1a61d9671f3d5bd..a2d716161679ba23ccee8e1de7af1e5ba0f230f8 100644 --- a/core/modules/contact/tests/src/Functional/ContactLanguageTest.php +++ b/core/modules/contact/tests/src/Functional/ContactLanguageTest.php @@ -51,7 +51,7 @@ protected function setUp(): void { public function testContactLanguage() { // Ensure that contact form by default does not show the language select. $this->drupalGet('contact'); - $this->assertResponse(200, 'The page exists'); + $this->assertResponse(200); $this->assertNoField('edit-langcode-0-value'); // Enable language select from content language settings page. @@ -62,7 +62,7 @@ public function testContactLanguage() { // Ensure that contact form now shows the language select. $this->drupalGet('contact'); - $this->assertResponse(200, 'The page exists'); + $this->assertResponse(200); $this->assertField('edit-langcode-0-value'); } diff --git a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php index 5a978ac6150c138763879083c0135f3d44b77389..3e956722cb45ea6dafd134405d82024da7094e15 100644 --- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php +++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php @@ -137,7 +137,7 @@ public function testPersonalContactAccess() { $original_email = $this->contactUser->getEmail(); $this->contactUser->setEmail(FALSE)->save(); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(404, 'Not found (404) returned when visiting a personal contact form for a user with no email address'); + $this->assertResponse(404); // Test that the 'contact tab' does not appear on the user profiles // for users without an email address configured. diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php index 2d360d224917cacf6bd8faa67e2082f8c33d391b..89c7ad93b090d194ce2453a2010a73b1953e8b53 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php @@ -83,7 +83,7 @@ protected function doTestBasicTranslation() { $entity = $storage->load($this->entityId); $this->assertNotEmpty($entity, 'Entity found in the database.'); $this->drupalGet($entity->toUrl()); - $this->assertResponse(200, 'Entity URL is valid.'); + $this->assertResponse(200); // Ensure that the content language cache context is not yet added to the // page. diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php index 35f782fd59b9250385c9b1757eedb2421ab5de3b..c0f27d038ec3f7de39b21d10633f7e80dac0de94 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php @@ -163,26 +163,25 @@ public function testWorkflows() { protected function doTestWorkflows(UserInterface $user, $expected_status) { $default_langcode = $this->langcodes[0]; $languages = $this->container->get('language_manager')->getLanguages(); - $args = ['@user_label' => $user->getAccountName()]; $options = ['language' => $languages[$default_langcode], 'absolute' => TRUE]; $this->drupalLogin($user); // Check whether the user is allowed to access the entity form in edit mode. $edit_url = $this->entity->toUrl('edit-form', $options); $this->drupalGet($edit_url, $options); - $this->assertResponse($expected_status['edit'], new FormattableMarkup('The @user_label has the expected edit access.', $args)); + $this->assertResponse($expected_status['edit']); // Check whether the user is allowed to access the entity delete form. $delete_url = $this->entity->toUrl('delete-form', $options); $this->drupalGet($delete_url, $options); - $this->assertResponse($expected_status['delete'], new FormattableMarkup('The @user_label has the expected delete access.', $args)); + $this->assertResponse($expected_status['delete']); // Check whether the user is allowed to access the translation overview. $langcode = $this->langcodes[1]; $options['language'] = $languages[$langcode]; $translations_url = $this->entity->toUrl('drupal:content-translation-overview', $options)->toString(); $this->drupalGet($translations_url); - $this->assertResponse($expected_status['overview'], new FormattableMarkup('The @user_label has the expected translation overview access.', $args)); + $this->assertResponse($expected_status['overview']); // Check whether the user is allowed to create a translation. $add_translation_url = Url::fromRoute("entity.$this->entityTypeId.content_translation_add", [$this->entityTypeId => $this->entity->id(), 'source' => $default_langcode, 'target' => $langcode], $options); @@ -198,7 +197,7 @@ protected function doTestWorkflows(UserInterface $user, $expected_status) { else { $this->drupalGet($add_translation_url); } - $this->assertResponse($expected_status['add_translation'], new FormattableMarkup('The @user_label has the expected translation creation access.', $args)); + $this->assertResponse($expected_status['add_translation']); // Check whether the user is allowed to edit a translation. $langcode = $this->langcodes[2]; @@ -226,7 +225,7 @@ protected function doTestWorkflows(UserInterface $user, $expected_status) { else { $this->drupalGet($edit_translation_url); } - $this->assertResponse($expected_status['edit_translation'], new FormattableMarkup('The @user_label has the expected translation edit access.', $args)); + $this->assertResponse($expected_status['edit_translation']); // Check whether the user is allowed to delete a translation. $langcode = $this->langcodes[2]; @@ -254,7 +253,7 @@ protected function doTestWorkflows(UserInterface $user, $expected_status) { else { $this->drupalGet($delete_translation_url); } - $this->assertResponse($expected_status['delete_translation'], new FormattableMarkup('The @user_label has the expected translation deletion access.', $args)); + $this->assertResponse($expected_status['delete_translation']); } /** diff --git a/core/modules/file/tests/src/Functional/DownloadTest.php b/core/modules/file/tests/src/Functional/DownloadTest.php index 551edcdca068d7f9b50122a12df15e5537f26cbc..3b5090546ccd77c159dbff048d495ec58cb32f60 100644 --- a/core/modules/file/tests/src/Functional/DownloadTest.php +++ b/core/modules/file/tests/src/Functional/DownloadTest.php @@ -77,7 +77,7 @@ protected function doPrivateFileTransferTest() { $this->drupalGet($url); $this->assertEqual($this->drupalGetHeader('x-foo'), 'Bar', 'Found header set by file_test module on private download.'); $this->assertNull($this->drupalGetHeader('x-drupal-cache'), 'Page cache is disabled on private file download.'); - $this->assertResponse(200, 'Correctly allowed access to a file when file_test provides headers.'); + $this->assertResponse(200); // Ensure hook_file_download is fired correctly. $this->assertEquals($file->getFileUri(), \Drupal::state()->get('file_test.results')['download'][0][0]); diff --git a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php index 48937fe4ee43545b684d15877c75b63f18842a49..1c0b398d53bbce23b0f0f49791d465babc1c8a03 100644 --- a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php @@ -40,7 +40,7 @@ public function testAnonymousNode() { // Load the node form. $this->drupalLogout(); $this->drupalGet('node/add/article'); - $this->assertResponse(200, 'Loaded the article node form.'); + $this->assertResponse(200); $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); $edit = [ @@ -71,7 +71,7 @@ public function testAnonymousNodeWithFile() { // Load the node form. $this->drupalLogout(); $this->drupalGet('node/add/article'); - $this->assertResponse(200, 'Loaded the article node form.'); + $this->assertResponse(200); $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); // Generate an image file. @@ -128,7 +128,7 @@ protected function doTestNodeWithFileWithoutTitle() { // Load the node form. $this->drupalGet('node/add/article'); - $this->assertResponse(200, 'Loaded the article node form.'); + $this->assertResponse(200); $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); // Generate an image file. diff --git a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php index eb29d644a9a23d93bed2aa5a90f2e182a6aea2b5..f2821a800c94b210674401acab9ebc688ddb93e6 100644 --- a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php @@ -93,7 +93,7 @@ public function testSingleValuedWidget() { // Ensure the file can be downloaded. $this->drupalGet($node_file->createFileUrl()); - $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); + $this->assertResponse(200); // Ensure the edit page has a remove button instead of an upload button. $this->drupalGet("node/$nid/edit"); @@ -267,7 +267,7 @@ public function testPrivateFileSetting() { // Ensure the private file is available to the user who uploaded it. $this->drupalGet($node_file->createFileUrl()); - $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); + $this->assertResponse(200); // Ensure we can't change 'uri_scheme' field settings while there are some // entities with uploaded files. @@ -335,12 +335,12 @@ public function testPrivateFileComment() { $url = $comment_file->createFileUrl(); $this->assertNotEqual($url, NULL, 'Confirmed that the URL is valid'); $this->drupalGet($comment_file->createFileUrl()); - $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); + $this->assertResponse(200); - // Test anonymous file download. + // Ensure that the anonymous user cannot download the file. $this->drupalLogout(); $this->drupalGet($comment_file->createFileUrl()); - $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); + $this->assertResponse(403); // Unpublishes node. $this->drupalLogin($this->adminUser); @@ -350,7 +350,7 @@ public function testPrivateFileComment() { // Ensures normal user can no longer download the file. $this->drupalLogin($user); $this->drupalGet($comment_file->createFileUrl()); - $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); + $this->assertResponse(403); } /** @@ -512,7 +512,7 @@ protected function doTestTemporaryFileRemovalExploit(UserInterface $victim_user, // Ensure the file can be downloaded. $this->drupalGet($node_file->createFileUrl()); - $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); + $this->assertResponse(200); // "Click" the remove button (emulating either a nojs or js submission). // In this POST request, the attacker "guesses" the fid of the victim's diff --git a/core/modules/file/tests/src/Functional/FilePrivateTest.php b/core/modules/file/tests/src/Functional/FilePrivateTest.php index 9b2a3977634c05423881eda5761a4a0f9b28be9a..a765bbab93e10d4fb2b9ad462901af1e4b2dbe54 100644 --- a/core/modules/file/tests/src/Functional/FilePrivateTest.php +++ b/core/modules/file/tests/src/Functional/FilePrivateTest.php @@ -60,10 +60,11 @@ public function testPrivateFile() { $this->assertRaw($node_file->getFilename(), 'File reference is displayed after attaching it'); // Ensure the file can be downloaded. $this->drupalGet(file_create_url($node_file->getFileUri())); - $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); + $this->assertResponse(200); $this->drupalLogOut(); + // Ensure the file cannot be downloaded after logging out. $this->drupalGet(file_create_url($node_file->getFileUri())); - $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); + $this->assertResponse(403); // Create a field with no view access. See // field_test_entity_field_access(). @@ -79,7 +80,7 @@ public function testPrivateFile() { // Ensure the file cannot be downloaded. $file_url = file_create_url($node_file->getFileUri()); $this->drupalGet($file_url); - $this->assertResponse(403, 'Confirmed that access is denied for the file without view field access permission.'); + $this->assertResponse(403); // Attempt to reuse the file when editing a node. $edit = []; @@ -114,20 +115,20 @@ public function testPrivateFile() { \Drupal::state()->set('file_test.allow_all', TRUE); // Delete the node. $node->delete(); - // Ensure the file can still be downloaded by the owner. + // Ensure the temporary file can still be downloaded by the owner. $this->drupalGet($file_url); - $this->assertResponse(200, 'Confirmed that the owner still has access to the temporary file.'); + $this->assertResponse(200); - // Ensure the file cannot be downloaded by an anonymous user. + // Ensure the temporary file cannot be downloaded by an anonymous user. $this->drupalLogout(); $this->drupalGet($file_url); - $this->assertResponse(403, 'Confirmed that access is denied for an anonymous user to the temporary file.'); + $this->assertResponse(403); - // Ensure the file cannot be downloaded by another user. + // Ensure the temporary file cannot be downloaded by another user. $account = $this->drupalCreateUser(); $this->drupalLogin($account); $this->drupalGet($file_url); - $this->assertResponse(403, 'Confirmed that access is denied for another user to the temporary file.'); + $this->assertResponse(403); // As an anonymous user, create a temporary file with no references and // confirm that only the session that uploaded it may view it. @@ -152,12 +153,14 @@ public function testPrivateFile() { $usage = $this->container->get('file.usage')->listUsage($file); $this->assertEmpty($usage, 'No file usage found.'); $file_url = file_create_url($file->getFileUri()); + // Ensure the anonymous uploader has access to the temporary file. $this->drupalGet($file_url); - $this->assertResponse(200, 'Confirmed that the anonymous uploader has access to the temporary file.'); + $this->assertResponse(200); // Close the prior connection and remove the session cookie. $this->getSession()->reset(); + // Ensure that a different anonymous user cannot access the temporary file. $this->drupalGet($file_url); - $this->assertResponse(403, 'Confirmed that another anonymous user cannot access the temporary file.'); + $this->assertResponse(403); // As an anonymous user, create a permanent file, then remove all // references to the file (so that it becomes temporary again) and confirm @@ -180,12 +183,14 @@ public function testPrivateFile() { $usage = $this->container->get('file.usage')->listUsage($file); $this->assertEmpty($usage, 'No file usage found.'); $file_url = file_create_url($file->getFileUri()); + // Ensure the anonymous uploader has access to the temporary file. $this->drupalGet($file_url); - $this->assertResponse(200, 'Confirmed that the anonymous uploader has access to the file whose references were removed.'); + $this->assertResponse(200); // Close the prior connection and remove the session cookie. $this->getSession()->reset(); + // Ensure that a different anonymous user cannot access the temporary file. $this->drupalGet($file_url); - $this->assertResponse(403, 'Confirmed that another anonymous user cannot access the file whose references were removed.'); + $this->assertResponse(403); // As an anonymous user, create a permanent file that is referenced by a // published node and confirm that all anonymous users may view it. @@ -201,12 +206,14 @@ public function testPrivateFile() { $usage = $this->container->get('file.usage')->listUsage($file); $this->assertCount(1, $usage, 'File usage found.'); $file_url = file_create_url($file->getFileUri()); + // Ensure the anonymous uploader has access to the file. $this->drupalGet($file_url); - $this->assertResponse(200, 'Confirmed that the anonymous uploader has access to the permanent file that is referenced by a published node.'); + $this->assertResponse(200); // Close the prior connection and remove the session cookie. $this->getSession()->reset(); + // Ensure that a different anonymous user can access the file. $this->drupalGet($file_url); - $this->assertResponse(200, 'Confirmed that another anonymous user also has access to the permanent file that is referenced by a published node.'); + $this->assertResponse(200); // As an anonymous user, create a permanent file that is referenced by an // unpublished node and confirm that no anonymous users may view it (even @@ -226,12 +233,14 @@ public function testPrivateFile() { $usage = $this->container->get('file.usage')->listUsage($file); $this->assertCount(1, $usage, 'File usage found.'); $file_url = file_create_url($file->getFileUri()); + // Ensure the anonymous uploader cannot access to the file. $this->drupalGet($file_url); - $this->assertResponse(403, 'Confirmed that the anonymous uploader cannot access the permanent file when it is referenced by an unpublished node.'); + $this->assertResponse(403); // Close the prior connection and remove the session cookie. $this->getSession()->reset(); + // Ensure that a different anonymous user cannot access the temporary file. $this->drupalGet($file_url); - $this->assertResponse(403, 'Confirmed that another anonymous user cannot access the permanent file when it is referenced by an unpublished node.'); + $this->assertResponse(403); } } diff --git a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php index 20ea56bf18a0a2808d0d716231b1f5b038120c6d..1668274bc426c097bc82e6bafd5229e21632c24f 100644 --- a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php +++ b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php @@ -96,7 +96,7 @@ public function testPrivateLanguageFile() { $node = Node::load($default_language_node->id()); $node_file = File::load($node->{$this->fieldName}->target_id); $this->drupalGet(file_create_url($node_file->getFileUri())); - $this->assertResponse(200, 'Confirmed that the file attached to the English node can be downloaded.'); + $this->assertResponse(200); // Translate the node into French. $this->drupalGet('node/' . $default_language_node->id() . '/translations'); @@ -123,7 +123,7 @@ public function testPrivateLanguageFile() { $french_node = $default_language_node->getTranslation('fr'); $node_file = File::load($french_node->{$this->fieldName}->target_id); $this->drupalGet(file_create_url($node_file->getFileUri())); - $this->assertResponse(200, 'Confirmed that the file attached to the French node can be downloaded.'); + $this->assertResponse(200); } } diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php index 6b8211be6aa22e8cade0fab99bca14229fab3f8f..072c5007d9a6208c299dc14ebcc686ce22f1b05d 100644 --- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php +++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php @@ -86,7 +86,7 @@ protected function setUp(): void { 'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called then clean out the hook @@ -115,7 +115,7 @@ public function testNormal() { $file_system = \Drupal::service('file_system'); $edit = ['files[file_test_upload][]' => $file_system->realpath($image2->uri)]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!')); $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; @@ -141,7 +141,7 @@ public function testNormal() { 'file_subdir' => $dir, ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!')); $this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath))); } @@ -164,7 +164,7 @@ public function testHandleExtension() { ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $extensions . '</em>'; $this->assertRaw($message, 'Cannot upload a disallowed extension'); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); @@ -184,7 +184,7 @@ public function testHandleExtension() { ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload an allowed extension.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -201,7 +201,7 @@ public function testHandleExtension() { 'allow_all_extensions' => TRUE, ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload any extension.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -226,7 +226,7 @@ public function testHandleDangerousFile() { ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '.txt' . '</em>'; $this->assertRaw($message, 'Dangerous file was renamed.'); $this->assertRaw(t('File MIME type is text/plain.'), "Dangerous file's MIME type was changed."); @@ -242,7 +242,7 @@ public function testHandleDangerousFile() { file_test_reset(); $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.'); $this->assertRaw(t('File name is @filename', ['@filename' => $this->phpfile->filename]), 'Dangerous file was not renamed when insecure uploads is TRUE.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -278,7 +278,7 @@ public function testHandleFileMunge() { $munged_filename .= '_.' . $this->imageExtension; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.'); $this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -296,7 +296,7 @@ public function testHandleFileMunge() { ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.'); $this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -316,7 +316,7 @@ public function testExistingRename() { 'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. @@ -334,7 +334,7 @@ public function testExistingReplace() { 'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called. @@ -352,7 +352,7 @@ public function testExistingError() { 'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Check that the no hooks were called while failing. @@ -385,7 +385,7 @@ public function testDrupalMovingUploadedFileError() { \Drupal::state()->set('file_test.disable_error_collection', TRUE); $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('File upload error. Could not move uploaded file.'), 'Found the failure message.'); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); @@ -411,7 +411,7 @@ public function testErrorMessagesAreNotChanged() { 'error_message' => $error, ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Ensure the expected error message is present and the counts before and @@ -427,7 +427,7 @@ public function testErrorMessagesAreNotChanged() { 'extensions' => 'foo', ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Ensure the expected error message is present and the counts before and @@ -441,7 +441,7 @@ public function testErrorMessagesAreNotChanged() { 'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Ensure the error message is not present and the counts before and after @@ -475,8 +475,7 @@ public function testCombinedErrorMessages() { $files['files']['file_test_upload'][0] = $file_system->realpath($this->phpfile->uri); $files['files']['file_test_upload'][1] = $file_system->realpath($textfile->uri); $client->request($form->getMethod(), $form->getUri(), $edit, $files); - - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Search for combined error message followed by a formatted list of messages. @@ -496,7 +495,7 @@ public function testUploadFieldIsHighlighted() { 'extensions' => 'foo', ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); $this->assertCount(1, $this->cssSelect('input[name="files[file_test_upload][]"].error'), 'File upload field has error.'); } diff --git a/core/modules/file/tests/src/Functional/SaveUploadTest.php b/core/modules/file/tests/src/Functional/SaveUploadTest.php index 68e6becc589503063bf8d6b2e8a80f09db64cdbc..caf01b1669f462c0e9f05b695e098d80d7247db0 100644 --- a/core/modules/file/tests/src/Functional/SaveUploadTest.php +++ b/core/modules/file/tests/src/Functional/SaveUploadTest.php @@ -81,7 +81,7 @@ protected function setUp(): void { 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Check that the correct hooks were called then clean out the hook @@ -108,7 +108,7 @@ public function testNormal() { $image2 = current($this->drupalGetTestFiles('image')); $edit = ['files[file_test_upload]' => \Drupal::service('file_system')->realpath($image2->uri)]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!')); $max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max']; @@ -134,7 +134,7 @@ public function testNormal() { 'file_subdir' => $dir, ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!')); $this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath))); } @@ -184,7 +184,7 @@ public function testHandleExtension() { ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $message = t('Only files with the following extensions are allowed:') . ' <em class="placeholder">' . $extensions . '</em>'; $this->assertRaw($message, 'Cannot upload a disallowed extension'); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); @@ -204,7 +204,7 @@ public function testHandleExtension() { ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload an allowed extension.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -221,7 +221,7 @@ public function testHandleExtension() { 'allow_all_extensions' => TRUE, ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload any extension.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -244,7 +244,7 @@ public function testHandleDangerousFile() { ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $message = t('For security reasons, your upload has been renamed to') . ' <em class="placeholder">' . $this->phpfile->filename . '.txt' . '</em>'; $this->assertRaw($message, 'Dangerous file was renamed.'); $this->assertSession()->pageTextContains('File name is php-2.php.txt.'); @@ -261,7 +261,7 @@ public function testHandleDangerousFile() { file_test_reset(); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.'); $this->assertSession()->pageTextContains('File name is php-2.php.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -295,7 +295,7 @@ public function testHandleFileMunge() { $munged_filename .= '_.' . $this->imageExtension; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.'); $this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -313,7 +313,7 @@ public function testHandleFileMunge() { ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.'); $this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.'); $this->assertRaw(t('You WIN!'), 'Found the success message.'); @@ -331,7 +331,7 @@ public function testExistingRename() { 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); $this->assertSession()->pageTextContains('File name is image-test_0.png.'); @@ -348,7 +348,7 @@ public function testExistingReplace() { 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); $this->assertSession()->pageTextContains('File name is image-test.png.'); @@ -365,7 +365,7 @@ public function testExistingError() { 'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()), ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Check that the no hooks were called while failing. @@ -398,7 +398,7 @@ public function testDrupalMovingUploadedFileError() { \Drupal::state()->set('file_test.disable_error_collection', TRUE); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('File upload error. Could not move uploaded file.'), 'Found the failure message.'); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); diff --git a/core/modules/filter/tests/src/Functional/FilterAdminTest.php b/core/modules/filter/tests/src/Functional/FilterAdminTest.php index 6851016d34b4c54d264a48d36c5b04354af8a5db..8fd19f562345853dcc44b337c02b382a9987e4ea 100644 --- a/core/modules/filter/tests/src/Functional/FilterAdminTest.php +++ b/core/modules/filter/tests/src/Functional/FilterAdminTest.php @@ -163,7 +163,7 @@ public function testFormatAdmin() { // Verify that disabled text format no longer exists. $this->drupalGet('admin/config/content/formats/manage/' . $format_id); - $this->assertResponse(404, 'Disabled text format no longer exists.'); + $this->assertResponse(404); // Attempt to create a format of the same machine name as the disabled // format but with a different human readable name. @@ -203,7 +203,7 @@ public function testFilterAdmin() { $this->drupalGet('admin/config/content/formats'); $this->assertNoRaw('admin/config/content/formats/manage/' . $plain . '/disable', 'Disable link for the fallback format not found.'); $this->drupalGet('admin/config/content/formats/manage/' . $plain . '/disable'); - $this->assertResponse(403, 'The fallback format cannot be disabled.'); + $this->assertResponse(403); // Verify access permissions to Full HTML format. $full_format = FilterFormat::load($full); diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php index e3c6a6dbeaec7be32088b5f097e77106d3ba0ce0..b68e1daa918509a4833ea460bc859a74ed326209 100644 --- a/core/modules/forum/tests/src/Functional/ForumTest.php +++ b/core/modules/forum/tests/src/Functional/ForumTest.php @@ -491,7 +491,7 @@ public function deleteForum($tid) { // Assert that the forum no longer exists. $this->drupalGet('forum/' . $tid); - $this->assertResponse(404, 'The forum was not found'); + $this->assertResponse(404); } /** diff --git a/core/modules/help/tests/src/Functional/NoHelpTest.php b/core/modules/help/tests/src/Functional/NoHelpTest.php index 91f82c9d9dad6f4b3c220eb225bd0e7c68c65831..86ba5cbdb08f2c9c27765334f050e4542b2fed6d 100644 --- a/core/modules/help/tests/src/Functional/NoHelpTest.php +++ b/core/modules/help/tests/src/Functional/NoHelpTest.php @@ -47,8 +47,10 @@ public function testMainPageNoHelp() { $this->assertFalse(\Drupal::moduleHandler()->implementsHook('menu_test', 'help'), 'The menu_test module does not implement hook_help'); $this->assertNoText(\Drupal::moduleHandler()->getName('menu_test'), 'Making sure the test module menu_test does not display a help link on admin/help.'); + // Ensure that the module overview help page for a module that does not + // implement hook_help() results in a 404. $this->drupalGet('admin/help/menu_test'); - $this->assertResponse(404, 'Getting a module overview help page for a module that does not implement hook_help() results in a 404.'); + $this->assertResponse(404); } } diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php index 2ada4e1b40d3df87864681b4f5a9d6d4a10579d2..02cbba80b005f069420e1e5cae8290b4564e4b51 100644 --- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @@ -217,7 +217,6 @@ public function testStyle() { // Check that the URL was updated. $this->drupalGet($style_path); $this->assertTitle(t('Edit style @name | Drupal', ['@name' => $style_label])); - $this->assertResponse(200, new FormattableMarkup('Image style %original renamed to %new', ['%original' => $style->id(), '%new' => $style_name])); // Check that the available image effects are properly sorted. $option = $this->xpath('//select[@id=:id]//option', [':id' => 'edit-new--2']); diff --git a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php index bed6eeb6c49fb67d617fefbb626bcbd189abcf30..f374a9d2b26bcf728621e5b159903861476bf2a7 100644 --- a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php +++ b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php @@ -80,7 +80,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="120" height="60" alt="" class="image-style-test" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); $this->assertEqual($image_file->getWidth(), 120); @@ -101,7 +101,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="60" height="120" alt="" class="image-style-test" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); $this->assertEqual($image_file->getWidth(), 60); @@ -123,7 +123,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); $this->assertEqual($image_file->getWidth(), 45); @@ -145,7 +145,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); $this->assertEqual($image_file->getWidth(), 45); @@ -163,7 +163,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); $this->assertEqual($image_file->getWidth(), 45); @@ -184,7 +184,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" alt="" class="image-style-test" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); // Add a crop effect. @@ -203,7 +203,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="30" height="30" alt="" class="image-style-test" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); $this->assertEqual($image_file->getWidth(), 30); @@ -226,7 +226,7 @@ public function testImageDimensions() { // $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="41" height="41" alt="" class="image-style-test" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); // @todo Uncomment this once @@ -270,7 +270,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="100" height="100" alt="" class="image-style-test-uri" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); $this->assertEqual($image_file->getWidth(), 100); @@ -284,7 +284,7 @@ public function testImageDimensions() { $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="50" height="50" alt="" class="image-style-test-uri" />'); $this->assertFileNotExists($generated_uri); $this->drupalGet($this->getAbsoluteUrl($url)); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); $image_file = $image_factory->get($generated_uri); $this->assertEqual($image_file->getWidth(), 50); diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php index e435e1792b0e137c3d65de626580ad8a26d660d6..62edbb7a72c6f218eecd6fbb9b351d1914530818 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -152,10 +152,10 @@ public function _testImageFieldFormatters($scheme) { $this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', 'Content-Type header was sent.'); $this->assertTrue(strstr($this->drupalGetHeader('Cache-Control'), 'private') !== FALSE, 'Cache-Control header was sent.'); - // Log out and try to access the file. + // Log out and ensure the file cannot be accessed. $this->drupalLogout(); $this->drupalGet(file_create_url($image_uri)); - $this->assertResponse('403', 'Access denied to original image as anonymous user.'); + $this->assertResponse(403); // Log in again. $this->drupalLogin($this->adminUser); @@ -211,10 +211,10 @@ public function _testImageFieldFormatters($scheme) { $this->assertRaw($default_output, 'Image style thumbnail formatter displaying correctly on full node view.'); if ($scheme == 'private') { - // Log out and try to access the file. + // Log out and ensure the file cannot be accessed. $this->drupalLogout(); $this->drupalGet(ImageStyle::load('thumbnail')->buildUrl($image_uri)); - $this->assertResponse('403', 'Access denied to image style thumbnail as anonymous user.'); + $this->assertResponse(403); } // Test the image URL formatter without an image style. diff --git a/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php b/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php index a5e353687abab66d564d5122892b253a92af6718..6c2a733a59b85ff0563e9332510ac9ce6d0fb0b1 100644 --- a/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php +++ b/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php @@ -126,7 +126,7 @@ public function testImageStyleUrlForMissingSourceImage() { $non_existent_uri = 'public://foo.png'; $generated_url = $this->style->buildUrl($non_existent_uri); $this->drupalGet($generated_url); - $this->assertResponse(404, 'Accessing an image style URL with a source image that does not exist provides a 404 error response.'); + $this->assertResponse(404); } /** @@ -185,10 +185,10 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s } // Add some extra chars to the token. $this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url)); - $this->assertResponse(404, 'Image was inaccessible at the URL with an invalid token.'); + $this->assertResponse(404); // Change the parameter name so the token is missing. $this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', 'wrongparam=', $generate_url)); - $this->assertResponse(404, 'Image was inaccessible at the URL with a missing token.'); + $this->assertResponse(404); // Check that the generated URL is the same when we pass in a relative path // rather than a URI. We need to temporarily switch the default scheme to @@ -202,7 +202,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s // Fetch the URL that generates the file. $this->drupalGet($generate_url); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); $this->assertFileExists($generated_uri); // assertRaw can't be used with string containing non UTF-8 chars. $this->assertNotEmpty(file_get_contents($generated_uri), 'URL returns expected file.'); @@ -224,7 +224,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s // Make sure that a second request to the already existing derivative // works too. $this->drupalGet($generate_url); - $this->assertResponse(200, 'Image was generated at the URL.'); + $this->assertResponse(200); // Check that the second request also returned the generated image. $this->assertEqual($this->drupalGetHeader('Content-Length'), $image->getFileSize()); @@ -236,7 +236,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s // have access. \Drupal::state()->delete('image.test_file_download'); $this->drupalGet($generate_url); - $this->assertResponse(403, 'Confirmed that access is denied for the private image style.'); + $this->assertResponse(403); // Repeat this with a different file that we do not have access to and // make sure that access is denied. @@ -247,7 +247,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s $generate_url_noaccess = $this->style->buildUrl($original_uri_noaccess); $this->drupalGet($generate_url_noaccess); - $this->assertResponse(403, 'Confirmed that access is denied for the private image style.'); + $this->assertResponse(403); // Verify that images are not appended to the response. // Currently this test only uses PNG images. if (strpos($generate_url, '.png') === FALSE) { @@ -268,7 +268,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s if ($clean_url) { // Add some extra chars to the token. $this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url)); - $this->assertResponse(200, 'Existing image was accessible at the URL with an invalid token.'); + $this->assertResponse(200); } } @@ -295,7 +295,7 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s $generate_url = $this->style->buildUrl($original_uri, $clean_url); $this->assertStringNotContainsString(IMAGE_DERIVATIVE_TOKEN . '=', $generate_url, 'The security token does not appear in the image style URL.'); $this->drupalGet($generate_url); - $this->assertResponse(200, 'Image was accessible at the URL with a missing token.'); + $this->assertResponse(200); // Stop suppressing the security token in the URL. $this->config('image.settings')->set('suppress_itok_output', FALSE)->save(); @@ -309,16 +309,16 @@ public function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_s $this->assertTrue($matches_expected_url_format, "URL for a derivative of an image style matches expected format."); $nested_url_with_wrong_token = str_replace(IMAGE_DERIVATIVE_TOKEN . '=', 'wrongparam=', $nested_url); $this->drupalGet($nested_url_with_wrong_token); - $this->assertResponse(404, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token.'); + $this->assertResponse(404); // Check that this restriction cannot be bypassed by adding extra slashes // to the URL. $this->drupalGet(substr_replace($nested_url_with_wrong_token, '//styles/', strrpos($nested_url_with_wrong_token, '/styles/'), strlen('/styles/'))); - $this->assertResponse(404, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token, even with an extra forward slash in the URL.'); + $this->assertResponse(404); $this->drupalGet(substr_replace($nested_url_with_wrong_token, '////styles/', strrpos($nested_url_with_wrong_token, '/styles/'), strlen('/styles/'))); - $this->assertResponse(404, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token, even with multiple forward slashes in the URL.'); + $this->assertResponse(404); // Make sure the image can still be generated if a correct token is used. $this->drupalGet($nested_url); - $this->assertResponse(200, 'Image was accessible when a correct token was provided in the URL.'); + $this->assertResponse(200); // Check that requesting a nonexistent image does not create any new // directories in the file system. diff --git a/core/modules/image/tests/src/Functional/QuickEditImageControllerTest.php b/core/modules/image/tests/src/Functional/QuickEditImageControllerTest.php index 791394ed942bb85203a5266ec306d10af4845708..73acb48df5f442f3e6dd41d59a6fc16cb73bc8d8 100644 --- a/core/modules/image/tests/src/Functional/QuickEditImageControllerTest.php +++ b/core/modules/image/tests/src/Functional/QuickEditImageControllerTest.php @@ -86,7 +86,7 @@ public function testAccess() { 'title' => t('Test Node'), ]); $this->drupalGet('quickedit/image/info/node/' . $node->id() . '/' . $this->fieldName . '/' . $node->language()->getId() . '/default'); - $this->assertResponse('403'); + $this->assertResponse(403); /** @var \Symfony\Component\BrowserKit\Client $client */ $client = $this->getSession()->getDriver()->getClient(); diff --git a/core/modules/language/tests/src/Functional/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php index ebd2fae80f8ed7c9d30f5e2e0badda00c1ff41bb..2b17c5edf4feba45581e0fc1a97f1dac27fbb512 100644 --- a/core/modules/language/tests/src/Functional/LanguageListTest.php +++ b/core/modules/language/tests/src/Functional/LanguageListTest.php @@ -88,7 +88,7 @@ public function testLanguageList() { // Ensure we can't delete the default language. $this->drupalGet('admin/config/regional/language/delete/' . $langcode); - $this->assertResponse(403, 'Failed to delete the default language.'); + $this->assertResponse(403); // Ensure 'Edit' link works. $this->drupalGet('admin/config/regional/language'); @@ -128,7 +128,7 @@ public function testLanguageList() { $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $english])->toString()); // Verify that language is no longer found. $this->drupalGet('admin/config/regional/language/delete/' . $langcode); - $this->assertResponse(404, 'Language no longer found.'); + $this->assertResponse(404); // Delete French. $this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete')); @@ -140,7 +140,7 @@ public function testLanguageList() { $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE])->toString()); // Verify that language is no longer found. $this->drupalGet('admin/config/regional/language/delete/fr'); - $this->assertResponse(404, 'Language no longer found.'); + $this->assertResponse(404); // Make sure the "language_count" state has not changed. // Ensure we can delete the English language. Right now English is the only @@ -179,7 +179,7 @@ public function testLanguageList() { // Ensure we can't delete a locked language. $this->drupalGet('admin/config/regional/language/delete/und'); - $this->assertResponse(403, 'Can not delete locked language'); + $this->assertResponse(403); // Ensure that NL cannot be set default when it's not available. // First create the NL language. diff --git a/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php b/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php index da5f1aefa7c08111147036cfa2f009bca2968aed..da17dc04193d6d9f0f6026b6a77b7def1010b2f5 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() { // Verify that links in this page can be followed and work. $this->clickLink(t('Languages')); - $this->assertResponse(200, 'Clicked link results in a valid page'); + $this->assertResponse(200); $this->assertText(t('Add language'), 'Page contains the add language text'); } diff --git a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php index 68906e2177aa50ae1b8515430a18b8bfcef73191..c04d6503e8dd14d972fc21d872d26d6569e48e53 100644 --- a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php @@ -257,7 +257,7 @@ public function testUILanguageNegotiation() { ->set('negotiation.' . LanguageInterface::TYPE_INTERFACE . '.enabled', array_flip(array_keys($language_interface_method_definitions))) ->save(); $this->drupalGet("$langcode_unknown/admin/config", [], $http_header_browser_fallback); - $this->assertResponse(404, "Unknown language path prefix should return 404"); + $this->assertResponse(404); // Set preferred langcode for user to NULL. $account = $this->loggedInUser; diff --git a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php index ba747fd951958aa129062da91918d326b5fdf08a..f7561c19a3011a09cf1ebf86df816ab690ddc5c3 100644 --- a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php @@ -62,7 +62,7 @@ protected function setUp(): void { public function testUrlRewritingEdgeCases() { // Check URL rewriting with a non-installed language. $non_existing = new Language(['id' => $this->randomMachineName()]); - $this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages'); + $this->checkUrl($non_existing, 'Path language is ignored if language is not installed.'); // Check that URL rewriting is not applied to subrequests. $this->drupalGet('language_test/subrequest'); @@ -78,12 +78,10 @@ public function testUrlRewritingEdgeCases() { * * @param \Drupal\Core\Language\LanguageInterface $language * The language object. - * @param string $message1 + * @param string $message * Message to display in assertion that language prefixes are not added. - * @param string $message2 - * The message to display confirming prefixed URL is not working. */ - private function checkUrl(LanguageInterface $language, $message1, $message2) { + private function checkUrl(LanguageInterface $language, $message) { $options = ['language' => $language, 'script' => '']; $base_path = trim(base_path(), '/'); $rewritten_path = trim(str_replace($base_path, '', Url::fromRoute('<front>', [], $options)->toString()), '/'); @@ -95,11 +93,11 @@ private function checkUrl(LanguageInterface $language, $message1, $message2) { // we can always check the prefixed URL. $prefixes = $this->config('language.negotiation')->get('url.prefixes'); $stored_prefix = isset($prefixes[$language->getId()]) ? $prefixes[$language->getId()] : $this->randomMachineName(); - $this->assertNotEqual($stored_prefix, $prefix, $message1); + $this->assertNotEqual($stored_prefix, $prefix, $message); $prefix = $stored_prefix; $this->drupalGet("$prefix/$path"); - $this->assertResponse(404, $message2); + $this->assertResponse(404); } /** diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php index 85cba673fe59f07e9cfc24f71ebabc3fdccabd10..2de4334a7dd2db77c06d35d95af8876e3350b437 100644 --- a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php @@ -182,7 +182,7 @@ public function testStringTranslation() { // Reload to remove $name. $this->drupalGet($path); // Verify that language is no longer found. - $this->assertResponse(404, 'Language no longer found.'); + $this->assertResponse(404); $this->drupalLogout(); // Delete the string. diff --git a/core/modules/node/tests/src/Functional/NodeTypeTest.php b/core/modules/node/tests/src/Functional/NodeTypeTest.php index b9e7d7eca56c945d7753427afc42a618481e9ce3..7c42cb8f2b5b0c8e3097f36fbc473ffe90a8f64f 100644 --- a/core/modules/node/tests/src/Functional/NodeTypeTest.php +++ b/core/modules/node/tests/src/Functional/NodeTypeTest.php @@ -64,7 +64,7 @@ public function testNodeTypeCreation() { $this->drupalLogin($web_user); $this->drupalGet('node/add/' . $type->id()); - $this->assertResponse(200, 'The new content type can be accessed at node/add.'); + $this->assertResponse(200); // Create a content type via the user interface. $web_user = $this->drupalCreateUser(['bypass node access', 'administer content types']); diff --git a/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php b/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php index 34f1f7f7fa044d35f143a13d8d23f629251262f1..38f23218215b3679fac00dc9df4ced6da080280b 100644 --- a/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php +++ b/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php @@ -48,7 +48,7 @@ public function testRevisionLinks() { $second_revision = $nodes[1]->getRevisionId(); $this->drupalGet('test-node-revision-links'); - $this->assertResponse(200, 'Test view can be accessed in the path expected'); + $this->assertResponse(200); // 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(); diff --git a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php index b607560adc18259bb894d6098775dd8e6c7d6748..3f70a97f3935a87190687b794fe09612e414f061 100644 --- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php +++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php @@ -201,38 +201,47 @@ public function testConditionalRequests() { $etag = $this->drupalGetHeader('ETag'); $last_modified = $this->drupalGetHeader('Last-Modified'); + // Ensure a conditional request returns 304 Not Modified. $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => $etag]); - $this->assertResponse(304, 'Conditional request returned 304 Not Modified.'); + $this->assertResponse(304); + // Ensure a conditional request with obsolete If-Modified-Since date + // returns 304 Not Modified. $this->drupalGet('', [], [ 'If-Modified-Since' => gmdate(DATE_RFC822, strtotime($last_modified)), 'If-None-Match' => $etag, ]); - $this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.'); + $this->assertResponse(304); + // Ensure a conditional request with obsolete If-Modified-Since date + // returns 304 Not Modified. $this->drupalGet('', [], [ 'If-Modified-Since' => gmdate(DATE_RFC850, strtotime($last_modified)), 'If-None-Match' => $etag, ]); - $this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.'); + $this->assertResponse(304); + // Ensure a conditional request without If-None-Match returns 200 OK. $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => NULL]); // Verify the page is not printed twice when the cache is warm. $this->assertSession()->responseNotMatches('#<html.*<html#'); - $this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.'); + $this->assertResponse(200); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); + // Ensure a conditional request with If-Modified-Since newer than + // Last-Modified returns 200 OK. $this->drupalGet('', [], [ 'If-Modified-Since' => gmdate(DateTimePlus::RFC7231, strtotime($last_modified) + 1), 'If-None-Match' => $etag, ]); - $this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.'); + $this->assertResponse(200); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); + // Ensure a conditional request by an authenticated user returns 200 OK. $user = $this->drupalCreateUser(); $this->drupalLogin($user); $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => $etag]); - $this->assertResponse(200, 'Conditional request returned 200 OK for authenticated user.'); + $this->assertResponse(200); $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Absence of Page was not cached.'); } diff --git a/core/modules/path/tests/src/Functional/PathLanguageTest.php b/core/modules/path/tests/src/Functional/PathLanguageTest.php index c166affbdfe741fb1aa66fe688152bf8b775e45a..de4032763fc58c3103f6fb6439ae8fd05c59f5bb 100644 --- a/core/modules/path/tests/src/Functional/PathLanguageTest.php +++ b/core/modules/path/tests/src/Functional/PathLanguageTest.php @@ -173,7 +173,7 @@ public function testAliasTranslation() { // situation only aliases in the default language and language neutral ones // should keep working. $this->drupalGet($french_alias); - $this->assertResponse(404, 'Alias for French translation is unavailable when URL language negotiation is disabled.'); + $this->assertResponse(404); // The alias manager has an internal path lookup cache. Check to see that // it has the appropriate contents at this point. diff --git a/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php b/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php index 30c584e5aa417da35ffc48a2c3633ab81396f794..c2bcd761b629fc82b63d0a6529f884b1c8517574 100644 --- a/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php +++ b/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php @@ -76,7 +76,7 @@ public function testTermAlias() { // Confirm that the old alias no longer works. $this->drupalGet(trim($edit['path[0][alias]'], '/')); $this->assertNoText($description, 'Old URL alias has been removed after altering.'); - $this->assertResponse(404, 'Old URL alias returns 404.'); + $this->assertResponse(404); // Remove the term's URL alias. $edit3 = []; @@ -86,7 +86,7 @@ public function testTermAlias() { // Confirm that the alias no longer works. $this->drupalGet(trim($edit2['path[0][alias]'], '/')); $this->assertNoText($description, 'Old URL alias has been removed after altering.'); - $this->assertResponse(404, 'Old URL alias returns 404.'); + $this->assertResponse(404); } } diff --git a/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php b/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php index 835f034b1d99699f45f39bb82f79dab91a202a5a..d7c48a77bda2a51975a9de4e3a7a71364797bdaf 100644 --- a/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php +++ b/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php @@ -47,7 +47,7 @@ public function testUrlAlter() { // Test a single altered path. $this->drupalGet("user/$name"); - $this->assertResponse('200', 'The user/username path gets resolved correctly'); + $this->assertResponse(200); $this->assertUrlOutboundAlter("/user/$uid", "/user/$name"); // Test that a path always uses its alias. @@ -61,7 +61,7 @@ public function testUrlAlter() { $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save')); $this->assertText(t('The alias has been saved.')); $this->drupalGet('alias/test2'); - $this->assertResponse('200', 'The path alias gets resolved correctly'); + $this->assertResponse(200); $this->assertUrlOutboundAlter("/user/$uid/edit", '/alias/test2'); // Test a non-existent user is not altered. diff --git a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php index f242e3c189d0171d77be29f36dbd5eef69764d47..22904081f56ca3eeeee2e7a903ddd9820e8b440d 100644 --- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php +++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php @@ -268,10 +268,10 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles = $this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', 'Content-Type header was sent.'); $this->assertTrue(strstr($this->drupalGetHeader('Cache-Control'), 'private') !== FALSE, 'Cache-Control header was sent.'); - // Log out and try to access the file. + // Log out and ensure the file cannot be accessed. $this->drupalLogout(); $this->drupalGet(file_create_url($image_uri)); - $this->assertResponse('403', 'Access denied to original image as anonymous user.'); + $this->assertResponse(403); // Log in again. $this->drupalLogin($this->adminUser); @@ -334,10 +334,10 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles = $this->assertRaw($default_output, 'Image style large formatter displaying correctly on full node view.'); if ($scheme == 'private') { - // Log out and try to access the file. + // Log out and ensure the file cannot be accessed. $this->drupalLogout(); $this->drupalGet($large_style->buildUrl($image_uri)); - $this->assertResponse('403', 'Access denied to image style large as anonymous user.'); + $this->assertResponse(403); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); } diff --git a/core/modules/rest/tests/src/Functional/ResourceTest.php b/core/modules/rest/tests/src/Functional/ResourceTest.php index 035b5803c9c539eb2031f60fe7920e3795931b6e..bd1908bcb31da3e9c2b5fcadfaae100f6b984ca6 100644 --- a/core/modules/rest/tests/src/Functional/ResourceTest.php +++ b/core/modules/rest/tests/src/Functional/ResourceTest.php @@ -83,7 +83,7 @@ public function testFormats() { // means there's always a match and hence when there is no matching REST // route, the non-REST route is used, but can't render into // application/hal+json, so it returns a 406. - $this->assertResponse('406', 'HTTP response code is 406 when the resource does not define formats, because it falls back to the canonical, non-REST route.'); + $this->assertResponse(406); } /** @@ -109,7 +109,7 @@ public function testAuthentication() { // means there's always a match and hence when there is no matching REST // route, the non-REST route is used, but can't render into // application/hal+json, so it returns a 406. - $this->assertResponse('406', 'HTTP response code is 406 when the resource does not define formats, because it falls back to the canonical, non-REST route.'); + $this->assertResponse(406); } /** diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php index ddc463c9075148aa400dbde53afd73f0260e1369..1d3209c564a9571422a2702ee66ab170abb1d0b6 100644 --- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php +++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php @@ -383,23 +383,23 @@ public function testResponseFormatConfiguration() { $style_options = 'admin/structure/views/nojs/display/test_serializer_display_field/rest_export_1/style_options'; - // Test with no format. + // Ensure a request with no format returns 406 Not Acceptable. $this->drupalGet('test/serialize/field'); $this->assertHeader('content-type', 'text/html; charset=UTF-8'); - $this->assertResponse(406, 'A 406 response was returned when no format was requested.'); + $this->assertResponse(406); // Select only 'xml' as an accepted format. $this->drupalPostForm($style_options, ['style_options[formats][xml]' => 'xml'], t('Apply')); $this->drupalPostForm(NULL, [], t('Save')); - // Should return a 406. + // Ensure a request for JSON returns 406 Not Acceptable. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]); $this->assertHeader('content-type', 'application/json'); - $this->assertResponse(406, 'A 406 response was returned when JSON was requested.'); - // Should return a 200. + $this->assertResponse(406); + // Ensure a request for XML returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]); $this->assertHeader('content-type', 'text/xml; charset=UTF-8'); - $this->assertResponse(200, 'A 200 response was returned when XML was requested.'); + $this->assertResponse(200); // Add 'json' as an accepted format, so we have multiple. $this->drupalPostForm($style_options, ['style_options[formats][json]' => 'json'], t('Apply')); @@ -408,39 +408,40 @@ public function testResponseFormatConfiguration() { // Should return a 406. Emulates a sample Firefox header. $this->drupalGet('test/serialize/field', [], ['Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8']); $this->assertHeader('content-type', 'text/html; charset=UTF-8'); - $this->assertResponse(406, 'A 406 response was returned when a browser accept header was requested.'); + $this->assertResponse(406); - // Should return a 406. + // Ensure a request for HTML returns 406 Not Acceptable. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'html']]); $this->assertHeader('content-type', 'text/html; charset=UTF-8'); - $this->assertResponse(406, 'A 406 response was returned when HTML was requested.'); + $this->assertResponse(406); - // Should return a 200. + // Ensure a request for JSON returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]); $this->assertHeader('content-type', 'application/json'); - $this->assertResponse(200, 'A 200 response was returned when JSON was requested.'); + $this->assertResponse(200); - // Should return a 200. + // Ensure a request XML returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]); $this->assertHeader('content-type', 'text/xml; charset=UTF-8'); - $this->assertResponse(200, 'A 200 response was returned when XML was requested'); + $this->assertResponse(200); // Now configure no format, so both serialization formats should be allowed. $this->drupalPostForm($style_options, ['style_options[formats][json]' => '0', 'style_options[formats][xml]' => '0'], t('Apply')); - // Should return a 200. + // Ensure a request for JSON returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]); $this->assertHeader('content-type', 'application/json'); - $this->assertResponse(200, 'A 200 response was returned when JSON was requested.'); - // Should return a 200. + $this->assertResponse(200); + + // Ensure a request for XML returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]); $this->assertHeader('content-type', 'text/xml; charset=UTF-8'); - $this->assertResponse(200, 'A 200 response was returned when XML was requested'); + $this->assertResponse(200); // Should return a 406 for HTML still. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'html']]); $this->assertHeader('content-type', 'text/html; charset=UTF-8'); - $this->assertResponse(406, 'A 406 response was returned when HTML was requested.'); + $this->assertResponse(406); } /** diff --git a/core/modules/search/tests/src/Functional/SearchPageTextTest.php b/core/modules/search/tests/src/Functional/SearchPageTextTest.php index 35f3204405c77cd84844009ff13e1c24f7545354..f33f196bea1adc8dc1a797e25175b3db2b9ba6cc 100644 --- a/core/modules/search/tests/src/Functional/SearchPageTextTest.php +++ b/core/modules/search/tests/src/Functional/SearchPageTextTest.php @@ -157,13 +157,13 @@ public function testSearchText() { // Test that if you search for a URL with .. in it, you still end up at // the search page. See issue https://www.drupal.org/node/890058. $this->drupalPostForm('search/node', ['keys' => '../../admin'], t('Search')); - $this->assertResponse(200, 'Searching for ../../admin with non-admin user does not lead to a 403 error'); + $this->assertResponse(200); $this->assertText('no results', 'Searching for ../../admin with non-admin user gives you a no search results page'); // Test that if you search for a URL starting with "./", you still end up // at the search page. See issue https://www.drupal.org/node/1421560. $this->drupalPostForm('search/node', ['keys' => '.something'], t('Search')); - $this->assertResponse(200, 'Searching for .something does not lead to a 403 error'); + $this->assertResponse(200); $this->assertText('no results', 'Searching for .something gives you a no search results page'); } diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php index d6ebb42aed966da63db767e4c858e7002ff26865..814f65790f60a5178053f987bff7a26c136f2d7b 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php @@ -406,17 +406,12 @@ private function verifyAccessShortcutsPermissionForEditPages() { // Verify that set administration pages are inaccessible without the // 'access shortcuts' permission. - $edit_paths = [ - 'admin/config/user-interface/shortcut/manage/default/customize', - 'admin/config/user-interface/shortcut/manage/default', - 'user/' . $noaccess_user->id() . '/shortcuts', - ]; - - foreach ($edit_paths as $path) { - $this->drupalGet($path); - $message = new FormattableMarkup('Access is denied on %s', ['%s' => $path]); - $this->assertResponse(403, $message); - } + $this->drupalGet('admin/config/user-interface/shortcut/manage/default/customize'); + $this->assertResponse(403); + $this->drupalGet('admin/config/user-interface/shortcut/manage/default'); + $this->assertResponse(403); + $this->drupalGet('user/' . $noaccess_user->id() . '/shortcuts'); + $this->assertResponse(403); } /** diff --git a/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php b/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php index 672312c0ad511589d357a57847ee00b1948626a3..4d31dfb427d1df5ded1f680b626a368b21c6c238 100644 --- a/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php +++ b/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php @@ -56,7 +56,7 @@ public function testFormStateValuesCleanAdvanced() { $this->drupalPostForm('form_test/form-state-values-clean-advanced', $edit, t('Submit')); // Expecting a 200 HTTP code. - $this->assertResponse(200, 'Received a 200 response for posted test file.'); + $this->assertResponse(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); } diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index 80798de0e18cba66cda51af3cc81e3a2d655abc5..6757c73ff04621e7e8e0289851adf346c33dfd7f 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -354,7 +354,7 @@ protected function assertUninstallModuleUpdates($module) { */ protected function assertHelp($module, $name) { $this->drupalGet('admin/help/' . $module); - $this->assertResponse(200, "Help for $module displayed successfully"); + $this->assertResponse(200); $this->assertText($name . ' module', "'$name module' is on the help page for $module"); $this->assertLink('online documentation for the ' . $name . ' module', 0, "Correct online documentation link is in the help page for $module"); } diff --git a/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php index 6acdb9541c926e06757ad94e41ca3d7a453c8812..fff122b72f87dd168f019a4b8bb2a4f69a072aae 100644 --- a/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php @@ -151,9 +151,9 @@ public function testUninstall() { $this->assertText('The selected modules have been uninstalled.'); $this->assertNoText('Allows content to be submitted to the site and displayed on pages.'); - // Ensure the proper response when accessing a non-existent entity type. + // Ensure a 404 is returned when accessing a non-existent entity type. $this->drupalGet('admin/modules/uninstall/entity/node'); - $this->assertResponse(404, 'Entity types that do not exist result in a 404.'); + $this->assertResponse(404); // Test an entity type which does not have any existing entities. $this->drupalGet('admin/modules/uninstall/entity/entity_test_no_label'); diff --git a/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php b/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php index 1de9fcc9f28080db7ef00a62848db6379b6a4a67..69922ae19968ff9e77a1ecc995758193571f840e 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php @@ -27,12 +27,13 @@ class RouterPermissionTest extends BrowserTestBase { * Tests permission requirements on routes. */ public function testPermissionAccess() { - $path = 'router_test/test7'; - $this->drupalGet($path); - $this->assertResponse(403, "Access denied for a route where we don't have a permission"); + // Ensure 403 Access Denied for a route without permission. + $this->drupalGet('router_test/test7'); + $this->assertResponse(403); + // Ensure 403 Access Denied by default if no access specified. $this->drupalGet('router_test/test8'); - $this->assertResponse(403, 'Access denied by default if no access specified'); + $this->assertResponse(403); $user = $this->drupalCreateUser(['access test7']); $this->drupalLogin($user); diff --git a/core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php b/core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php index 718e8c697715da798d4bc641dbf09e209ebe2008..5b2ab797a5d8a3c4de74d58e608787b5b453c38b 100644 --- a/core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php +++ b/core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php @@ -58,11 +58,11 @@ public function testSessionFromBasicAuthenticationDoesNotLeak() { // Test that the route is not accessible as an anonymous user. $this->drupalGet($protected_url); $session = $this->getSession(); - $this->assertResponse(401, 'An anonymous user cannot access a route protected with basic authentication.'); + $this->assertResponse(401); // We should be able to access the route with basic authentication. $this->basicAuthGet($protected_url, $this->user->getAccountName(), $this->user->passRaw); - $this->assertResponse(200, 'A route protected with basic authentication can be accessed by an authenticated user.'); + $this->assertResponse(200); // Check that the correct user is logged in. $this->assertEqual($this->user->id(), json_decode($session->getPage()->getContent())->user, 'The correct user is authenticated on a route with basic authentication.'); @@ -71,13 +71,13 @@ public function testSessionFromBasicAuthenticationDoesNotLeak() { // If we now try to access a page without basic authentication then we // should no longer be logged in. $this->drupalGet($unprotected_url); - $this->assertResponse(200, 'An unprotected route can be accessed without basic authentication.'); + $this->assertResponse(200); $this->assertEquals(0, json_decode($session->getPage()->getContent())->user, 'The user is no longer authenticated after visiting a page without basic authentication.'); // If we access the protected page again without basic authentication we // should get 401 Unauthorized. $this->drupalGet($protected_url); - $this->assertResponse(401, 'A subsequent request to the same route without basic authentication is not authorized.'); + $this->assertResponse(401); } /** @@ -88,12 +88,12 @@ public function testBasicAuthSession() { $test_value = 'alpaca'; $response = $this->basicAuthGet('session-test/set-session/' . $test_value, $this->user->getAccountName(), $this->user->pass_raw); $this->assertSessionData($response, $test_value); - $this->assertResponse(200, 'The request to set a session value was successful.'); + $this->assertResponse(200); // Test that on a subsequent request the session value is still present. $response = $this->basicAuthGet('session-test/get-session', $this->user->getAccountName(), $this->user->pass_raw); $this->assertSessionData($response, $test_value); - $this->assertResponse(200, 'The request to get a session value was successful.'); + $this->assertResponse(200); } /** @@ -126,7 +126,7 @@ public function testBasicAuthNoSession() { // session cookie should be set, the third party system is responsible for // sustaining the session. $this->basicAuthGet($no_cookie_url, $this->user->getAccountName(), $this->user->passRaw); - $this->assertResponse(200, 'The user is successfully authenticated using basic authentication.'); + $this->assertResponse(200); $this->assertEmpty($this->getSessionCookies()); // Mink stores some information in the session that breaks the next check if // not reset. diff --git a/core/modules/system/tests/src/Functional/Session/SessionTest.php b/core/modules/system/tests/src/Functional/Session/SessionTest.php index 37ffe4cc1306f39a90074edd3d8ca8f86f8c4af8..ece2d374b90c94ac1daea93edd2e068d82428db0 100644 --- a/core/modules/system/tests/src/Functional/Session/SessionTest.php +++ b/core/modules/system/tests/src/Functional/Session/SessionTest.php @@ -279,7 +279,7 @@ public function testEmptySessionID() { $user = $this->drupalCreateUser([]); $this->drupalLogin($user); $this->drupalGet('session-test/is-logged-in'); - $this->assertResponse(200, 'User is logged in.'); + $this->assertResponse(200); // Reset the sid in {sessions} to a blank string. This may exist in the // wild in some cases, although we normally prevent it from happening. @@ -292,37 +292,42 @@ public function testEmptySessionID() { $this->assertRaw("session_id:\n", 'Session ID is blank as sent from cookie header.'); // Assert that we have an anonymous session now. $this->drupalGet('session-test/is-logged-in'); - $this->assertResponse(403, 'An empty session ID is not allowed.'); + $this->assertResponse(403); } /** * Test session bag. */ public function testSessionBag() { + // Ensure the flag is absent to start with. $this->drupalGet('/session-test/has-bag-flag'); $this->assertSessionCookie(FALSE); $this->assertSessionEmpty(TRUE); - $this->assertResponse(200, 'Flag is absent from session bag'); + $this->assertResponse(200); + // Set the flag. $this->drupalGet('/session-test/set-bag-flag'); $this->assertSessionCookie(TRUE); $this->assertSessionEmpty(TRUE); $this->assertResponse(200); + // Ensure the flag is set. $this->drupalGet('/session-test/has-bag-flag'); $this->assertSessionCookie(TRUE); $this->assertSessionEmpty(FALSE); - $this->assertResponse(200, 'Flag is present in session bag'); + $this->assertResponse(200); + // Clear the flag. $this->drupalGet('/session-test/clear-bag-flag'); $this->assertSessionCookie(FALSE); $this->assertSessionEmpty(FALSE); $this->assertResponse(200); + // Ensure the flag is absent again. $this->drupalGet('/session-test/has-bag-flag'); $this->assertSessionCookie(FALSE); $this->assertSessionEmpty(TRUE); - $this->assertResponse(200, 'Flag is absent from session bag'); + $this->assertResponse(200); } /** @@ -335,7 +340,7 @@ public function sessionReset() { // Change cookie file for user. $this->drupalGet('session-test/get'); - $this->assertResponse(200, 'Session test module is correctly enabled.', 'Session'); + $this->assertResponse(200); } /** diff --git a/core/modules/system/tests/src/Functional/System/AdminTest.php b/core/modules/system/tests/src/Functional/System/AdminTest.php index a3e4f9a4091bc8e9349e53028c652573854ddda0..bbd1d7b32116c5609932651ea362b7c939dd098c 100644 --- a/core/modules/system/tests/src/Functional/System/AdminTest.php +++ b/core/modules/system/tests/src/Functional/System/AdminTest.php @@ -157,7 +157,7 @@ public function testCompactMode() { $frontpage_url = 'user/' . $this->adminUser->id(); $this->drupalGet('admin/compact/on'); - $this->assertResponse(200, 'A valid page is returned after turning on compact mode.'); + $this->assertResponse(200); $this->assertUrl($frontpage_url, [], 'The user is redirected to the front page after turning on compact mode.'); $this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode turns on.'); $this->drupalGet('admin/compact/on'); @@ -166,7 +166,7 @@ public function testCompactMode() { $this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode persists on new requests.'); $this->drupalGet('admin/compact/off'); - $this->assertResponse(200, 'A valid page is returned after turning off compact mode.'); + $this->assertResponse(200); $this->assertUrl($frontpage_url, [], 'The user is redirected to the front page after turning off compact mode.'); $this->assertNull($session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode turns off.'); $this->drupalGet('admin/compact/off'); diff --git a/core/modules/system/tests/src/Functional/System/DateTimeTest.php b/core/modules/system/tests/src/Functional/System/DateTimeTest.php index eee2e76bd156988bdbbbad898bdebd27d97cdc33..311a35312f54bf7cd2f14d7d2902d882cb3bf461 100644 --- a/core/modules/system/tests/src/Functional/System/DateTimeTest.php +++ b/core/modules/system/tests/src/Functional/System/DateTimeTest.php @@ -185,7 +185,7 @@ public function testEnteringDateTimeViaSelectors() { $this->drupalCreateContentType(['type' => 'page_with_date', 'name' => 'Page with date']); $this->drupalGet('admin/structure/types/manage/page_with_date'); - $this->assertResponse(200, 'Content type created.'); + $this->assertResponse(200); $this->drupalGet('admin/structure/types/manage/page_with_date/fields/add-field'); $edit = [ diff --git a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php index c2775b8e29c16cf636490401777dc070a436c648..b01a42186205e3cc7942834afbe25b00f0f018b5 100644 --- a/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php +++ b/core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php @@ -51,7 +51,7 @@ public function testErrorHandler() { // Set error reporting to display verbose notices. $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save(); $this->drupalGet('error-test/generate-warnings'); - $this->assertResponse(200, 'Received expected HTTP status code.'); + $this->assertResponse(200); $this->assertErrorMessage($error_notice); $this->assertErrorMessage($error_warning); $this->assertErrorMessage($error_user_notice); @@ -66,7 +66,7 @@ public function testErrorHandler() { // Set error reporting to collect notices. $config->set('error_level', ERROR_REPORTING_DISPLAY_ALL)->save(); $this->drupalGet('error-test/generate-warnings'); - $this->assertResponse(200, 'Received expected HTTP status code.'); + $this->assertResponse(200); $this->assertErrorMessage($error_notice); $this->assertErrorMessage($error_warning); $this->assertErrorMessage($error_user_notice); @@ -75,7 +75,7 @@ public function testErrorHandler() { // Set error reporting to not collect notices. $config->set('error_level', ERROR_REPORTING_DISPLAY_SOME)->save(); $this->drupalGet('error-test/generate-warnings'); - $this->assertResponse(200, 'Received expected HTTP status code.'); + $this->assertResponse(200); $this->assertNoErrorMessage($error_notice); $this->assertErrorMessage($error_warning); $this->assertErrorMessage($error_user_notice); @@ -84,7 +84,7 @@ public function testErrorHandler() { // Set error reporting to not show any errors. $config->set('error_level', ERROR_REPORTING_HIDE)->save(); $this->drupalGet('error-test/generate-warnings'); - $this->assertResponse(200, 'Received expected HTTP status code.'); + $this->assertResponse(200); $this->assertNoErrorMessage($error_notice); $this->assertNoErrorMessage($error_warning); $this->assertNoErrorMessage($error_user_notice); diff --git a/core/modules/system/tests/src/Functional/System/HtaccessTest.php b/core/modules/system/tests/src/Functional/System/HtaccessTest.php index 074b3c00904cf5f3aa7799be412ff4e5afb8dce3..ec3b3c8d0214140697203004dd5c3488a6282d2b 100644 --- a/core/modules/system/tests/src/Functional/System/HtaccessTest.php +++ b/core/modules/system/tests/src/Functional/System/HtaccessTest.php @@ -108,7 +108,7 @@ public function testFileAccess() { // Test that adding "/1" to a .php URL does not make it accessible. $this->drupalGet('core/lib/Drupal.php/1'); - $this->assertResponse(403, "Access to core/lib/Drupal.php/1 is denied."); + $this->assertResponse(403); // Test that it is possible to have path aliases containing .php. $type = $this->drupalCreateContentType(); @@ -143,7 +143,7 @@ public function testFileAccess() { protected function assertFileAccess($path, $response_code) { $this->assertFileExists(\Drupal::root() . '/' . $path); $this->drupalGet($path); - $this->assertResponse($response_code, "Response code to $path is $response_code."); + $this->assertEquals($response_code, $this->getSession()->getStatusCode(), "Response code to $path should be $response_code"); } /** diff --git a/core/modules/system/tests/src/Functional/System/IndexPhpTest.php b/core/modules/system/tests/src/Functional/System/IndexPhpTest.php index 8d10a3e81f480ca95d6073e4bbddce1679b543f2..9896e850bdc670cdff50fdfceaca76bfdf049a87 100644 --- a/core/modules/system/tests/src/Functional/System/IndexPhpTest.php +++ b/core/modules/system/tests/src/Functional/System/IndexPhpTest.php @@ -27,10 +27,10 @@ public function testIndexPhpHandling() { $index_php = $GLOBALS['base_url'] . '/index.php'; $this->drupalGet($index_php, ['external' => TRUE]); - $this->assertResponse(200, 'Make sure index.php returns a valid page.'); + $this->assertResponse(200); $this->drupalGet($index_php . '/user', ['external' => TRUE]); - $this->assertResponse(200, 'Make sure index.php/user returns a valid page.'); + $this->assertResponse(200); } } diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php index 770453a881848c7222eb4448fdf80dae1150b209..a4b5557d146e637290b991ba1043632951fcb0fc 100644 --- a/core/modules/system/tests/src/Functional/System/StatusTest.php +++ b/core/modules/system/tests/src/Functional/System/StatusTest.php @@ -48,7 +48,7 @@ protected function setUp(): void { public function testStatusPage() { // Go to Administration. $this->drupalGet('admin/reports/status'); - $this->assertResponse(200, 'The status page is reachable.'); + $this->assertResponse(200); $phpversion = phpversion(); $this->assertText($phpversion, 'Php version is shown on the page.'); @@ -81,7 +81,7 @@ public function testStatusPage() { $this->assertText(t('Out of date')); $this->drupalGet('admin/reports/status/php'); - $this->assertResponse(200, 'The phpinfo page is reachable.'); + $this->assertResponse(200); // Check if cron error is displayed in errors section $cron_last_run = \Drupal::state()->get('system.cron_last'); diff --git a/core/modules/system/tests/src/Functional/System/ThemeTest.php b/core/modules/system/tests/src/Functional/System/ThemeTest.php index 4611da8e22ac16e3592ce3c66fbb10dd05825ab9..a7ff15600662c1e8f7464c7f05f35d2dd5bc9f34 100644 --- a/core/modules/system/tests/src/Functional/System/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php @@ -53,14 +53,16 @@ protected function setUp(): void { * Test the theme settings form. */ public function testThemeSettings() { - // Ensure invalid theme settings form URLs return a proper 404. + // Ensure a disabled theme settings form URL returns 404. $this->drupalGet('admin/appearance/settings/bartik'); - $this->assertResponse(404, 'The theme settings form URL for a uninstalled theme could not be found.'); + $this->assertResponse(404); + // Ensure a non existent theme settings form URL returns 404. $this->drupalGet('admin/appearance/settings/' . $this->randomMachineName()); - $this->assertResponse(404, 'The theme settings form URL for a non-existent theme could not be found.'); + $this->assertResponse(404); + // Ensure a hidden theme settings form URL returns 404. $this->assertTrue(\Drupal::service('theme_installer')->install(['stable'])); $this->drupalGet('admin/appearance/settings/stable'); - $this->assertResponse(404, 'The theme settings form URL for a hidden theme is unavailable.'); + $this->assertResponse(404); // Specify a filesystem path to be used for the logo. $file = current($this->drupalGetTestFiles('image')); @@ -211,7 +213,7 @@ public function testThemeSettings() { $this->drupalGet('admin/appearance/settings'); $this->assertLink($theme_handler->getName('stable')); $this->drupalGet('admin/appearance/settings/stable'); - $this->assertResponse(200, 'The theme settings form URL for a hidden theme that is the admin theme is available.'); + $this->assertResponse(200); // Ensure default logo and favicons are not triggering custom path // validation errors if their custom paths are set on the form. diff --git a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php index 016413393ca8079fcf2ba761ff687efb464159c8..83613f72b0f6196cc3920e6652f2233159a83102 100644 --- a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php +++ b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php @@ -34,7 +34,7 @@ protected function setUp(): void { */ public function testStatusPageWithoutConfiguration() { $this->drupalGet('admin/reports/status'); - $this->assertResponse(200, 'The status page is reachable.'); + $this->assertResponse(200); $this->assertRaw(t('Trusted Host Settings')); $this->assertRaw(t('The trusted_host_patterns setting is not configured in settings.php.')); @@ -52,7 +52,7 @@ public function testStatusPageWithConfiguration() { $this->writeSettings($settings); $this->drupalGet('admin/reports/status'); - $this->assertResponse(200, 'The status page is reachable.'); + $this->assertResponse(200); $this->assertRaw(t('Trusted Host Settings')); $this->assertRaw(t('The trusted_host_patterns setting is set to allow')); diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php index db7aa38021ea2680a7760526510ccf3bd546208d..b49217b68e415c5a86f47f6054ba8b6cd738d3b2 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php @@ -190,7 +190,7 @@ public function testUpdatedSite() { $this->drupalGet('admin/config/content/formats'); $this->assertText('Test text format'); $this->drupalGet('admin/config/content/formats/manage/test_text_format'); - $this->assertResponse('200'); + $this->assertResponse(200); // Make sure our feed still exists. $this->drupalGet('admin/config/services/aggregator'); @@ -323,7 +323,7 @@ public function testUpdatedSite() { $this->assertText('Test root term'); $this->assertText('Test child term'); $this->drupalGet('taxonomy/term/3'); - $this->assertResponse('200'); + $this->assertResponse(200); // Make sure the terms are still translated. $this->drupalGet('taxonomy/term/2/translations'); diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php index 8df1618ed24a8db810dfdff7ef7830b7a22afd99..8a009298c9cd95b04b4b3244b2dca6bdad7700e7 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php @@ -98,13 +98,17 @@ public function testTaxonomyImageAccess() { $access_user = $this->drupalCreateUser(['access content']); $no_access_user = $this->drupalCreateUser(); $image = File::load($term->field_test->target_id); + + // Ensure a user that should be able to access the file can access it. $this->drupalLogin($access_user); $this->drupalGet(file_create_url($image->getFileUri())); - $this->assertResponse(200, 'Private image on term is accessible with right permission'); + $this->assertResponse(200); + // Ensure a user that should not be able to access the file cannot access + // it. $this->drupalLogin($no_access_user); $this->drupalGet(file_create_url($image->getFileUri())); - $this->assertResponse(403, 'Private image on term not accessible without right permission'); + $this->assertResponse(403); } } diff --git a/core/modules/taxonomy/tests/src/Functional/TermTest.php b/core/modules/taxonomy/tests/src/Functional/TermTest.php index 7202016461332c4344122f3301158d0846090744..8572bd5f4b831a39780ca2ad46b3336e19f41ee2 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTest.php @@ -359,7 +359,7 @@ public function testTermInterface() { // Check the term link can be clicked through to the term page. $this->clickLink($edit['name[0][value]']); - $this->assertResponse(200, 'Term page can be accessed via the listing link.'); + $this->assertResponse(200); // View the term and check that it is correct. $this->drupalGet('taxonomy/term/' . $term->id()); @@ -390,7 +390,7 @@ public function testTermInterface() { // Assert that the term no longer exists. $this->drupalGet('taxonomy/term/' . $term->id()); - $this->assertResponse(404, 'The taxonomy term page was not found.'); + $this->assertResponse(404); } /** diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php index 674d31a7276f30a6449e1f24af8855b28ec4899e..9b153abf593e3abcf5727d36f8b79c31b610268c 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php @@ -131,7 +131,7 @@ public function testTranslateLinkVocabularyAdminPage() { // Verify translation links. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); - $this->assertResponse(200, 'The translatable vocabulary page was found.'); + $this->assertResponse(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.'); diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php index c3fb9c69b08e83172f7c586445a70c784f9ae211..0342c3838a8b542e7316229c1f0f6618bc4a0835 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php @@ -85,7 +85,7 @@ public function testVocabularyDefaultLanguageForTerms() { // Check that the vocabulary was actually created. $this->drupalGet('admin/structure/taxonomy/manage/' . $edit['vid']); - $this->assertResponse(200, 'The vocabulary has been created.'); + $this->assertResponse(200); // Check that the language settings were saved. $language_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $edit['vid']); diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php index a7fac48138e37268c51e9d75916a1fbac0c298e3..c6b1c81f9bac410b64db4f97bdba20fe2f2649a7 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php @@ -304,9 +304,9 @@ public function testVocabularyPermissionsTaxonomyTerm() { $user = $this->drupalCreateUser(["edit terms in {$vocabulary->id()}"]); $this->drupalLogin($user); - // Visit the main taxonomy administration page. + // Ensure the taxonomy term add form is denied. $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add'); - $this->assertResponse(403, 'Add taxonomy term form open failed.'); + $this->assertResponse(403); // Create a test term. $term = $this->createTerm($vocabulary); @@ -324,24 +324,24 @@ public function testVocabularyPermissionsTaxonomyTerm() { $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']); $this->assert(isset($view_link), 'The message area contains a link to a term'); - // Delete the vocabulary. + // Ensure the term cannot be deleted. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); - $this->assertResponse(403, 'Delete taxonomy term form open failed.'); + $this->assertResponse(403); // Test as user with "delete" permissions. $user = $this->drupalCreateUser(["delete terms in {$vocabulary->id()}"]); $this->drupalLogin($user); - // Visit the main taxonomy administration page. + // Ensure the taxonomy term add form is denied. $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add'); - $this->assertResponse(403, 'Add taxonomy term form open failed.'); + $this->assertResponse(403); // Create a test term. $term = $this->createTerm($vocabulary); - // Edit the term. + // Ensure that the term cannot be edited. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); - $this->assertResponse(403, 'Edit taxonomy term form open failed.'); + $this->assertResponse(403); // Delete the vocabulary. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); @@ -355,20 +355,20 @@ public function testVocabularyPermissionsTaxonomyTerm() { $user = $this->drupalCreateUser(); $this->drupalLogin($user); - // Visit the main taxonomy administration page. + // Ensure the taxonomy term add form is denied. $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add'); - $this->assertResponse(403, 'Add taxonomy term form open failed.'); + $this->assertResponse(403); // Create a test term. $term = $this->createTerm($vocabulary); - // Edit the term. + // Ensure that the term cannot be edited. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); - $this->assertResponse(403, 'Edit taxonomy term form open failed.'); + $this->assertResponse(403); - // Delete the vocabulary. + // Ensure the term cannot be deleted. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); - $this->assertResponse(403, 'Delete taxonomy term form open failed.'); + $this->assertResponse(403); } } diff --git a/core/modules/update/tests/src/Functional/UpdateCoreTest.php b/core/modules/update/tests/src/Functional/UpdateCoreTest.php index 41eea608236db727428944d1eeb8bf98757a65fe..9b0564187ec90fb5fa9acdbec5a6ee875e8d2fdd 100644 --- a/core/modules/update/tests/src/Functional/UpdateCoreTest.php +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php @@ -98,7 +98,7 @@ public function testNormalUpdateAvailable() { // Ensure that the update check requires a token. $this->drupalGet('admin/reports/updates/check'); - $this->assertResponse(403, 'Accessing admin/reports/updates/check without a CSRF token results in access denied.'); + $this->assertResponse(403); foreach ([0, 1] as $minor_version) { foreach (['-alpha1', '-beta1', ''] as $extra_version) { diff --git a/core/modules/user/tests/src/Functional/UserAdminListingTest.php b/core/modules/user/tests/src/Functional/UserAdminListingTest.php index c34e0aae8c9cf270a2a5af7f471c62d3270a4034..225e34b520608cf4641a25f7dc98dcddd2e2c0f1 100644 --- a/core/modules/user/tests/src/Functional/UserAdminListingTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminListingTest.php @@ -22,8 +22,9 @@ class UserAdminListingTest extends BrowserTestBase { * Tests the listing. */ public function testUserListing() { + // Ensure the anonymous user cannot access the admin listing. $this->drupalGet('admin/people'); - $this->assertResponse(403, 'Anonymous user does not have access to the user admin listing.'); + $this->assertResponse(403); // Create a bunch of users. $accounts = []; @@ -62,8 +63,9 @@ public function testUserListing() { $this->drupalLogin($admin_user); + // Ensure the admin user can access the admin listing. $this->drupalGet('admin/people'); - $this->assertResponse(200, 'The admin user has access to the user admin listing.'); + $this->assertResponse(200); $result = $this->xpath('//table[contains(@class, "responsive-enabled")]/tbody/tr'); $result_accounts = []; diff --git a/core/modules/user/tests/src/Functional/UserCancelTest.php b/core/modules/user/tests/src/Functional/UserCancelTest.php index 5895a0cf936d13ee9d99d5d5d180dfc6e905e72f..357a3fb7f6639ea97d0ec46856a35357e6fff037 100644 --- a/core/modules/user/tests/src/Functional/UserCancelTest.php +++ b/core/modules/user/tests/src/Functional/UserCancelTest.php @@ -61,7 +61,7 @@ public function testUserCancelWithoutPermission() { // Attempt bogus account cancellation request confirmation. $timestamp = $account->getLastLoginTime(); $this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp)); - $this->assertResponse(403, 'Bogus cancelling request rejected.'); + $this->assertResponse(403); $user_storage->resetCache([$account->id()]); $account = $user_storage->load($account->id()); $this->assertTrue($account->isActive(), 'User account was not canceled.'); diff --git a/core/modules/user/tests/src/Functional/UserRegistrationTest.php b/core/modules/user/tests/src/Functional/UserRegistrationTest.php index ddad258635e7a4e71239df50d3ee402e81732932..adabd94ba4ccb5da97bb7b05b5e1103661fbc3ba 100644 --- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php +++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php @@ -34,10 +34,11 @@ public function testRegistrationWithEmailVerification() { // Require email verification. $config->set('verify_mail', TRUE)->save(); - // Set registration to administrator only. + // Set registration to administrator only and ensure the user registration + // page is inaccessible. $config->set('register', UserInterface::REGISTER_ADMINISTRATORS_ONLY)->save(); $this->drupalGet('user/register'); - $this->assertResponse(403, 'Registration page is inaccessible when only administrators can create accounts.'); + $this->assertResponse(403); // Allow registration by site visitors without administrator approval. $config->set('register', UserInterface::REGISTER_VISITORS)->save(); diff --git a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php index bd5505278cf09551e7327d0e3ff6a9a4a11df7f9..c9db300111533b94d2c72722421011b1e5837a18 100644 --- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php @@ -93,10 +93,10 @@ public function testRoleAdministration() { // Make sure that the system-defined roles can be edited via the user // interface. $this->drupalGet('admin/people/roles/manage/' . RoleInterface::ANONYMOUS_ID); - $this->assertResponse(200, 'Access granted when trying to edit the built-in anonymous role.'); + $this->assertResponse(200); $this->assertNoText(t('Delete role'), 'Delete button for the anonymous role is not present.'); $this->drupalGet('admin/people/roles/manage/' . RoleInterface::AUTHENTICATED_ID); - $this->assertResponse(200, 'Access granted when trying to edit the built-in authenticated role.'); + $this->assertResponse(200); $this->assertNoText(t('Delete role'), 'Delete button for the authenticated role is not present.'); } diff --git a/core/modules/user/tests/src/Functional/UserSearchTest.php b/core/modules/user/tests/src/Functional/UserSearchTest.php index 1950a8440d221dd267444e190dc68c96f0888a64..3f54c9945afbc8d0f346317bf2d71f5fbf8e31cc 100644 --- a/core/modules/user/tests/src/Functional/UserSearchTest.php +++ b/core/modules/user/tests/src/Functional/UserSearchTest.php @@ -108,17 +108,19 @@ public function testUserSearch() { $this->drupalPostForm('search/user', $edit, t('Search')); $this->assertText(t('Your search yielded no results.'), 'Blocked users are hidden from the user search results.'); - // Create a user without search permission, and one without user page view - // permission. Verify that neither one can access the user search page. + // Ensure that a user without access to user profiles cannot access the + // user search page. $user3 = $this->drupalCreateUser(['search content']); $this->drupalLogin($user3); $this->drupalGet('search/user'); - $this->assertResponse('403', 'User without user profile access cannot search'); + $this->assertResponse(403); + // Ensure that a user without search permission cannot access the user + // search page. $user4 = $this->drupalCreateUser(['access user profiles']); $this->drupalLogin($user4); $this->drupalGet('search/user'); - $this->assertResponse('403', 'User without search permission cannot search'); + $this->assertResponse(403); $this->drupalLogout(); } diff --git a/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php index f330d5db17f8549a5991be7819cf8e09a69227ae..ce27dab51c6630b7328dd3562a42edc36e6975e3 100644 --- a/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php +++ b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php @@ -49,7 +49,7 @@ public function testUserEditAccess() { // Ensure that the account "no_edit" can not be edited. $this->drupalGet('user/' . $no_edit_user->id() . '/edit'); $this->assertFalse($no_edit_user->access('update', $admin_user)); - $this->assertResponse(403, 'The user may not be edited.'); + $this->assertResponse(403); // Test blocking the account "no_edit". $edit = [ @@ -109,10 +109,10 @@ public function testUserDeleteAccess() { // Ensure that the account "no_delete" can not be deleted. $this->drupalGet('user/' . $account->id() . '/cancel'); - $this->assertResponse(403, 'The user "no_delete" may not be deleted.'); + $this->assertResponse(403); // Ensure that the account "may_delete" *can* be deleted. $this->drupalGet('user/' . $account2->id() . '/cancel'); - $this->assertResponse(200, 'The user "may_delete" may be deleted.'); + $this->assertResponse(200); // Test deleting the accounts "no_delete" and "may_delete". $edit = [ diff --git a/core/modules/views_ui/tests/src/Functional/ReportTest.php b/core/modules/views_ui/tests/src/Functional/ReportTest.php index 4d2326487b3155ea5b79c20457d81619e8ca6f1f..53363a1f2ee397b401db790af77ef9564975378b 100644 --- a/core/modules/views_ui/tests/src/Functional/ReportTest.php +++ b/core/modules/views_ui/tests/src/Functional/ReportTest.php @@ -36,7 +36,7 @@ public function testReport() { // Test the report page. $this->drupalGet('admin/reports/views-plugins'); - $this->assertResponse(200, "Views report page exists"); + $this->assertResponse(200); } } diff --git a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php index c65df1edef91885cdfd1a656180353651961686f..096c5670dd016908b08f0f832b0474e55685c794 100644 --- a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php +++ b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php @@ -115,7 +115,7 @@ public function testUncaughtFatalError() { '%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()', ]; $this->drupalGet('error-test/generate-fatals'); - $this->assertResponse(500, 'Received expected HTTP status code.'); + $this->assertResponse(500); $message = new FormattableMarkup('%type: @message in %function (line ', $fatal_error); $this->assertRaw((string) $message); $this->assertRaw('<pre class="backtrace">');