From 6b7a53243752be5411df34684b4e11226b3238ca Mon Sep 17 00:00:00 2001 From: xjm Date: Fri, 22 May 2020 12:37:50 -0500 Subject: [PATCH] Issue #3132964 by jungle, longwave, sja112, dww, xjm, daffie: assertResponse() does not actually support a $message parameter, so stop passing one (cherry picked from commit f09c8902983f944b4c99a26b4ee6f573e7290e08) --- .../tests/src/Functional/AddFeedTest.php | 4 +- .../src/Functional/AggregatorTestBase.php | 2 +- .../tests/src/Functional/DeleteFeedTest.php | 2 +- .../src/Functional/FeedAdminDisplayTest.php | 2 +- .../tests/src/Functional/FeedParserTest.php | 7 ++- .../tests/src/Functional/UpdateFeedTest.php | 2 +- .../tests/src/Functional/BasicAuthTest.php | 34 +++++++++------ .../tests/src/Functional/BlockUiTest.php | 11 +++-- .../Functional/BlockContentPageViewTest.php | 4 +- .../book/tests/src/Functional/BookTest.php | 14 +++--- .../tests/src/Functional/CommentAdminTest.php | 8 ++-- .../tests/src/Functional/CommentTypeTest.php | 3 +- .../src/Functional/ConfigExportUITest.php | 2 +- .../src/Functional/ContactLanguageTest.php | 4 +- .../src/Functional/ContactPersonalTest.php | 2 +- .../ContentTranslationUITestBase.php | 2 +- .../ContentTranslationWorkflowsTest.php | 13 +++--- .../tests/src/Functional/DownloadTest.php | 2 +- .../FileFieldAnonymousSubmissionTest.php | 6 +-- .../src/Functional/FileFieldWidgetTest.php | 14 +++--- .../tests/src/Functional/FilePrivateTest.php | 43 +++++++++++-------- .../PrivateFileOnTranslatedEntityTest.php | 4 +- .../src/Functional/SaveUploadFormTest.php | 39 ++++++++--------- .../tests/src/Functional/SaveUploadTest.php | 28 ++++++------ .../tests/src/Functional/FilterAdminTest.php | 4 +- .../forum/tests/src/Functional/ForumTest.php | 2 +- .../help/tests/src/Functional/NoHelpTest.php | 4 +- .../src/Functional/ImageAdminStylesTest.php | 1 - .../src/Functional/ImageDimensionsTest.php | 20 ++++----- .../src/Functional/ImageFieldDisplayTest.php | 8 ++-- .../Functional/ImageStylesPathAndUrlTest.php | 26 +++++------ .../QuickEditImageControllerTest.php | 2 +- .../tests/src/Functional/LanguageListTest.php | 8 ++-- .../LanguagePathMonolingualTest.php | 2 +- .../LanguageUILanguageNegotiationTest.php | 2 +- .../Functional/LanguageUrlRewritingTest.php | 12 +++--- .../Functional/LocaleTranslationUiTest.php | 2 +- .../tests/src/Functional/NodeTypeTest.php | 2 +- .../src/Functional/Views/RevisionLinkTest.php | 2 +- .../tests/src/Functional/PageCacheTest.php | 21 ++++++--- .../tests/src/Functional/PathLanguageTest.php | 2 +- .../src/Functional/PathTaxonomyTermTest.php | 4 +- .../src/Functional/UrlAlterFunctionalTest.php | 4 +- .../ResponsiveImageFieldDisplayTest.php | 8 ++-- .../tests/src/Functional/ResourceTest.php | 4 +- .../Functional/Views/StyleSerializerTest.php | 37 ++++++++-------- .../src/Functional/SearchPageTextTest.php | 4 +- .../src/Functional/ShortcutLinksTest.php | 17 +++----- .../Form/StateValuesCleanAdvancedTest.php | 2 +- .../Module/InstallUninstallTest.php | 2 +- .../Module/PrepareUninstallTest.php | 4 +- .../Routing/RouterPermissionTest.php | 9 ++-- .../Session/SessionAuthenticationTest.php | 14 +++--- .../src/Functional/Session/SessionTest.php | 17 +++++--- .../tests/src/Functional/System/AdminTest.php | 4 +- .../src/Functional/System/DateTimeTest.php | 2 +- .../Functional/System/ErrorHandlerTest.php | 8 ++-- .../src/Functional/System/HtaccessTest.php | 4 +- .../src/Functional/System/IndexPhpTest.php | 4 +- .../src/Functional/System/StatusTest.php | 4 +- .../tests/src/Functional/System/ThemeTest.php | 12 +++--- .../Functional/System/TrustedHostsTest.php | 4 +- .../UpdatePathTestBaseFilledTest.php | 4 +- .../src/Functional/TaxonomyImageTest.php | 8 +++- .../tests/src/Functional/TermTest.php | 4 +- .../src/Functional/TermTranslationUITest.php | 2 +- .../src/Functional/VocabularyLanguageTest.php | 2 +- .../Functional/VocabularyPermissionsTest.php | 28 ++++++------ .../tests/src/Functional/UpdateCoreTest.php | 2 +- .../src/Functional/UserAdminListingTest.php | 6 ++- .../tests/src/Functional/UserCancelTest.php | 2 +- .../src/Functional/UserRegistrationTest.php | 5 ++- .../src/Functional/UserRoleAdminTest.php | 4 +- .../tests/src/Functional/UserSearchTest.php | 10 +++-- .../Functional/Views/BulkFormAccessTest.php | 6 +-- .../tests/src/Functional/ReportTest.php | 2 +- .../Bootstrap/UncaughtExceptionTest.php | 2 +- 77 files changed, 335 insertions(+), 292 deletions(-) diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php index 03497a91fa5..2abe8aeb047 100644 --- a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php @@ -35,7 +35,7 @@ class AddFeedTest extends AggregatorTestBase { // 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 @@ class AddFeedTest extends AggregatorTestBase { // 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 6b3b9bbea57..ebf19fb052c 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php @@ -181,7 +181,7 @@ abstract class AggregatorTestBase extends BrowserTestBase { 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 9ff7b3435ba..58e3b0fda3c 100644 --- a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php @@ -45,7 +45,7 @@ class DeleteFeedTest extends AggregatorTestBase { // 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 ec327a595e7..e83128c05cd 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php @@ -22,7 +22,7 @@ class FeedAdminDisplayTest extends AggregatorTestBase { $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 82cea3ff9e2..54e396a57e9 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 @@ class FeedParserTest extends AggregatorTestBase { $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 @@ class FeedParserTest extends AggregatorTestBase { $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 @@ class FeedParserTest extends AggregatorTestBase { $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 a7ee2436cad..8f17ceb0a6d 100644 --- a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php +++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php @@ -44,7 +44,7 @@ class UpdateFeedTest extends AggregatorTestBase { // 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 89b3de24e97..eac42bff1bc 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 @@ class BasicAuthTest extends BrowserTestBase { $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 @@ class BasicAuthTest extends BrowserTestBase { // 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 @@ class BasicAuthTest extends BrowserTestBase { // 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 @@ class BasicAuthTest extends BrowserTestBase { // 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 @@ class BasicAuthTest extends BrowserTestBase { $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 @@ class BasicAuthTest extends BrowserTestBase { // 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 7e98e70938d..433f6435e63 100644 --- a/core/modules/block/tests/src/Functional/BlockUiTest.php +++ b/core/modules/block/tests/src/Functional/BlockUiTest.php @@ -89,13 +89,15 @@ class BlockUiTest extends BrowserTestBase { $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('Test theme'); + // 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); } /** @@ -154,16 +156,19 @@ class BlockUiTest extends BrowserTestBase { $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 c9bc68b0f3c..527680a6133 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 @@ class BlockContentPageViewTest extends BlockContentTestBase { // 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(''); $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 e1e81955d23..a5a3cba99f3 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -209,11 +209,11 @@ class BookTest extends BrowserTestBase { // 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(); @@ -224,14 +224,14 @@ class BookTest extends BrowserTestBase { // 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); } /** @@ -351,9 +351,11 @@ class BookTest extends BrowserTestBase { $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 47a3c6494a5..cb625e21641 100644 --- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php @@ -156,12 +156,14 @@ class CommentAdminTest extends CommentTestBase { $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 889e2246e7a..75953595917 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -64,8 +64,9 @@ class CommentTypeTest extends CommentTestBase { // 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 ba88e6d2d1a..299d7c158dc 100644 --- a/core/modules/config/tests/src/Functional/ConfigExportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigExportUITest.php @@ -53,7 +53,7 @@ class ConfigExportUITest extends BrowserTestBase { // 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 2f08a9f40b9..422977b7f0a 100644 --- a/core/modules/contact/tests/src/Functional/ContactLanguageTest.php +++ b/core/modules/contact/tests/src/Functional/ContactLanguageTest.php @@ -51,7 +51,7 @@ class ContactLanguageTest extends BrowserTestBase { 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 @@ class ContactLanguageTest extends BrowserTestBase { // 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 684532153bc..ff6dfcfe55c 100644 --- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php +++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php @@ -137,7 +137,7 @@ class ContactPersonalTest extends BrowserTestBase { $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 2d360d22491..89c7ad93b09 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 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase { $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 2efc272143c..8e13baac163 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php @@ -159,26 +159,25 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { 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); @@ -194,7 +193,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { 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]; @@ -222,7 +221,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { 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]; @@ -250,7 +249,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { 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 5ff4c8e7895..2df73d3c917 100644 --- a/core/modules/file/tests/src/Functional/DownloadTest.php +++ b/core/modules/file/tests/src/Functional/DownloadTest.php @@ -77,7 +77,7 @@ class DownloadTest extends FileManagedTestBase { $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 26e74df04ef..6c3d14d2eb5 100644 --- a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php @@ -40,7 +40,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { // 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 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { // 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 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { // 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 bd28b840e78..496473153ed 100644 --- a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php @@ -93,7 +93,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { // 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 @@ class FileFieldWidgetTest extends FileFieldTestBase { // 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 @@ class FileFieldWidgetTest extends FileFieldTestBase { $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 @@ class FileFieldWidgetTest extends FileFieldTestBase { // 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 @@ class FileFieldWidgetTest extends FileFieldTestBase { // 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 0fb36c354d6..1f6020c200c 100644 --- a/core/modules/file/tests/src/Functional/FilePrivateTest.php +++ b/core/modules/file/tests/src/Functional/FilePrivateTest.php @@ -60,10 +60,11 @@ class FilePrivateTest extends FileFieldTestBase { $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 @@ class FilePrivateTest extends FileFieldTestBase { // 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 @@ class FilePrivateTest extends FileFieldTestBase { \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 @@ class FilePrivateTest extends FileFieldTestBase { $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 @@ class FilePrivateTest extends FileFieldTestBase { $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 @@ class FilePrivateTest extends FileFieldTestBase { $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 @@ class FilePrivateTest extends FileFieldTestBase { $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 a838efef66f..ea032ae410b 100644 --- a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php +++ b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php @@ -96,7 +96,7 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase { $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 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase { $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 1e586822470..c6013c41c88 100644 --- a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php +++ b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php @@ -86,7 +86,7 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { $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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { ]; $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:') . ' ' . $extensions . ''; $this->assertRaw($message, 'Cannot upload a disallowed extension'); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); @@ -184,7 +184,7 @@ class SaveUploadFormTest extends FileManagedTestBase { ]; $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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { ]; $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') . ' ' . $this->phpfile->filename . '.txt' . ''; $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 @@ class SaveUploadFormTest extends FileManagedTestBase { 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 @@ class SaveUploadFormTest extends FileManagedTestBase { $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 @@ class SaveUploadFormTest extends FileManagedTestBase { ]; $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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { \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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 @@ class SaveUploadFormTest extends FileManagedTestBase { $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 @@ class SaveUploadFormTest extends FileManagedTestBase { '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 2e6cad07760..9833d6a5ae7 100644 --- a/core/modules/file/tests/src/Functional/SaveUploadTest.php +++ b/core/modules/file/tests/src/Functional/SaveUploadTest.php @@ -81,7 +81,7 @@ class SaveUploadTest extends FileManagedTestBase { '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 @@ class SaveUploadTest extends FileManagedTestBase { $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 @@ class SaveUploadTest extends FileManagedTestBase { '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 @@ class SaveUploadTest extends FileManagedTestBase { ]; $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:') . ' ' . $extensions . ''; $this->assertRaw($message, 'Cannot upload a disallowed extension'); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); @@ -204,7 +204,7 @@ class SaveUploadTest extends FileManagedTestBase { ]; $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 @@ class SaveUploadTest extends FileManagedTestBase { '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 @@ class SaveUploadTest extends FileManagedTestBase { ]; $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') . ' ' . $this->phpfile->filename . '.txt' . ''; $this->assertRaw($message, 'Dangerous file was renamed.'); $this->assertSession()->pageTextContains('File name is php-2.php.txt.'); @@ -261,7 +261,7 @@ class SaveUploadTest extends FileManagedTestBase { 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 @@ class SaveUploadTest extends FileManagedTestBase { $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 @@ class SaveUploadTest extends FileManagedTestBase { ]; $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 @@ class SaveUploadTest extends FileManagedTestBase { '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 @@ class SaveUploadTest extends FileManagedTestBase { '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 @@ class SaveUploadTest extends FileManagedTestBase { '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 @@ class SaveUploadTest extends FileManagedTestBase { \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 b0553f967ec..fa14c6d1864 100644 --- a/core/modules/filter/tests/src/Functional/FilterAdminTest.php +++ b/core/modules/filter/tests/src/Functional/FilterAdminTest.php @@ -163,7 +163,7 @@ class FilterAdminTest extends BrowserTestBase { // 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 @@ class FilterAdminTest extends BrowserTestBase { $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 91f42a428b0..5c96dd79a1d 100644 --- a/core/modules/forum/tests/src/Functional/ForumTest.php +++ b/core/modules/forum/tests/src/Functional/ForumTest.php @@ -491,7 +491,7 @@ class ForumTest extends BrowserTestBase { // 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 0b68c0d225e..3416e90211a 100644 --- a/core/modules/help/tests/src/Functional/NoHelpTest.php +++ b/core/modules/help/tests/src/Functional/NoHelpTest.php @@ -47,8 +47,10 @@ class NoHelpTest extends BrowserTestBase { $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 2ada4e1b40d..02cbba80b00 100644 --- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @@ -217,7 +217,6 @@ class ImageAdminStylesTest extends ImageFieldTestBase { // 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 6bc06d84831..1efbddaa832 100644 --- a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php +++ b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php @@ -80,7 +80,7 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { // $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 @@ class ImageDimensionsTest extends BrowserTestBase { $this->assertEqual($this->getImageTag($variables), ''); $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 591ad9f4e1c..54dfed30b2c 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -152,10 +152,10 @@ class ImageFieldDisplayTest extends ImageFieldTestBase { $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 @@ class ImageFieldDisplayTest extends ImageFieldTestBase { $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 45060aa4a39..f66bfa2d870 100644 --- a/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php +++ b/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php @@ -126,7 +126,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { $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 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { } // 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 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { // 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 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { // 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 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { // 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 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { $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 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { 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 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { $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 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase { $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 5c8f3301999..41732355515 100644 --- a/core/modules/image/tests/src/Functional/QuickEditImageControllerTest.php +++ b/core/modules/image/tests/src/Functional/QuickEditImageControllerTest.php @@ -86,7 +86,7 @@ class QuickEditImageControllerTest extends BrowserTestBase { '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 45ec251ba24..3fa3f5582ac 100644 --- a/core/modules/language/tests/src/Functional/LanguageListTest.php +++ b/core/modules/language/tests/src/Functional/LanguageListTest.php @@ -88,7 +88,7 @@ class LanguageListTest extends BrowserTestBase { // 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 @@ class LanguageListTest extends BrowserTestBase { $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 @@ class LanguageListTest extends BrowserTestBase { $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 @@ class LanguageListTest extends BrowserTestBase { // 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 5c4bcfa0160..525228542f0 100644 --- a/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php +++ b/core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php @@ -71,7 +71,7 @@ class LanguagePathMonolingualTest extends BrowserTestBase { // 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 81fd9c2fd08..5085fe17b48 100644 --- a/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php @@ -257,7 +257,7 @@ class LanguageUILanguageNegotiationTest extends BrowserTestBase { ->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 49007619dfc..fb464833aae 100644 --- a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php @@ -62,7 +62,7 @@ class LanguageUrlRewritingTest extends BrowserTestBase { 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 @@ class LanguageUrlRewritingTest extends BrowserTestBase { * * @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('', [], $options)->toString()), '/'); @@ -95,11 +93,11 @@ class LanguageUrlRewritingTest extends BrowserTestBase { // 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 bcd0865c4ad..5bdfbc669c1 100644 --- a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php @@ -182,7 +182,7 @@ class LocaleTranslationUiTest extends BrowserTestBase { // 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 534f5564168..6068f4ea43f 100644 --- a/core/modules/node/tests/src/Functional/NodeTypeTest.php +++ b/core/modules/node/tests/src/Functional/NodeTypeTest.php @@ -64,7 +64,7 @@ class NodeTypeTest extends NodeTestBase { $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 34f1f7f7fa0..38f23218215 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 @@ class RevisionLinkTest extends NodeTestBase { $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 e14cbdd42bb..e6e8e4b5ebb 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 @@ class PageCacheTest extends BrowserTestBase { $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('#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 c85083090af..d108a8e83d3 100644 --- a/core/modules/path/tests/src/Functional/PathLanguageTest.php +++ b/core/modules/path/tests/src/Functional/PathLanguageTest.php @@ -173,7 +173,7 @@ class PathLanguageTest extends PathTestBase { // 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 1db6bb1885d..9cf084c12bd 100644 --- a/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php +++ b/core/modules/path/tests/src/Functional/PathTaxonomyTermTest.php @@ -76,7 +76,7 @@ class PathTaxonomyTermTest extends PathTestBase { // 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 @@ class PathTaxonomyTermTest extends PathTestBase { // 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 42f789db28e..d2025bf53e7 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 @@ class UrlAlterFunctionalTest extends BrowserTestBase { // 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 @@ class UrlAlterFunctionalTest extends BrowserTestBase { $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 a955bd68ab3..e354882c067 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 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase { $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 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase { $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 a38231df557..84bbd8cf9f2 100644 --- a/core/modules/rest/tests/src/Functional/ResourceTest.php +++ b/core/modules/rest/tests/src/Functional/ResourceTest.php @@ -83,7 +83,7 @@ class ResourceTest extends BrowserTestBase { // 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 @@ class ResourceTest extends BrowserTestBase { // 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 d521d702512..1a851d002f1 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 @@ class StyleSerializerTest extends ViewTestBase { $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 @@ class StyleSerializerTest extends ViewTestBase { // 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 148b4372ce7..6978277b209 100644 --- a/core/modules/search/tests/src/Functional/SearchPageTextTest.php +++ b/core/modules/search/tests/src/Functional/SearchPageTextTest.php @@ -157,13 +157,13 @@ class SearchPageTextTest extends BrowserTestBase { // 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 a252ae687d9..291d8872889 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php @@ -406,17 +406,12 @@ class ShortcutLinksTest extends ShortcutTestBase { // 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 b1b44431432..fc9d0f7ee2a 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 @@ class StateValuesCleanAdvancedTest extends BrowserTestBase { $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 b05891eb11d..9578940e6f9 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -356,7 +356,7 @@ class InstallUninstallTest extends ModuleTestBase { */ 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 fdabecdbec8..4bda0bb5902 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 @@ class PrepareUninstallTest extends BrowserTestBase { $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 1985725ef35..ffe56373dfd 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 45b40fe4251..69577f050dd 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 @@ class SessionAuthenticationTest extends BrowserTestBase { // 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 @@ class SessionAuthenticationTest extends BrowserTestBase { // 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 @@ class SessionAuthenticationTest extends BrowserTestBase { $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 @@ class SessionAuthenticationTest extends BrowserTestBase { // 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 f83169b29e3..a7448be4d31 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 @@ class SessionTest extends BrowserTestBase { $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 @@ class SessionTest extends BrowserTestBase { $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 @@ class SessionTest extends BrowserTestBase { // 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 2face42913a..72cca313a93 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 @@ class AdminTest extends BrowserTestBase { $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 @@ class AdminTest extends BrowserTestBase { $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 f3d6f3eae88..c1b9e01ef16 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 @@ class DateTimeTest extends BrowserTestBase { $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 9eab301a9c4..aa8a097e537 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 @@ class ErrorHandlerTest extends BrowserTestBase { // 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 @@ class ErrorHandlerTest extends BrowserTestBase { // 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 @@ class ErrorHandlerTest extends BrowserTestBase { // 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 @@ class ErrorHandlerTest extends BrowserTestBase { // 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 678a8d9b4a2..728399294a2 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 @@ class HtaccessTest extends BrowserTestBase { // 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 @@ class HtaccessTest extends BrowserTestBase { 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 4146d0c655c..fc7aa2cfe5b 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 @@ class IndexPhpTest extends BrowserTestBase { $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 6d4cce4c7b0..97d660e2fa6 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 @@ class StatusTest extends BrowserTestBase { 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 @@ class StatusTest extends BrowserTestBase { $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 2a7b5f898cd..f07345b5854 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 @@ class ThemeTest extends BrowserTestBase { * 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 @@ class ThemeTest extends BrowserTestBase { $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 13f43b80b2e..07f3f27f100 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 @@ class TrustedHostsTest extends BrowserTestBase { */ 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 @@ class TrustedHostsTest extends BrowserTestBase { $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 503b1c50b78..181dc09f827 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 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { $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 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { $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 6bd4ef5bca5..dc4ed06159e 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php @@ -98,13 +98,17 @@ class TaxonomyImageTest extends TaxonomyTestBase { $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 48dd4004a32..66a7c7f5e7a 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTest.php @@ -359,7 +359,7 @@ class TermTest extends TaxonomyTestBase { // 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 @@ class TermTest extends TaxonomyTestBase { // 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 74b7b2467c3..b1066d88f21 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php @@ -131,7 +131,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase { // 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 17a096b2cbe..f7df57d8535 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php @@ -85,7 +85,7 @@ class VocabularyLanguageTest extends TaxonomyTestBase { // 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 174feab7f75..3515858528e 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php @@ -304,9 +304,9 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { $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 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { $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 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { $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 b7a8c59b893..8fe1d84a115 100644 --- a/core/modules/update/tests/src/Functional/UpdateCoreTest.php +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php @@ -98,7 +98,7 @@ class UpdateCoreTest extends UpdateTestBase { // 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 c34e0aae8c9..225e34b5206 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 @@ class UserAdminListingTest extends BrowserTestBase { $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 89c78db2438..5b30633c9d9 100644 --- a/core/modules/user/tests/src/Functional/UserCancelTest.php +++ b/core/modules/user/tests/src/Functional/UserCancelTest.php @@ -61,7 +61,7 @@ class UserCancelTest extends BrowserTestBase { // 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 760836b307e..32be44858ac 100644 --- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php +++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php @@ -34,10 +34,11 @@ class UserRegistrationTest extends BrowserTestBase { // 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 a9c64a882bf..cb7863617cc 100644 --- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php @@ -93,10 +93,10 @@ class UserRoleAdminTest extends BrowserTestBase { // 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 49fca33902e..9557b5347c4 100644 --- a/core/modules/user/tests/src/Functional/UserSearchTest.php +++ b/core/modules/user/tests/src/Functional/UserSearchTest.php @@ -108,17 +108,19 @@ class UserSearchTest extends BrowserTestBase { $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 358ae137913..9b7f9f6cc80 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 @@ class BulkFormAccessTest extends UserTestBase { // 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 @@ class BulkFormAccessTest extends UserTestBase { // 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 5322e010847..052ac1bb99a 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 @@ class ReportTest extends UITestBase { // 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 eff926f7b1a..ac0b60ed240 100644 --- a/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php +++ b/core/tests/Drupal/FunctionalTests/Bootstrap/UncaughtExceptionTest.php @@ -115,7 +115,7 @@ class UncaughtExceptionTest extends BrowserTestBase { '%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('
');