From 8972542f9fdbdd04d86c01002b3f3df7529ff308 Mon Sep 17 00:00:00 2001 From: xjm Date: Thu, 28 May 2020 14:02:21 -0500 Subject: [PATCH] Issue #3139218 by sja112, mondrake, xjm, ketikagrover, daffie: Replace usages of AssertLegacyTrait::assertResponse(), which is deprecated --- .../src/Functional/ConfigurationTest.php | 12 ++--- .../tests/src/Functional/AddFeedTest.php | 6 +-- .../src/Functional/AggregatorAdminTest.php | 2 +- .../Functional/AggregatorRenderingTest.php | 4 +- .../src/Functional/AggregatorTestBase.php | 4 +- .../tests/src/Functional/DeleteFeedTest.php | 2 +- .../src/Functional/FeedAdminDisplayTest.php | 2 +- .../tests/src/Functional/FeedParserTest.php | 6 +-- .../src/Functional/UpdateFeedItemTest.php | 4 +- .../tests/src/Functional/UpdateFeedTest.php | 2 +- .../tests/src/Functional/BasicAuthTest.php | 36 +++++++------- .../src/Functional/BlockAdminThemeTest.php | 4 +- .../tests/src/Functional/BlockCacheTest.php | 4 +- .../tests/src/Functional/BlockDemoTest.php | 6 +-- .../src/Functional/BlockFormInBlockTest.php | 4 +- .../tests/src/Functional/BlockUiTest.php | 10 ++-- .../src/Functional/Views/DisplayBlockTest.php | 2 +- .../Functional/BlockContentCreationTest.php | 4 +- .../src/Functional/BlockContentListTest.php | 6 +-- .../Functional/BlockContentListViewsTest.php | 6 +-- .../Functional/BlockContentPageViewTest.php | 2 +- .../src/Functional/BlockContentTypeTest.php | 4 +- .../Views/BlockContentIntegrationTest.php | 4 +- .../src/Functional/BookBreadcrumbTest.php | 2 +- .../book/tests/src/Functional/BookTest.php | 12 ++--- .../src/Functional/CKEditorAdminTest.php | 2 +- .../color/tests/src/Functional/ColorTest.php | 4 +- .../tests/src/Functional/CommentAdminTest.php | 8 ++-- .../src/Functional/CommentAnonymousTest.php | 6 +-- .../src/Functional/CommentInterfaceTest.php | 6 +-- .../src/Functional/CommentNonNodeTest.php | 8 ++-- .../Functional/CommentTranslationUITest.php | 2 +- .../tests/src/Functional/CommentTypeTest.php | 2 +- .../Views/CommentOperationsTest.php | 2 +- .../Views/CommentRestExportTest.php | 2 +- .../src/Functional/Views/NodeCommentsTest.php | 2 +- .../src/Functional/ConfigEntityListTest.php | 8 ++-- .../Functional/ConfigEntityStatusUITest.php | 4 +- .../tests/src/Functional/ConfigEntityTest.php | 12 ++--- .../src/Functional/ConfigExportUITest.php | 4 +- .../src/Functional/ConfigImportUploadTest.php | 2 +- .../ConfigTranslationInstallTest.php | 2 +- .../Functional/ConfigTranslationUiTest.php | 16 +++---- .../ConfigTranslationUiThemeTest.php | 2 +- .../src/Functional/ContactLanguageTest.php | 4 +- .../src/Functional/ContactPersonalTest.php | 34 ++++++------- .../src/Functional/ContactSitewideTest.php | 26 +++++----- .../src/Functional/ModerationFormTest.php | 34 ++++++------- .../ModerationStateNodeTypeTest.php | 6 +-- .../tests/src/Functional/NodeAccessTest.php | 26 +++++----- .../ContentTranslationOperationsTest.php | 4 +- .../ContentTranslationUITestBase.php | 4 +- .../ContentTranslationWorkflowsTest.php | 12 ++--- .../tests/src/Functional/DateFilterTest.php | 4 +- .../src/Functional/DateTimeFieldTest.php | 6 +-- .../src/Functional/DateRangeFieldTest.php | 6 +-- .../dblog/tests/src/Functional/DbLogTest.php | 48 +++++++++---------- .../src/Functional/EditorLoadingTest.php | 2 +- .../EntityReferenceAdminTest.php | 2 +- .../EntityReferenceFileUploadTest.php | 4 +- .../field/tests/src/Functional/FormTest.php | 2 +- .../src/Functional/Views/FieldUITest.php | 4 +- .../src/Functional/EntityDisplayModeTest.php | 12 ++--- .../tests/src/Functional/FieldUIRouteTest.php | 6 +-- .../Functional/ManageFieldsFunctionalTest.php | 10 ++-- .../tests/src/Functional/DownloadTest.php | 4 +- .../FileFieldAnonymousSubmissionTest.php | 12 ++--- .../src/Functional/FileFieldWidgetTest.php | 12 ++--- .../tests/src/Functional/FileListingTest.php | 12 ++--- .../tests/src/Functional/FilePrivateTest.php | 28 +++++------ .../PrivateFileOnTranslatedEntityTest.php | 4 +- .../src/Functional/SaveUploadFormTest.php | 40 ++++++++-------- .../tests/src/Functional/SaveUploadTest.php | 32 ++++++------- .../tests/src/Functional/FilterAdminTest.php | 4 +- .../src/Functional/FilterFormatAccessTest.php | 16 +++---- .../forum/tests/src/Functional/ForumTest.php | 28 +++++------ .../src/Functional/ForumUninstallTest.php | 2 +- .../src/Functional/ExperimentalHelpTest.php | 2 +- .../help/tests/src/Functional/HelpTest.php | 4 +- .../help/tests/src/Functional/NoHelpTest.php | 4 +- .../src/Functional/HelpTopicSearchTest.php | 2 +- .../src/Functional/ImageAdminStylesTest.php | 4 +- .../src/Functional/ImageDimensionsTest.php | 20 ++++---- .../src/Functional/ImageFieldDisplayTest.php | 4 +- .../src/Functional/ImageStyleFlushTest.php | 4 +- .../Functional/ImageStylesPathAndUrlTest.php | 26 +++++----- .../QuickEditImageControllerTest.php | 2 +- .../tests/src/Functional/LanguageListTest.php | 8 ++-- .../LanguagePathMonolingualTest.php | 2 +- .../LanguageUILanguageNegotiationTest.php | 6 +-- .../Functional/LanguageUrlRewritingTest.php | 2 +- .../src/Functional/LocaleLocaleLookupTest.php | 2 +- .../Functional/LocaleTranslationUiTest.php | 2 +- .../Functional/MenuLinkContentFormTest.php | 4 +- .../tests/src/Functional/MenuUiTest.php | 38 +++++++-------- .../src/Functional/MigrateAccessTest.php | 4 +- .../Functional/NodeAccessBaseTableTest.php | 6 +-- .../NodeActionsConfigurationTest.php | 12 ++--- .../tests/src/Functional/NodeAdminTest.php | 8 ++-- .../tests/src/Functional/NodeCreationTest.php | 6 +-- .../tests/src/Functional/NodeHelpTest.php | 4 +- .../src/Functional/NodeRevisionsTest.php | 8 ++-- .../src/Functional/NodeTranslationUITest.php | 8 ++-- .../tests/src/Functional/NodeTypeTest.php | 6 +-- .../Functional/NodeTypeTranslationTest.php | 4 +- .../tests/src/Functional/PagePreviewTest.php | 2 +- .../tests/src/Functional/PageViewTest.php | 6 +-- .../src/Functional/Views/FrontPageTest.php | 2 +- .../Functional/Views/NodeIntegrationTest.php | 4 +- .../src/Functional/Views/RevisionLinkTest.php | 2 +- .../tests/src/Functional/PageCacheTest.php | 26 +++++----- .../tests/src/Functional/PathAliasTest.php | 28 +++++------ .../tests/src/Functional/PathLanguageTest.php | 2 +- .../src/Functional/PathTaxonomyTermTest.php | 4 +- .../src/Functional/UrlAlterFunctionalTest.php | 4 +- .../Functional/ResponsiveImageAdminUITest.php | 2 +- .../ResponsiveImageFieldDisplayTest.php | 4 +- .../tests/src/Functional/ResourceTest.php | 4 +- .../Views/ExcludedFieldTokenTest.php | 2 +- .../src/Functional/Views/FieldCounterTest.php | 2 +- .../Functional/Views/StyleSerializerTest.php | 44 ++++++++--------- .../tests/src/Functional/SearchBlockTest.php | 10 ++-- .../SearchConfigSettingsFormTest.php | 14 +++--- .../src/Functional/SearchPageTextTest.php | 4 +- .../src/Functional/ShortcutLinksTest.php | 16 +++---- .../tests/src/Functional/ShortcutSetsTest.php | 4 +- .../src/Functional/Views/IntegrationTest.php | 2 +- .../Common/EarlyRenderingControllerTest.php | 32 ++++++------- .../src/Functional/Entity/EntityAddUITest.php | 6 +-- .../Entity/EntityViewControllerTest.php | 2 +- .../Entity/EntityWithUriCacheTagsTestBase.php | 2 +- .../src/Functional/Form/RedirectTest.php | 8 ++-- .../src/Functional/Form/ResponseTest.php | 4 +- .../Form/StateValuesCleanAdvancedTest.php | 2 +- .../src/Functional/Menu/MenuAccessTest.php | 8 ++-- .../src/Functional/Menu/MenuRouterTest.php | 4 +- .../src/Functional/Module/ClassLoaderTest.php | 6 +-- .../Module/InstallUninstallTest.php | 2 +- .../Module/PrepareUninstallTest.php | 2 +- .../Render/HtmlResponseAttachmentsTest.php | 6 +-- .../Functional/Routing/DestinationTest.php | 2 +- .../Routing/RouterPermissionTest.php | 6 +-- .../src/Functional/Routing/RouterTest.php | 24 +++++----- .../Session/SessionAuthenticationTest.php | 14 +++--- .../Functional/Session/SessionHttpsTest.php | 14 +++--- .../src/Functional/Session/SessionTest.php | 16 +++---- .../Functional/System/AccessDeniedTest.php | 8 ++-- .../tests/src/Functional/System/AdminTest.php | 4 +- .../src/Functional/System/CronRunTest.php | 10 ++-- .../System/DateFormatsLockedTest.php | 8 ++-- .../src/Functional/System/DateTimeTest.php | 2 +- .../Functional/System/ErrorHandlerTest.php | 8 ++-- .../src/Functional/System/HtaccessTest.php | 8 ++-- .../src/Functional/System/IndexPhpTest.php | 4 +- .../Functional/System/PageNotFoundTest.php | 4 +- .../System/ResponseGeneratorTest.php | 6 +-- .../Functional/System/SiteMaintenanceTest.php | 2 +- .../src/Functional/System/StatusTest.php | 4 +- .../tests/src/Functional/System/ThemeTest.php | 10 ++-- .../Functional/System/TrustedHostsTest.php | 4 +- .../Theme/EntityFilteringThemeTest.php | 2 +- .../src/Functional/Theme/TwigSettingsTest.php | 4 +- .../UpdatePathTestBaseFilledTest.php | 10 ++-- .../UpdatePathWithBrokenRoutingTest.php | 4 +- .../UpdateSystem/UpdateScriptTest.php | 24 +++++----- .../taxonomy/tests/src/Functional/RssTest.php | 2 +- .../src/Functional/TaxonomyImageTest.php | 4 +- .../tests/src/Functional/TermTest.php | 4 +- .../src/Functional/TermTranslationUITest.php | 4 +- .../Functional/Views/TaxonomyTermViewTest.php | 4 +- .../src/Functional/VocabularyLanguageTest.php | 2 +- .../Functional/VocabularyPermissionsTest.php | 20 ++++---- .../tests/src/Functional/TextFieldTest.php | 4 +- .../src/Functional/ToolbarAdminMenuTest.php | 18 +++---- .../src/Functional/ToolbarHookToolbarTest.php | 2 +- .../tests/src/Functional/UpdateCoreTest.php | 2 +- .../tests/src/Functional/UpdateUploadTest.php | 2 +- .../tests/src/Functional/AccessRoleUITest.php | 2 +- .../src/Functional/UserAdminListingTest.php | 4 +- .../tests/src/Functional/UserCancelTest.php | 2 +- .../src/Functional/UserPasswordResetTest.php | 12 ++--- .../src/Functional/UserRegistrationTest.php | 6 +-- .../src/Functional/UserRoleAdminTest.php | 4 +- .../tests/src/Functional/UserSearchTest.php | 4 +- .../src/Functional/Views/AccessRoleTest.php | 10 ++-- .../Functional/Views/BulkFormAccessTest.php | 8 ++-- .../tests/src/Functional/DefaultViewsTest.php | 2 +- .../Entity/ViewNonTranslatableEntityTest.php | 2 +- .../tests/src/Functional/GlossaryTest.php | 2 +- .../Handler/AreaHTTPStatusCodeTest.php | 4 +- .../src/Functional/Handler/FieldWebTest.php | 2 +- .../src/Functional/Plugin/AccessTest.php | 4 +- .../src/Functional/Plugin/CacheWebTest.php | 4 +- .../Functional/Plugin/DisabledDisplayTest.php | 6 +-- .../src/Functional/Plugin/DisplayFeedTest.php | 6 +-- .../Plugin/DisplayFeedTranslationTest.php | 2 +- .../Functional/Plugin/DisplayPageWebTest.php | 24 +++++----- .../src/Functional/Plugin/DisplayTest.php | 10 ++-- .../src/Functional/Plugin/ExposedFormTest.php | 14 +++--- .../src/Functional/Plugin/FilterTest.php | 4 +- .../tests/src/Functional/Wizard/BasicTest.php | 8 ++-- .../Functional/Wizard/ItemsPerPageTest.php | 2 +- .../tests/src/Functional/Wizard/MenuTest.php | 2 +- .../src/Functional/Wizard/SortingTest.php | 4 +- .../src/Functional/Wizard/TaggedWithTest.php | 6 +-- .../tests/src/Functional/DefaultViewsTest.php | 14 +++--- .../tests/src/Functional/DisplayCRUDTest.php | 2 +- .../tests/src/Functional/DisplayPathTest.php | 8 ++-- .../src/Functional/ExposedFormUITest.php | 4 +- .../src/Functional/OverrideDisplaysTest.php | 16 +++---- .../tests/src/Functional/PreviewTest.php | 8 ++-- .../tests/src/Functional/ReportTest.php | 2 +- .../tests/src/Functional/RowUITest.php | 2 +- .../src/Functional/UnsavedPreviewTest.php | 16 +++---- .../tests/src/Functional/ViewEditTest.php | 8 ++-- .../tests/src/Functional/ViewsListTest.php | 2 +- .../tests/src/Functional/MinimalTest.php | 2 +- .../tests/src/Functional/StandardTest.php | 4 +- .../Image/ToolkitSetupFormTest.php | 2 +- ...istributionProfileExistingSettingsTest.php | 2 +- .../Installer/DistributionProfileTest.php | 2 +- ...istributionProfileTranslationQueryTest.php | 2 +- .../DistributionProfileTranslationTest.php | 2 +- ...allerConfigDirectorySetNoDirectoryTest.php | 2 +- .../Installer/InstallerEmptySettingsTest.php | 2 +- .../InstallerExistingConfigDirectoryTest.php | 2 +- .../InstallerExistingDatabaseSettingsTest.php | 2 +- ...InstallerExistingSettingsNoProfileTest.php | 2 +- .../InstallerExistingSettingsTest.php | 2 +- .../InstallerLanguageDirectionTest.php | 2 +- .../Installer/InstallerLanguagePageTest.php | 2 +- .../InstallerNonDefaultDatabaseDriverTest.php | 2 +- .../Installer/InstallerTest.php | 2 +- .../InstallerTranslationQueryTest.php | 2 +- .../Installer/InstallerTranslationTest.php | 4 +- .../MultipleDistributionsProfileTest.php | 2 +- .../Installer/SingleVisibleProfileTest.php | 2 +- 237 files changed, 863 insertions(+), 863 deletions(-) diff --git a/core/modules/action/tests/src/Functional/ConfigurationTest.php b/core/modules/action/tests/src/Functional/ConfigurationTest.php index c178ca68fe2..2a4a7452e2b 100644 --- a/core/modules/action/tests/src/Functional/ConfigurationTest.php +++ b/core/modules/action/tests/src/Functional/ConfigurationTest.php @@ -38,7 +38,7 @@ class ConfigurationTest extends BrowserTestBase { $edit = []; $edit['action'] = 'action_goto_action'; $this->drupalPostForm('admin/config/system/actions', $edit, t('Create')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make a POST request to the individual action configuration page. $edit = []; @@ -47,7 +47,7 @@ class ConfigurationTest extends BrowserTestBase { $edit['id'] = strtolower($action_label); $edit['url'] = 'admin'; $this->drupalPostForm('admin/config/system/actions/add/action_goto_action', $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $action_id = $edit['id']; @@ -63,7 +63,7 @@ class ConfigurationTest extends BrowserTestBase { $edit['label'] = $new_action_label; $edit['url'] = 'admin'; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure that the action updated properly. $this->assertText(t('The action has been successfully saved.'), "Make sure we get a confirmation that we've successfully updated the complex action."); @@ -77,15 +77,15 @@ class ConfigurationTest extends BrowserTestBase { // Make sure that deletions work properly. $this->drupalGet('admin/config/system/actions'); $this->clickLink(t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = []; $this->drupalPostForm(NULL, $edit, t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure that the action was actually deleted. $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'Make sure that we get a delete confirmation message.'); $this->drupalGet('admin/config/system/actions'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action."); $action = Action::load($action_id); diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php index ef0dffe7b0c..ed1ce4fd676 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); + $this->assertSession()->statusCodeEquals(200); $this->assertText($feed->label(), 'Page title'); $this->assertRaw($feed->getWebsiteUrl()); @@ -61,7 +61,7 @@ class AddFeedTest extends AggregatorTestBase { $this->checkForMetaRefresh(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertEscaped('Test feed title '); $this->assertNoRaw('Test feed title '); @@ -91,7 +91,7 @@ class AddFeedTest extends AggregatorTestBase { // Check feed source. $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($feed->label(), 'Page title'); // Delete feeds. diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php index 19f03e726fd..aa9b297342b 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php @@ -60,7 +60,7 @@ class AggregatorAdminTest extends AggregatorTestBase { $this->container->get('module_installer')->uninstall(['aggregator_test']); $this->resetAll(); $this->drupalGet('admin/config/services/aggregator/settings'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php index b5010b8e0c8..fd6c673254f 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php @@ -127,12 +127,12 @@ class AggregatorRenderingTest extends AggregatorTestBase { // Check the rss aggregator page as anonymous user. $this->drupalLogout(); $this->drupalGet('aggregator/rss'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Check the rss aggregator page as admin. $this->drupalLogin($this->adminUser); $this->drupalGet('aggregator/rss'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertEqual($this->drupalGetHeader('Content-type'), 'application/rss+xml; charset=utf-8'); // Check the opml aggregator page. diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php index 09c05073c03..54b57137ad9 100644 --- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php +++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php @@ -181,11 +181,11 @@ 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); + $this->assertSession()->statusCodeEquals(200); // Attempt to access the update link directly without an access token. $this->drupalGet('admin/config/services/aggregator/update/' . $feed->id()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Refresh the feed (simulated link click). $this->drupalGet('admin/config/services/aggregator'); diff --git a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php index 192ef47133e..e31fe47cf6e 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); + $this->assertSession()->statusCodeEquals(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 e83128c05cd..f02a2271562 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); + $this->assertSession()->statusCodeEquals(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 63c7ac17062..95be9e5171f 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php @@ -37,7 +37,7 @@ class FeedParserTest extends AggregatorTestBase { $feed = $this->createFeed($this->getRSS091Sample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('First example feed item title'); $this->assertLinkByHref('http://example.com/example-turns-one'); $this->assertText('First example feed item description.'); @@ -60,7 +60,7 @@ class FeedParserTest extends AggregatorTestBase { $feed = $this->createFeed($this->getAtomSample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Atom-Powered Robots Run Amok'); $this->assertLinkByHref('http://example.org/2003/12/13/atom03'); $this->assertText('Some text.'); @@ -84,7 +84,7 @@ class FeedParserTest extends AggregatorTestBase { $feed = $this->createFeed($this->getHtmlEntitiesSample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw("Quote" Amp&"); } diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php index 7aef9ac0f99..fdbcc04eabd 100644 --- a/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php +++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php @@ -41,7 +41,7 @@ class UpdateFeedItemTest extends AggregatorTestBase { ]; $this->drupalGet($edit['url[0][value]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm('aggregator/sources/add', $edit, t('Save')); $this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), new FormattableMarkup('The feed @name has been added.', ['@name' => $edit['title[0][value]']])); @@ -75,7 +75,7 @@ class UpdateFeedItemTest extends AggregatorTestBase { $this->enableTestPlugins(); $this->container->get('module_installer')->uninstall(['aggregator_test']); $this->updateFeedItems($feed); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php index 8f17ceb0a6d..798bc557812 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); + $this->assertSession()->statusCodeEquals(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 47282b52616..96b52757ea7 100644 --- a/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php +++ b/core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php @@ -50,7 +50,7 @@ class BasicAuthTest extends BrowserTestBase { // 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); + $this->assertSession()->statusCodeEquals(200); $this->mink->resetSessions(); $this->assertNull($this->drupalGetHeader('X-Drupal-Cache')); // Check that Cache-Control is not set to public. @@ -59,25 +59,25 @@ class BasicAuthTest extends BrowserTestBase { // 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(401); // Ensure that a route without basic auth defined doesn't prompt for auth. $this->drupalGet('admin'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); $this->mink->resetSessions(); // Ensure that pages already in the page cache aren't returned from page @@ -113,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); + $this->assertSession()->statusCodeEquals(403); } /** @@ -137,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); + $this->assertSession()->statusCodeEquals(200); // Try 2 failed logins for a user. They will trigger flood control. for ($i = 0; $i < 2; $i++) { @@ -146,12 +146,12 @@ class BasicAuthTest extends BrowserTestBase { // Now the user account is blocked. $this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); } /** @@ -166,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); + $this->assertSession()->statusCodeEquals(200); } /** @@ -178,24 +178,24 @@ class BasicAuthTest extends BrowserTestBase { // Case when no credentials are passed. $this->drupalGet($url); - $this->assertResponse(401); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); $this->assertText('Access denied', "A user friendly access denied message is displayed"); } @@ -247,19 +247,19 @@ class BasicAuthTest extends BrowserTestBase { */ public function testControllerNotCalledBeforeAuth() { $this->drupalGet('/basic_auth_test/state/modify'); - $this->assertResponse(401); + $this->assertSession()->statusCodeEquals(401); $this->drupalGet('/basic_auth_test/state/read'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('nope'); $account = $this->drupalCreateUser(); $this->basicAuthGet('/basic_auth_test/state/modify', $account->getAccountName(), $account->pass_raw); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Done'); $this->mink->resetSessions(); $this->drupalGet('/basic_auth_test/state/read'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('yep'); } diff --git a/core/modules/block/tests/src/Functional/BlockAdminThemeTest.php b/core/modules/block/tests/src/Functional/BlockAdminThemeTest.php index fe248420cb2..e0952e072be 100644 --- a/core/modules/block/tests/src/Functional/BlockAdminThemeTest.php +++ b/core/modules/block/tests/src/Functional/BlockAdminThemeTest.php @@ -34,14 +34,14 @@ class BlockAdminThemeTest extends BrowserTestBase { // Ensure that access to block admin page is denied when theme is not // installed. $this->drupalGet('admin/structure/block/list/bartik'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Install admin theme and confirm that tab is accessible. \Drupal::service('theme_installer')->install(['bartik']); $edit['admin_theme'] = 'bartik'; $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); $this->drupalGet('admin/structure/block/list/bartik'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/block/tests/src/Functional/BlockCacheTest.php b/core/modules/block/tests/src/Functional/BlockCacheTest.php index cca0be87c77..7bc2e7ff658 100644 --- a/core/modules/block/tests/src/Functional/BlockCacheTest.php +++ b/core/modules/block/tests/src/Functional/BlockCacheTest.php @@ -210,10 +210,10 @@ class BlockCacheTest extends BrowserTestBase { \Drupal::state()->set('block_test.content', $current_content); $this->drupalGet('user'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText($old_content, 'Block content cached for the test page does not show up for the user page.'); $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($old_content, 'Block content cached for the test page.'); } diff --git a/core/modules/block/tests/src/Functional/BlockDemoTest.php b/core/modules/block/tests/src/Functional/BlockDemoTest.php index 818280aa5b9..e8fc4600e71 100644 --- a/core/modules/block/tests/src/Functional/BlockDemoTest.php +++ b/core/modules/block/tests/src/Functional/BlockDemoTest.php @@ -35,7 +35,7 @@ class BlockDemoTest extends BrowserTestBase { $config = $this->container->get('config.factory')->get('system.theme'); $default_theme = $config->get('default'); $this->drupalGet('admin/structure/block/demo/' . $default_theme); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('admin/structure/block'); $this->assertNoLinkByHref('admin/structure/block/list/' . $default_theme); @@ -55,14 +55,14 @@ class BlockDemoTest extends BrowserTestBase { $this->container->get('theme_installer')->install([$theme]); // Confirm access to the block demo page for the theme. $this->drupalGet('admin/structure/block/demo/' . $theme); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm existence of link for "Exit block region demonstration". $this->assertLinkByHref('admin/structure/block/list/' . $theme); } // Confirm access to the block demo page is denied for an invalid theme. $this->drupalGet('admin/structure/block/demo/invalid_theme'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php b/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php index a536500fa77..2b88abbc352 100644 --- a/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php +++ b/core/modules/block/tests/src/Functional/BlockFormInBlockTest.php @@ -42,7 +42,7 @@ class BlockFormInBlockTest extends BrowserTestBase { // Go to "test-page" and test if the block is enabled. $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Your .com email address.', 'form found'); // Make sure that we're currently still on /test-page after submitting the @@ -53,7 +53,7 @@ class BlockFormInBlockTest extends BrowserTestBase { // Go to a different page and see if the block is enabled there as well. $this->drupalGet('test-render-title'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Your .com email address.', 'form found'); // Make sure that submitting the form didn't redirect us to the first page diff --git a/core/modules/block/tests/src/Functional/BlockUiTest.php b/core/modules/block/tests/src/Functional/BlockUiTest.php index 185e1c198e7..86489ada218 100644 --- a/core/modules/block/tests/src/Functional/BlockUiTest.php +++ b/core/modules/block/tests/src/Functional/BlockUiTest.php @@ -102,7 +102,7 @@ class BlockUiTest extends BrowserTestBase { // 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); + $this->assertSession()->statusCodeEquals(404); } /** @@ -163,7 +163,7 @@ class BlockUiTest extends BrowserTestBase { // Ensure that a hidden theme cannot use the block demo page. $this->drupalGet('admin/structure/block/list/stable'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Ensure that a hidden theme set as the admin theme can use the block demo // page. @@ -173,7 +173,7 @@ class BlockUiTest extends BrowserTestBase { $this->drupalGet('admin/structure/block'); $this->assertLink($theme_handler->getName('stable')); $this->drupalGet('admin/structure/block/list/stable'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -382,9 +382,9 @@ class BlockUiTest extends BrowserTestBase { $block = reset($this->blocks); // Ensure that the enable and disable routes are protected. $this->drupalGet('admin/structure/block/manage/' . $block->id() . '/disable'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('admin/structure/block/manage/' . $block->id() . '/enable'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php index c6af3eacf66..a4c27db7e62 100644 --- a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php +++ b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php @@ -386,7 +386,7 @@ class DisplayBlockTest extends ViewTestBase { $post = ['ids[0]' => $id, 'ids[1]' => $cached_id, 'tokens[0]' => $id_token, 'tokens[1]' => $cached_id_token]; $url = 'contextual/render?_format=json,destination=test-page'; $this->getSession()->getDriver()->getClient()->request('POST', $url, $post); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $json = Json::decode($this->getSession()->getPage()->getContent()); $this->assertIdentical($json[$id], ''); $this->assertIdentical($json[$cached_id], ''); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php index 24f6b5b4f53..8841bff67f4 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php @@ -82,7 +82,7 @@ class BlockContentCreationTest extends BlockContentTestBase { $this->assertRaw(new FormattableMarkup('A custom block with block description %value already exists.', [ '%value' => $edit['info[0][value]'], ])); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -164,7 +164,7 @@ class BlockContentCreationTest extends BlockContentTestBase { $this->assertRaw(new FormattableMarkup('A custom block with block description %value already exists.', [ '%value' => $edit['info[0][value]'], ])); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/block_content/tests/src/Functional/BlockContentListTest.php b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php index e50ee168f46..eaaf8e0b4e0 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentListTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php @@ -57,7 +57,7 @@ class BlockContentListTest extends BlockContentTestBase { $link_text = t('Add custom block'); $this->assertLink($link_text); $this->clickLink($link_text); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = []; $edit['info[0][value]'] = $label; $edit['body[0][value]'] = $this->randomMachineName(16); @@ -84,7 +84,7 @@ class BlockContentListTest extends BlockContentTestBase { if (!empty($block)) { $this->assertLinkByHref('block/' . $block->id()); $this->clickLink(t('Edit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle(strip_tags(t('Edit custom block %label', ['%label' => $label]) . ' | Drupal')); $edit = ['info[0][value]' => $new_label]; $this->drupalPostForm(NULL, $edit, t('Save')); @@ -101,7 +101,7 @@ class BlockContentListTest extends BlockContentTestBase { $this->assertLinkByHref('block/' . $block->id() . '/delete'); $delete_text = t('Delete'); $this->clickLink($delete_text); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', ['%label' => $new_label]) . ' | Drupal')); $this->drupalPostForm(NULL, [], $delete_text); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php b/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php index 381bd447005..a3af1703a1a 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php @@ -69,7 +69,7 @@ class BlockContentListViewsTest extends BlockContentTestBase { $link_text = t('Add custom block'); $this->assertLink($link_text); $this->clickLink($link_text); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = []; $edit['info[0][value]'] = $label; $edit['body[0][value]'] = $this->randomMachineName(16); @@ -96,7 +96,7 @@ class BlockContentListViewsTest extends BlockContentTestBase { if (!empty($block)) { $this->assertLinkByHref('block/' . $block->id()); $this->clickLink(t('Edit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle(strip_tags(t('Edit custom block %label', ['%label' => $label]) . ' | Drupal')); $edit = ['info[0][value]' => $new_label]; $this->drupalPostForm(NULL, $edit, t('Save')); @@ -113,7 +113,7 @@ class BlockContentListViewsTest extends BlockContentTestBase { $this->assertLinkByHref('block/' . $block->id() . '/delete'); $delete_text = t('Delete'); $this->clickLink($delete_text); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', ['%label' => $new_label]) . ' | Drupal')); $this->drupalPostForm(NULL, [], $delete_text); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php index b77fe3e01c8..b2111370b60 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php @@ -32,7 +32,7 @@ class BlockContentPageViewTest extends BlockContentTestBase { $this->drupalGet('block-content/' . $block->id()); // Ensure user was able to view the block. - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php index 735334f796a..7c04fce442a 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php @@ -60,7 +60,7 @@ class BlockContentTypeTest extends BlockContentTestBase { // Test the page with no block-types. $this->drupalGet('block/add'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('You have not created any block types yet'); $this->clickLink('block type creation page'); @@ -93,7 +93,7 @@ class BlockContentTypeTest extends BlockContentTestBase { $this->assertInstanceOf(BlockContentType::class, $block_type); $this->drupalGet('block/add/' . $block_type->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/block_content/tests/src/Functional/Views/BlockContentIntegrationTest.php b/core/modules/block_content/tests/src/Functional/Views/BlockContentIntegrationTest.php index 8f9e03d2571..6857ee84538 100644 --- a/core/modules/block_content/tests/src/Functional/Views/BlockContentIntegrationTest.php +++ b/core/modules/block_content/tests/src/Functional/Views/BlockContentIntegrationTest.php @@ -42,10 +42,10 @@ class BlockContentIntegrationTest extends BlockContentTestBase { } $this->drupalGet('test-block_content-view'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet('test-block_content-view/all'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertIds($all_ids); /* @var \Drupal\block_content\Entity\BlockContentType[] $types*/ foreach ($types as $type) { diff --git a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php index 47c90e0ab9a..d4e3439d5d5 100644 --- a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php +++ b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php @@ -203,7 +203,7 @@ class BookBreadcrumbTest extends BrowserTestBase { $this->assertCount(4, $got_breadcrumb); $this->assertEqual($nodes[2]->getTitle(), end($got_breadcrumb)); $this->drupalGet($nodes[3]->toUrl()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index f5e0248cc08..de199204010 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -214,11 +214,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); + $this->assertSession()->statusCodeEquals(404); // Make sure we get a 404 on a not existing book node. $this->drupalGet('book/export/html/123'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Make sure an anonymous user cannot view printer-friendly version. $this->drupalLogout(); @@ -229,14 +229,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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); } /** @@ -358,7 +358,7 @@ class BookTest extends BrowserTestBase { // Ensure that the top-level book node cannot be deleted. $this->drupalGet('node/' . $this->book->id() . '/outline/remove'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Ensure that a child book node can be deleted. $this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove')); @@ -386,7 +386,7 @@ class BookTest extends BrowserTestBase { // Delete parent, and visit a child page. $this->drupalPostForm($this->book->toUrl('delete-form'), [], t('Delete')); $this->drupalGet($nodes[0]->toUrl()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($nodes[0]->label()); // The book parents should be updated. $node_storage = \Drupal::entityTypeManager()->getStorage('node'); diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php index dbb69ae5a02..ac551ec1217 100644 --- a/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php +++ b/core/modules/ckeditor/tests/src/Functional/CKEditorAdminTest.php @@ -232,7 +232,7 @@ class CKEditorAdminTest extends BrowserTestBase { ]; $this->submitForm($edit, 'editor_configure'); $this->submitForm($edit, 'Save configuration'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('The machine-readable name is already in use. It must be unique.'); } diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php index 5221a6902de..05930c688a2 100644 --- a/core/modules/color/tests/src/Functional/ColorTest.php +++ b/core/modules/color/tests/src/Functional/ColorTest.php @@ -112,7 +112,7 @@ class ColorTest extends BrowserTestBase { $this->drupalLogin($this->bigUser); $this->drupalGet($settings_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertUniqueText('Color set'); $edit['scheme'] = ''; $edit[$test_values['palette_input']] = '#123456'; @@ -127,7 +127,7 @@ class ColorTest extends BrowserTestBase { } $this->drupalGet($settings_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit['scheme'] = $test_values['scheme']; $this->drupalPostForm($settings_path, $edit, t('Save configuration')); diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php index 08d65f9df4e..22c1fa748f8 100644 --- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php @@ -159,9 +159,9 @@ class CommentAdminTest extends CommentTestBase { // Ensure comments cannot be approved without a valid token. $this->drupalLogin($this->adminUser); $this->drupalGet('comment/1/approve'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('comment/1/approve', ['query' => ['token' => 'forged']]); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Approve comment. $this->drupalGet('comment/1/edit'); @@ -182,7 +182,7 @@ class CommentAdminTest extends CommentTestBase { $this->drupalLogin($this->adminUser); // Browse to comment bundle overview. $this->drupalGet('admin/structure/comment'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure titles visible. $this->assertText('Comment type'); $this->assertText('Description'); @@ -190,7 +190,7 @@ class CommentAdminTest extends CommentTestBase { $this->assertText('Default comment field'); // Manage fields. $this->clickLink('Manage fields'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure comment_body field is shown. $this->assertText('comment_body'); // Rest from here on in is field_ui. diff --git a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php index d8fcedc1be1..cc6c466252c 100644 --- a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php @@ -162,7 +162,7 @@ class CommentAnonymousTest extends CommentTestBase { // Comment 3 was deleted. $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $anonymous_comment3->id()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Reset. user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ @@ -180,7 +180,7 @@ class CommentAnonymousTest extends CommentTestBase { // Attempt to view node-comment form while disallowed. $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => TRUE, @@ -203,7 +203,7 @@ class CommentAnonymousTest extends CommentTestBase { $this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $anonymous_comment2->id()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php index ff86da88468..5f9ceffbcd5 100644 --- a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php +++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php @@ -174,20 +174,20 @@ class CommentInterfaceTest extends CommentTestBase { $reply_loaded->setUnpublished(); $reply_loaded->save(); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $reply_loaded->id()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Attempt to post to node with comments disabled. $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::HIDDEN]]]); $this->assertNotNull($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with read-only comments. $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::CLOSED]]]); $this->assertNotNull($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with comments enabled (check field names etc). diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php index 111796a685e..3932ffb9a4f 100644 --- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php @@ -275,11 +275,11 @@ class CommentNonNodeTest extends BrowserTestBase { $this->assertLinkByHref('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); // Test widget hidden option is not visible when there's no comments. $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoField('edit-default-value-input-comment-und-0-status-0'); // Test that field to change cardinality is not available. $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment/storage'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoField('cardinality_number'); $this->assertNoField('cardinality'); @@ -359,7 +359,7 @@ class CommentNonNodeTest extends BrowserTestBase { // Attempt to view test entity comment form while disallowed. $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.'); $this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field not found.'); @@ -391,7 +391,7 @@ class CommentNonNodeTest extends BrowserTestBase { $this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.'); $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment/' . $comment1->id()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertNoText($comment1->getSubject(), 'Comment not displayed.'); // Test comment field widget changes. diff --git a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php index 6a268267769..99772080377 100644 --- a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php +++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php @@ -206,7 +206,7 @@ class CommentTranslationUITest extends ContentTranslationUITestBase { // Verify translation links. $this->drupalGet('admin/content/comment'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('comment/' . $cid_translatable . '/translations'); $this->assertNoLinkByHref('comment/' . $cid_untranslatable . '/translations'); } diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php index 5d02fb8532b..d13b9c62960 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -66,7 +66,7 @@ class CommentTypeTest extends CommentTestBase { // Ensure that the new comment type admin page can be accessed. $this->drupalGet('admin/structure/comment/manage/' . $type->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Create a comment type via the user interface. $edit = [ diff --git a/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php b/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php index 6cb28c85be4..c3d5c6898fa 100644 --- a/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php +++ b/core/modules/comment/tests/src/Functional/Views/CommentOperationsTest.php @@ -28,7 +28,7 @@ class CommentOperationsTest extends CommentTestBase { $admin_account = $this->drupalCreateUser(['administer comments']); $this->drupalLogin($admin_account); $this->drupalGet('test-comment-operations'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $operation = $this->cssSelect('.views-field-operations li.edit a'); $this->assertCount(1, $operation, 'Found edit operation for comment.'); $operation = $this->cssSelect('.views-field-operations li.delete a'); diff --git a/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php b/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php index d8ba9d93fa0..d2de8bb43bf 100644 --- a/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php +++ b/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php @@ -62,7 +62,7 @@ class CommentRestExportTest extends CommentTestBase { */ public function testCommentRestExport() { $this->drupalGet(sprintf('node/%d/comments', $this->nodeUserCommented->id()), ['query' => ['_format' => 'hal_json']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $contents = Json::decode($this->getSession()->getPage()->getContent()); $this->assertEqual($contents[0]['subject'], 'How much wood would a woodchuck chuck'); $this->assertEqual($contents[1]['subject'], 'A lot, apparently'); diff --git a/core/modules/comment/tests/src/Functional/Views/NodeCommentsTest.php b/core/modules/comment/tests/src/Functional/Views/NodeCommentsTest.php index a6916720d4b..c20760371ba 100644 --- a/core/modules/comment/tests/src/Functional/Views/NodeCommentsTest.php +++ b/core/modules/comment/tests/src/Functional/Views/NodeCommentsTest.php @@ -33,7 +33,7 @@ class NodeCommentsTest extends CommentTestBase { */ public function testNewComments() { $this->drupalGet('test-new-comments'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $new_comments = $this->cssSelect(".views-field-new-comments a:contains('1')"); $this->assertCount(1, $new_comments, 'Found the number of new comments for a certain node.'); } diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php index dd11022efec..1835e1d8974 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php @@ -192,7 +192,7 @@ class ConfigEntityListTest extends BrowserTestBase { // Add a new entity using the operations link. $this->assertLink('Add test configuration'); $this->clickLink('Add test configuration'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = [ 'label' => 'Antelope', 'id' => 'antelope', @@ -212,7 +212,7 @@ class ConfigEntityListTest extends BrowserTestBase { // Edit the entity using the operations link. $this->assertLinkByHref('admin/structure/config_test/manage/antelope'); $this->clickLink('Edit', 1); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle('Edit Antelope | Drupal'); $edit = ['label' => 'Albatross', 'id' => 'albatross']; $this->drupalPostForm(NULL, $edit, t('Save')); @@ -226,7 +226,7 @@ class ConfigEntityListTest extends BrowserTestBase { // Delete the added entity using the operations link. $this->assertLinkByHref('admin/structure/config_test/manage/albatross/delete'); $this->clickLink('Delete', 1); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle('Are you sure you want to delete the test configuration Albatross? | Drupal'); $this->drupalPostForm(NULL, [], t('Delete')); @@ -237,7 +237,7 @@ class ConfigEntityListTest extends BrowserTestBase { // Delete the original entity using the operations link. $this->clickLink('Delete'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle('Are you sure you want to delete the test configuration Default? | Drupal'); $this->drupalPostForm(NULL, [], t('Delete')); diff --git a/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php b/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php index f43e7a009a0..124705de19c 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php @@ -42,14 +42,14 @@ class ConfigEntityStatusUITest extends BrowserTestBase { $disable_url = $entity->toUrl('disable'); $this->assertLinkByHref($disable_url->toString()); $this->drupalGet($disable_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoLinkByHref($disable_url->toString()); // Enable an entity. $enable_url = $entity->toUrl('enable'); $this->assertLinkByHref($enable_url->toString()); $this->drupalGet($enable_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoLinkByHref($enable_url->toString()); } diff --git a/core/modules/config/tests/src/Functional/ConfigEntityTest.php b/core/modules/config/tests/src/Functional/ConfigEntityTest.php index 60506b4d28f..30dd0cf231a 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityTest.php @@ -253,7 +253,7 @@ class ConfigEntityTest extends BrowserTestBase { ]; $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $this->assertUrl('admin/structure/config_test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw($message_insert); $this->assertNoRaw($message_update); $this->assertLinkByHref("admin/structure/config_test/manage/$id"); @@ -264,7 +264,7 @@ class ConfigEntityTest extends BrowserTestBase { ]; $this->drupalPostForm("admin/structure/config_test/manage/$id", $edit, 'Save'); $this->assertUrl('admin/structure/config_test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoRaw($message_insert); $this->assertRaw($message_update); $this->assertLinkByHref("admin/structure/config_test/manage/$id"); @@ -276,7 +276,7 @@ class ConfigEntityTest extends BrowserTestBase { $this->assertUrl("admin/structure/config_test/manage/$id/delete"); $this->drupalPostForm(NULL, [], 'Delete'); $this->assertUrl('admin/structure/config_test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoRaw($message_update); $this->assertRaw($message_delete); $this->assertNoText($label1); @@ -289,7 +289,7 @@ class ConfigEntityTest extends BrowserTestBase { ]; $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $this->assertUrl('admin/structure/config_test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($label1); $this->assertLinkByHref("admin/structure/config_test/manage/$id"); @@ -300,7 +300,7 @@ class ConfigEntityTest extends BrowserTestBase { ]; $this->drupalPostForm("admin/structure/config_test/manage/$id", $edit, 'Save'); $this->assertUrl('admin/structure/config_test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText($label1); $this->assertNoText($label2); $this->assertText($label3); @@ -314,7 +314,7 @@ class ConfigEntityTest extends BrowserTestBase { 'label' => '0', ]; $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $message_insert = new FormattableMarkup('%label configuration has been created.', ['%label' => $edit['label']]); $this->assertRaw($message_insert); $this->assertLinkByHref('admin/structure/config_test/manage/0'); diff --git a/core/modules/config/tests/src/Functional/ConfigExportUITest.php b/core/modules/config/tests/src/Functional/ConfigExportUITest.php index 5598cca7802..32c9eae6fd9 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); + $this->assertSession()->statusCodeEquals(200); // Test if header contains file name with hostname and timestamp. $request = \Drupal::request(); @@ -97,7 +97,7 @@ class ConfigExportUITest extends BrowserTestBase { // permission. $this->drupalLogout(); $this->drupalGet('system/temporary', ['query' => ['file' => 'config.tar.gz']]); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php b/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php index 2aea457a660..368fd053c15 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportUploadTest.php @@ -47,7 +47,7 @@ class ConfigImportUploadTest extends BrowserTestBase { public function testImport() { // Verify access to the config upload form. $this->drupalGet('admin/config/development/configuration/full/import'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Attempt to upload a non-tar file. $text_file = $this->getTestFiles('text')[0]; diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php index 0e3fddd31d8..a4d174a8c79 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationInstallTest.php @@ -69,7 +69,7 @@ ENDPO; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalGet('/admin/structure/types/manage/article/fields'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php index 8fd7a9587b1..85ee670e561 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php @@ -294,7 +294,7 @@ class ConfigTranslationUiTest extends BrowserTestBase { $this->drupalLogout(); $this->drupalLogin($this->translatorUser); $this->drupalGet('admin/config/system/site-information'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // While translator can access the translation page, the edit link is not // present due to lack of permissions. @@ -430,7 +430,7 @@ class ConfigTranslationUiTest extends BrowserTestBase { $this->drupalLogout(); $this->drupalLogin($this->translatorUser); $this->drupalGet('admin/structure/contact/manage/feedback'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // While translator can access the translation page, the edit link is not // present due to lack of permissions. @@ -552,7 +552,7 @@ class ConfigTranslationUiTest extends BrowserTestBase { // Loading translation page for not-specified language (und) // should return 403. $this->drupalGet('admin/config/system/site-information/translate/und/add'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Check the source language doesn't have 'Add' or 'Delete' link and // make sure source language edit goes to original configuration page @@ -565,15 +565,15 @@ class ConfigTranslationUiTest extends BrowserTestBase { // Translation addition to source language should return 403. $this->drupalGet('admin/config/system/site-information/translate/en/add'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Translation editing in source language should return 403. $this->drupalGet('admin/config/system/site-information/translate/en/edit'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Translation deletion in source language should return 403. $this->drupalGet('admin/config/system/site-information/translate/en/delete'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Set default language of site information to not-specified language (und). $this->config('system.site') @@ -586,7 +586,7 @@ class ConfigTranslationUiTest extends BrowserTestBase { // If source language is not specified, translation page should be 403. $this->drupalGet('admin/config/system/site-information/translate'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** @@ -877,7 +877,7 @@ class ConfigTranslationUiTest extends BrowserTestBase { // Visit account setting translation page, this should not // throw any notices. $this->drupalGet('admin/config/people/accounts/translate'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php index faa0c0f2500..f338ca8e25e 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php @@ -77,7 +77,7 @@ class ConfigTranslationUiThemeTest extends BrowserTestBase { $translation_base_url = 'admin/config/development/performance/translate'; $this->drupalGet($translation_base_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref("$translation_base_url/fr/add"); } diff --git a/core/modules/contact/tests/src/Functional/ContactLanguageTest.php b/core/modules/contact/tests/src/Functional/ContactLanguageTest.php index a2d71616167..fcc27c9fad1 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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 3e956722cb4..d74dec93769 100644 --- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php +++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php @@ -117,7 +117,7 @@ class ContactPersonalTest extends BrowserTestBase { // Test allowed access to admin user's contact form. $this->drupalLogin($this->webUser); $this->drupalGet('user/' . $this->adminUser->id() . '/contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check the page title is properly displayed. $this->assertRaw(t('Contact @username', ['@username' => $this->adminUser->getDisplayName()])); @@ -125,25 +125,25 @@ class ContactPersonalTest extends BrowserTestBase { $this->drupalLogout(); $this->drupalLogin($this->adminUser); $this->drupalGet('user/' . $this->adminUser->id() . '/contact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Test allowed access to user with contact form enabled. $this->drupalLogin($this->webUser); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test that there is no access to personal contact forms for users // without an email address configured. $original_email = $this->contactUser->getEmail(); $this->contactUser->setEmail(FALSE)->save(); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Test that the 'contact tab' does not appear on the user profiles // for users without an email address configured. $this->drupalGet('user/' . $this->contactUser->id()); $contact_link = '/user/' . $this->contactUser->id() . '/contact'; - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoLinkByHref($contact_link, 'The "contact" tab is hidden on profiles for users with no email address'); // Restore original email address. @@ -151,30 +151,30 @@ class ContactPersonalTest extends BrowserTestBase { // Test denied access to the user's own contact form. $this->drupalGet('user/' . $this->webUser->id() . '/contact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Test always denied access to the anonymous user contact form. $this->drupalGet('user/0/contact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Test that anonymous users can access the contact form. $this->drupalLogout(); user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access user contact forms']); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test that anonymous users can access admin user's contact form. $this->drupalGet('user/' . $this->adminUser->id() . '/contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertCacheContext('user'); // Revoke the personal contact permission for the anonymous user. user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access user contact forms']); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertCacheContext('user'); $this->drupalGet('user/' . $this->adminUser->id() . '/contact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Disable the personal contact form. $this->drupalLogin($this->adminUser); @@ -190,12 +190,12 @@ class ContactPersonalTest extends BrowserTestBase { // Test denied access to a user with contact form disabled. $this->drupalLogin($this->webUser); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Test allowed access for admin user to a user with contact form disabled. $this->drupalLogin($this->adminUser); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Re-create our contacted user as a blocked user. $this->contactUser = $this->drupalCreateUser(); @@ -204,12 +204,12 @@ class ContactPersonalTest extends BrowserTestBase { // Test that blocked users can still be contacted by admin. $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test that blocked users cannot be contacted by non-admins. $this->drupalLogin($this->webUser); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Test enabling and disabling the contact page through the user profile // form. @@ -227,7 +227,7 @@ class ContactPersonalTest extends BrowserTestBase { \Drupal::service('user.data')->set('contact', $this->contactUser->id(), 'enabled', 1); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -301,7 +301,7 @@ class ContactPersonalTest extends BrowserTestBase { $this->drupalLogout(); $this->drupalGet('user/' . $user->id() . '/contact'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); } /** diff --git a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php index 97f8254e97a..3fb719e0626 100644 --- a/core/modules/contact/tests/src/Functional/ContactSitewideTest.php +++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php @@ -123,7 +123,7 @@ class ContactSitewideTest extends BrowserTestBase { $this->assertNoLinkByHref('admin/structure/contact/manage/personal/delete'); $this->drupalGet('admin/structure/contact/manage/personal'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Delete old forms to ensure that new forms are used. $this->deleteContactForms(); @@ -135,15 +135,15 @@ class ContactSitewideTest extends BrowserTestBase { user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalLogout(); $this->drupalGet('contact'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalLogin($admin_user); $this->drupalGet('contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('The contact form has not been configured.')); // Test access personal form via site-wide contact page. $this->drupalGet('contact/personal'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Add forms. // Test invalid recipients. @@ -232,12 +232,12 @@ class ContactSitewideTest extends BrowserTestBase { // Check to see that anonymous user cannot see contact page without permission. user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalGet('contact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Give anonymous user permission and see that page is viewable. user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalGet('contact'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Submit contact form with invalid values. $this->submitContact('', $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64)); @@ -260,13 +260,13 @@ class ContactSitewideTest extends BrowserTestBase { ->set('default_form', '') ->save(); $this->drupalGet('contact'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Try to access contact form with non-existing form IDs. $this->drupalGet('contact/0'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet('contact/' . $this->randomMachineName()); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Submit contact form with correct values and check flood interval. for ($i = 0; $i < $flood_limit; $i++) { @@ -288,7 +288,7 @@ class ContactSitewideTest extends BrowserTestBase { $this->addContactForm($contact_form, $label, $recipients, '', FALSE); $this->drupalGet('admin/structure/contact'); $this->clickLink(t('Edit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertFieldByName('label', $label); // Test field UI and field integration. @@ -309,9 +309,9 @@ class ContactSitewideTest extends BrowserTestBase { } } - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->clickLink(t('Add field')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Create a simple textfield. $field_name = mb_strtolower($this->randomMachineName()); @@ -576,7 +576,7 @@ class ContactSitewideTest extends BrowserTestBase { if ($id == 'personal') { // Personal form could not be deleted. $this->drupalGet("admin/structure/contact/manage/$id/delete"); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } else { $this->drupalPostForm("admin/structure/contact/manage/$id/delete", [], t('Delete')); diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php index 4346ea6d886..2fa1b5aa8bf 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationFormTest.php @@ -78,13 +78,13 @@ class ModerationFormTest extends ModerationStateTestBase { // The canonical view should have a moderation form, because it is not the // live revision. $this->drupalGet($canonical_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertField('edit-new-state', 'The node view page has a moderation form.'); // The latest version page should not show, because there is no pending // revision. $this->drupalGet($latest_version_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Update the draft. $this->drupalPostForm($edit_path, [ @@ -95,7 +95,7 @@ class ModerationFormTest extends ModerationStateTestBase { // The canonical view should have a moderation form, because it is not the // live revision. $this->drupalGet($canonical_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertField('edit-new-state', 'The node view page has a moderation form.'); // Preview the draft. @@ -109,14 +109,14 @@ class ModerationFormTest extends ModerationStateTestBase { 'node_preview' => $node->uuid(), 'view_mode_id' => 'full', ]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertUrl($preview_url); $this->assertNoField('edit-new-state', 'The node preview page has no moderation form.'); // The latest version page should not show, because there is still no // pending revision. $this->drupalGet($latest_version_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Publish the draft. $this->drupalPostForm($edit_path, [ @@ -140,13 +140,13 @@ class ModerationFormTest extends ModerationStateTestBase { // The published view should not have a moderation form, because it is the // live revision. $this->drupalGet($canonical_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoField('edit-new-state', 'The node view page has no moderation form.'); // The latest version page should not show, because there is still no // pending revision. $this->drupalGet($latest_version_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Make a pending revision. $this->drupalPostForm($edit_path, [ @@ -157,13 +157,13 @@ class ModerationFormTest extends ModerationStateTestBase { // The published view should not have a moderation form, because it is the // live revision. $this->drupalGet($canonical_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoField('edit-new-state', 'The node view page has no moderation form.'); // The latest version page should show the moderation form and have "Draft" // status, because the pending revision is in "Draft". $this->drupalGet($latest_version_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertField('edit-new-state', 'The latest-version page has a moderation form.'); $this->assertText('Draft', 'Correct status found on the latest-version page.'); @@ -175,7 +175,7 @@ class ModerationFormTest extends ModerationStateTestBase { // The latest version page should not show, because there is no // pending revision. $this->drupalGet($latest_version_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** @@ -192,7 +192,7 @@ class ModerationFormTest extends ModerationStateTestBase { // The latest version page should not show, because there is no pending // revision. $this->drupalGet('/entity_test_mulrevpub/manage/1/latest'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Update the draft. $this->drupalPostForm('entity_test_mulrevpub/manage/1/edit', ['moderation_state[0][state]' => 'draft'], t('Save')); @@ -200,7 +200,7 @@ class ModerationFormTest extends ModerationStateTestBase { // The latest version page should not show, because there is still no // pending revision. $this->drupalGet('/entity_test_mulrevpub/manage/1/latest'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Publish the draft. $this->drupalPostForm('entity_test_mulrevpub/manage/1/edit', ['moderation_state[0][state]' => 'published'], t('Save')); @@ -208,13 +208,13 @@ class ModerationFormTest extends ModerationStateTestBase { // The published view should not have a moderation form, because it is the // default revision. $this->drupalGet('entity_test_mulrevpub/manage/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText('Status', 'The node view page has no moderation form.'); // The latest version page should not show, because there is still no // pending revision. $this->drupalGet('entity_test_mulrevpub/manage/1/latest'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Make a pending revision. $this->drupalPostForm('entity_test_mulrevpub/manage/1/edit', ['moderation_state[0][state]' => 'draft'], t('Save')); @@ -222,13 +222,13 @@ class ModerationFormTest extends ModerationStateTestBase { // The published view should not have a moderation form, because it is the // default revision. $this->drupalGet('entity_test_mulrevpub/manage/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText('Status', 'The node view page has no moderation form.'); // The latest version page should show the moderation form and have "Draft" // status, because the pending revision is in "Draft". $this->drupalGet('entity_test_mulrevpub/manage/1/latest'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Moderation state', 'Form text found on the latest-version page.'); $this->assertText('Draft', 'Correct status found on the latest-version page.'); @@ -240,7 +240,7 @@ class ModerationFormTest extends ModerationStateTestBase { // The latest version page should not show, because there is no // pending revision. $this->drupalGet('entity_test_mulrevpub/manage/1/latest'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** diff --git a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php index 476642f0ad9..8999dae1229 100644 --- a/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php +++ b/core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php @@ -79,16 +79,16 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase { } $node = reset($nodes); $this->drupalGet('node/' . $node->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('node/' . $node->id() . '/edit'); $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSession()->optionExists('moderation_state[0][state]', 'draft'); $this->assertSession()->optionNotExists('moderation_state[0][state]', 'published'); $this->drupalLogin($editor_with_publish); $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSession()->optionExists('moderation_state[0][state]', 'draft'); $this->assertSession()->optionExists('moderation_state[0][state]', 'published'); } diff --git a/core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php b/core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php index cb2cb032304..6be4d3e00c1 100644 --- a/core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php +++ b/core/modules/content_moderation/tests/src/Functional/NodeAccessTest.php @@ -109,12 +109,12 @@ class NodeAccessTest extends ModerationStateTestBase { $this->drupalLogin($user); $this->drupalGet($edit_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet($latest_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet($view_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Publish the node. $this->drupalLogin($this->adminUser); @@ -126,12 +126,12 @@ class NodeAccessTest extends ModerationStateTestBase { $this->drupalLogout(); $this->drupalGet($edit_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet($latest_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet($view_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Create a pending revision for the 'Latest revision' tab. $this->drupalLogin($this->adminUser); @@ -143,12 +143,12 @@ class NodeAccessTest extends ModerationStateTestBase { $this->drupalLogin($user); $this->drupalGet($edit_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet($latest_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet($view_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Now make another user, who should not be able to see pending revisions. $user = $this->createUser([ @@ -157,12 +157,12 @@ class NodeAccessTest extends ModerationStateTestBase { $this->drupalLogin($user); $this->drupalGet($edit_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet($latest_path); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet($view_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Now create a private node that the user is not granted access to by the // node grants, but is granted access via hook_node_access(). @@ -181,7 +181,7 @@ class NodeAccessTest extends ModerationStateTestBase { \Drupal::state()->set('node_access_test.allow_uid', $user->id()); $this->drupalGet($node->toUrl()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify the moderation form is in place by publishing the node. $this->drupalPostForm(NULL, [], t('Apply')); diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php index 37bc9b8fa60..e1995ff97de 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php @@ -96,7 +96,7 @@ class ContentTranslationOperationsTest extends NodeTestBase { ); $this->drupalLogin($this->baseUser1); $this->drupalGet($node->toUrl('drupal:content-translation-overview')); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Ensure that the translation overview is also not accessible when the user // has 'access content', but the node is not published. @@ -109,7 +109,7 @@ class ContentTranslationOperationsTest extends NodeTestBase { ); $node->setUnpublished()->save(); $this->drupalGet($node->toUrl('drupal:content-translation-overview')); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalLogout(); // Ensure the 'Translate' local task does not show up anymore when disabling diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php index 89c7ad93b09..162c5d1f816 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); + $this->assertSession()->statusCodeEquals(200); // Ensure that the content language cache context is not yet added to the // page. @@ -377,7 +377,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase { // Check that the translator cannot delete the original translation. $args = [$this->entityTypeId => $entity->id(), 'language' => 'en']; $this->drupalGet(Url::fromRoute("entity.$this->entityTypeId.content_translation_delete", $args)); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php index c0f27d038ec..ae5e7303f65 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationWorkflowsTest.php @@ -169,19 +169,19 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { // 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']); + $this->assertSession()->statusCodeEquals($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']); + $this->assertSession()->statusCodeEquals($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']); + $this->assertSession()->statusCodeEquals($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); @@ -197,7 +197,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { else { $this->drupalGet($add_translation_url); } - $this->assertResponse($expected_status['add_translation']); + $this->assertSession()->statusCodeEquals($expected_status['add_translation']); // Check whether the user is allowed to edit a translation. $langcode = $this->langcodes[2]; @@ -225,7 +225,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { else { $this->drupalGet($edit_translation_url); } - $this->assertResponse($expected_status['edit_translation']); + $this->assertSession()->statusCodeEquals($expected_status['edit_translation']); // Check whether the user is allowed to delete a translation. $langcode = $this->langcodes[2]; @@ -253,7 +253,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { else { $this->drupalGet($delete_translation_url); } - $this->assertResponse($expected_status['delete_translation']); + $this->assertSession()->statusCodeEquals($expected_status['delete_translation']); } /** diff --git a/core/modules/datetime/tests/src/Functional/DateFilterTest.php b/core/modules/datetime/tests/src/Functional/DateFilterTest.php index 14053070a9b..acf11da3100 100644 --- a/core/modules/datetime/tests/src/Functional/DateFilterTest.php +++ b/core/modules/datetime/tests/src/Functional/DateFilterTest.php @@ -85,7 +85,7 @@ class DateFilterTest extends ViewTestBase { public function testLimitExposedOperators() { $this->drupalGet('test_exposed_filter_datetime'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertOption('edit-field-date-value-op', '='); $this->assertNoOption('edit-field-date-value-op', '>'); $this->assertNoOption('edit-field-date-value-op', '>='); @@ -103,7 +103,7 @@ class DateFilterTest extends ViewTestBase { $this->drupalPostForm('admin/structure/views/view/test_exposed_filter_datetime/edit/default', [], t('Save')); $this->drupalGet('test_exposed_filter_datetime'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoOption('edit-field-date-value-op', '<'); $this->assertNoOption('edit-field-date-value-op', '<='); $this->assertNoOption('edit-field-date-value-op', '='); diff --git a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php index 078e0196ae2..2c5ed0b3db0 100644 --- a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php +++ b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php @@ -567,7 +567,7 @@ class DateTimeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); foreach ($expected as $expected_text) { $this->assertText(t($expected_text)); } @@ -583,7 +583,7 @@ class DateTimeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -598,7 +598,7 @@ class DateTimeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertOptionSelected("edit-$field_name-0-value-minute", '0', 'Correct minute selected.'); } diff --git a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php index 08bae76b4eb..10e48dbdbd8 100644 --- a/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php +++ b/core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php @@ -869,7 +869,7 @@ class DateRangeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); foreach ($expected as $expected_text) { $this->assertText(t($expected_text)); } @@ -889,7 +889,7 @@ class DateRangeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); $id = $match[1]; $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); @@ -908,7 +908,7 @@ class DateRangeFieldTest extends DateTestBase { } $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertOptionSelected("edit-$field_name-0-value-minute", '0', 'Correct minute selected.'); $this->assertOptionSelected("edit-$field_name-0-end-value-minute", '0', 'Correct minute selected.'); } diff --git a/core/modules/dblog/tests/src/Functional/DbLogTest.php b/core/modules/dblog/tests/src/Functional/DbLogTest.php index 56ebfc62234..c8ebd31f593 100644 --- a/core/modules/dblog/tests/src/Functional/DbLogTest.php +++ b/core/modules/dblog/tests/src/Functional/DbLogTest.php @@ -183,7 +183,7 @@ class DbLogTest extends BrowserTestBase { // Try to read details of not existing event. $this->drupalGet('admin/reports/dblog/event/999999'); // Verify 404 response. - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** @@ -242,7 +242,7 @@ class DbLogTest extends BrowserTestBase { $edit = []; $edit['dblog_row_limit'] = $row_limit; $this->drupalPostForm('admin/config/development/logging', $edit, t('Save configuration')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check row limit variable. $current_limit = $this->config('dblog.settings')->get('row_limit'); @@ -284,34 +284,34 @@ class DbLogTest extends BrowserTestBase { private function verifyReports($response = 200) { // View the database log help page. $this->drupalGet('admin/help/dblog'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Database Logging'), 'DBLog help was displayed'); } // View the database log report page. $this->drupalGet('admin/reports/dblog'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Recent log messages'), 'DBLog report was displayed'); } $this->drupalGet('admin/reports/dblog/confirm'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Are you sure you want to delete the recent logs?'), 'DBLog clear logs form was displayed'); } // View the database log page-not-found report page. $this->drupalGet('admin/reports/page-not-found'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText("Top 'page not found' errors", 'DBLog page-not-found report was displayed'); } // View the database log access-denied report page. $this->drupalGet('admin/reports/access-denied'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText("Top 'access denied' errors", 'DBLog access-denied report was displayed'); } @@ -319,7 +319,7 @@ class DbLogTest extends BrowserTestBase { // View the database log event page. $wid = Database::getConnection()->query('SELECT MIN(wid) FROM {watchdog}')->fetchField(); $this->drupalGet('admin/reports/dblog/event/' . $wid); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Details'), 'DBLog event node was displayed'); } @@ -363,7 +363,7 @@ class DbLogTest extends BrowserTestBase { */ public function verifySort($sort = 'asc', $order = 'Date') { $this->drupalGet('admin/reports/dblog', ['query' => ['sort' => $sort, 'order' => $order]]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Recent log messages'), 'DBLog report was displayed correctly and sorting went fine.'); } @@ -402,7 +402,7 @@ class DbLogTest extends BrowserTestBase { $edit['pass[pass2]'] = $pass; $edit['status'] = 1; $this->drupalPostForm('admin/people/create', $edit, t('Create new account')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Retrieve the user object. $user = user_load_by_name($name); $this->assertNotNull($user, new FormattableMarkup('User @name was loaded', ['@name' => $name])); @@ -428,7 +428,7 @@ class DbLogTest extends BrowserTestBase { // View the database log report. $this->drupalGet('admin/reports/dblog'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify that the expected events were recorded. // Add user. @@ -459,10 +459,10 @@ class DbLogTest extends BrowserTestBase { // Visit random URL (to generate page not found event). $not_found_url = $this->randomMachineName(60); $this->drupalGet($not_found_url); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // View the database log page-not-found report page. $this->drupalGet('admin/reports/page-not-found'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check that full-length URL displayed. $this->assertText($not_found_url, 'DBLog event was recorded: [page not found]'); } @@ -485,29 +485,29 @@ class DbLogTest extends BrowserTestBase { $edit = $this->getContent($type); $title = $edit['title[0][value]']; $this->drupalPostForm('node/add/' . $type, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Retrieve the node object. $node = $this->drupalGetNodeByTitle($title); $this->assertNotNull($node, new FormattableMarkup('Node @title was loaded', ['@title' => $title])); // Edit the node. $edit = $this->getContentUpdate($type); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Delete the node. $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // View the node (to generate page not found event). $this->drupalGet('node/' . $node->id()); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // View the database log report (to generate access denied event). $this->drupalGet('admin/reports/dblog'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Log in the admin user. $this->drupalLogin($this->adminUser); // View the database log report. $this->drupalGet('admin/reports/dblog'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify that node events were recorded. // Was node content added? @@ -519,13 +519,13 @@ class DbLogTest extends BrowserTestBase { // View the database log access-denied report page. $this->drupalGet('admin/reports/access-denied'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify that the 'access denied' event was recorded. $this->assertText('admin/reports/dblog', 'DBLog event was recorded: [access denied]'); // View the database log page-not-found report page. $this->drupalGet('admin/reports/page-not-found'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify that the 'page not found' event was recorded. $this->assertText('node/' . $node->id(), 'DBLog event was recorded: [page not found]'); } @@ -677,7 +677,7 @@ class DbLogTest extends BrowserTestBase { } $this->drupalGet('admin/reports/dblog', ['query' => ['order' => 'Type']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Operations'), 'Operations text found'); // Clear all logs and make sure the confirmation message is found. @@ -807,7 +807,7 @@ class DbLogTest extends BrowserTestBase { // Delete the user. $tempuser->delete(); $this->drupalGet('user/' . $tempuser_uid); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Check if the full message displays on the details page. $this->drupalGet('admin/reports/dblog/event/' . $wid); @@ -821,7 +821,7 @@ class DbLogTest extends BrowserTestBase { $this->drupalLogin($this->adminUser); $this->generateLogEntries(1, ['message' => "<script>alert('foo');</script>Lorem ipsum dolor sit amet, consectetur adipiscing & elit."]); $this->drupalGet('admin/reports/dblog'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure HTML tags are filtered out. $this->assertRaw('title="alert('foo');Lorem'); $this->assertNoRaw(""); diff --git a/core/modules/editor/tests/src/Functional/EditorLoadingTest.php b/core/modules/editor/tests/src/Functional/EditorLoadingTest.php index 2d9f5b53cd9..15522d9764c 100644 --- a/core/modules/editor/tests/src/Functional/EditorLoadingTest.php +++ b/core/modules/editor/tests/src/Functional/EditorLoadingTest.php @@ -167,7 +167,7 @@ class EditorLoadingTest extends BrowserTestBase { // Load the editor image dialog form and make sure it does not fatal. $this->drupalGet('editor/dialog/image/full_html'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalLogout($this->privilegedUser); diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php index 6b8103178e0..124fe9d7b6a 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php @@ -163,7 +163,7 @@ class EntityReferenceAdminTest extends BrowserTestBase { 'field_test_entity_ref_field[1][target_id]' => 'Foo Node (' . $node2->id() . ')', ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = [ 'title[0][value]' => 'Example', diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFileUploadTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFileUploadTest.php index fcdf561c0a2..7541bea2d0b 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFileUploadTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFileUploadTest.php @@ -127,13 +127,13 @@ class EntityReferenceFileUploadTest extends BrowserTestBase { $test_file = current($this->getTestFiles('text')); $edit['files[file_field_0]'] = \Drupal::service('file_system')->realpath($test_file->uri); $this->drupalPostForm('node/add/' . $this->referencingType, $edit, 'Upload'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = [ 'title[0][value]' => $this->randomMachineName(), 'test_field[0][target_id]' => $this->nodeId, ]; $this->drupalPostForm(NULL, $edit, 'Save'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/field/tests/src/Functional/FormTest.php b/core/modules/field/tests/src/Functional/FormTest.php index a7678443286..dba8c35a694 100644 --- a/core/modules/field/tests/src/Functional/FormTest.php +++ b/core/modules/field/tests/src/Functional/FormTest.php @@ -666,7 +666,7 @@ class FormTest extends FieldTestBase { $entity->save(); $this->drupalGet('entity_test_base_field_display/manage/' . $entity->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('A field with multiple values'); // Test if labels were XSS filtered. $this->assertEscaped(""); diff --git a/core/modules/field/tests/src/Functional/Views/FieldUITest.php b/core/modules/field/tests/src/Functional/Views/FieldUITest.php index d3d595fe2ea..5f0f4ab0d19 100644 --- a/core/modules/field/tests/src/Functional/Views/FieldUITest.php +++ b/core/modules/field/tests/src/Functional/Views/FieldUITest.php @@ -111,7 +111,7 @@ class FieldUITest extends FieldTestBase { $url = "admin/structure/views/nojs/handler/test_view_fieldapi/default/field/field_name_0"; $this->drupalGet($url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test the click sort column options. // Tests the available formatter options. @@ -144,7 +144,7 @@ class FieldUITest extends FieldTestBase { $url = "admin/structure/views/nojs/add-handler/test_view_fieldapi/default/filter"; $this->drupalPostForm($url, ['name[node__' . $field_name . '.' . $field_name . '_value]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')])); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify that using a boolean field as a filter also results in using the // boolean plugin. $option = $this->xpath('//label[@for="edit-options-value-1"]'); diff --git a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php index af983850af0..9b37084ed41 100644 --- a/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php +++ b/core/modules/field_ui/tests/src/Functional/EntityDisplayModeTest.php @@ -48,16 +48,16 @@ class EntityDisplayModeTest extends BrowserTestBase { public function testEntityViewModeUI() { // Test the listing page. $this->drupalGet('admin/structure/display-modes/view'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalLogin($this->drupalCreateUser(['administer display modes'])); $this->drupalGet('admin/structure/display-modes/view'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Add view mode')); $this->assertLinkByHref('admin/structure/display-modes/view/add'); $this->assertLinkByHref('admin/structure/display-modes/view/add/entity_test'); $this->drupalGet('admin/structure/display-modes/view/add/entity_test_mulrev'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet('admin/structure/display-modes/view/add'); $this->assertNoLink(t('Test entity - revisions and data table'), 'An entity type with no view builder cannot have view modes.'); @@ -103,15 +103,15 @@ class EntityDisplayModeTest extends BrowserTestBase { public function testEntityFormModeUI() { // Test the listing page. $this->drupalGet('admin/structure/display-modes/form'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalLogin($this->drupalCreateUser(['administer display modes'])); $this->drupalGet('admin/structure/display-modes/form'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Add form mode')); $this->assertLinkByHref('admin/structure/display-modes/form/add'); $this->drupalGet('admin/structure/display-modes/form/add/entity_test_no_label'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet('admin/structure/display-modes/form/add'); $this->assertNoLink(t('Entity Test without label'), 'An entity type with no form cannot have form modes.'); diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php index 5f9ca9ccedf..49ab321cd34 100644 --- a/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php +++ b/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php @@ -48,7 +48,7 @@ class FieldUIRouteTest extends BrowserTestBase { // Test manage display tabs and titles. $this->drupalGet('admin/config/people/accounts/display/compact'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('admin/config/people/accounts/display'); $this->assertTitle('Manage display | Drupal'); @@ -62,7 +62,7 @@ class FieldUIRouteTest extends BrowserTestBase { // Test manage form display tabs and titles. $this->drupalGet('admin/config/people/accounts/form-display/register'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('admin/config/people/accounts/form-display'); $this->assertTitle('Manage form display | Drupal'); @@ -70,7 +70,7 @@ class FieldUIRouteTest extends BrowserTestBase { $edit = ['display_modes_custom[register]' => TRUE]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/config/people/accounts/form-display/register'); $this->assertTitle('Manage form display | Drupal'); $this->assertLocalTasks(); diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php index aecdb308ddf..0f45964fb7e 100644 --- a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php @@ -339,7 +339,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase { $field_id = 'node.' . $this->contentType . '.' . $this->fieldName; $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id); $this->clickLink(t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -585,7 +585,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase { $locked = $this->xpath('//tr[@id=:field_name]/td[4]', [':field_name' => $field_name]); $this->assertSame('Locked', $locked[0]->getHtml(), 'Field is marked as Locked in the UI'); $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/node.' . $this->contentType . '.' . $field_name . '/delete'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** @@ -668,7 +668,7 @@ class ManageFieldsFunctionalTest extends BrowserTestBase { $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body/storage', [], 'Save field settings', $options); // The external redirect should not fire. $this->assertUrl('admin/structure/types/manage/article/fields/node.article.body/storage', $options); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Attempt to update field Body failed: The internal path component 'http://example.com' is external. You are not allowed to specify an external URL together with internal:/..'); } @@ -782,10 +782,10 @@ class ManageFieldsFunctionalTest extends BrowserTestBase { $field_id = 'node.foo.bar'; $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id . '/storage'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } } diff --git a/core/modules/file/tests/src/Functional/DownloadTest.php b/core/modules/file/tests/src/Functional/DownloadTest.php index 3b5090546cc..35d2589323c 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); + $this->assertSession()->statusCodeEquals(200); // Ensure hook_file_download is fired correctly. $this->assertEquals($file->getFileUri(), \Drupal::state()->get('file_test.results')['download'][0][0]); @@ -174,7 +174,7 @@ class DownloadTest extends FileManagedTestBase { } $this->drupalGet($url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(file_get_contents($file->getFileUri())); $file->delete(); diff --git a/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php b/core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php index 1c0b398d53b..1d221e443d7 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); + $this->assertSession()->statusCodeEquals(200); $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); $edit = [ @@ -48,7 +48,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { 'body[0][value]' => 'Test article', ]; $this->drupalPostForm(NULL, $edit, 'Save'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $t_args = ['@type' => $bundle_label, '%title' => $node_title]; $this->assertText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.'); $matches = []; @@ -71,7 +71,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { // Load the node form. $this->drupalLogout(); $this->drupalGet('node/add/article'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); // Generate an image file. @@ -84,7 +84,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { 'files[field_image_0]' => $this->container->get('file_system')->realpath($image->getFileUri()), ]; $this->drupalPostForm(NULL, $edit, 'Save'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $t_args = ['@type' => $bundle_label, '%title' => $node_title]; $this->assertText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.'); $matches = []; @@ -128,7 +128,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { // Load the node form. $this->drupalGet('node/add/article'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label]))); // Generate an image file. @@ -146,7 +146,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase { $label = 'Save'; } $this->drupalPostForm(NULL, $edit, $label); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $t_args = ['@type' => $bundle_label, '%title' => $node_title]; $this->assertNoText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.'); $this->assertText('Title field is required.'); diff --git a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php index f2821a800c9..e558a4b601c 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); // Ensure that the anonymous user cannot download the file. $this->drupalLogout(); $this->drupalGet($comment_file->createFileUrl()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); } /** @@ -512,7 +512,7 @@ class FileFieldWidgetTest extends FileFieldTestBase { // Ensure the file can be downloaded. $this->drupalGet($node_file->createFileUrl()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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/FileListingTest.php b/core/modules/file/tests/src/Functional/FileListingTest.php index ae159841da8..5712525e3d0 100644 --- a/core/modules/file/tests/src/Functional/FileListingTest.php +++ b/core/modules/file/tests/src/Functional/FileListingTest.php @@ -75,7 +75,7 @@ class FileListingTest extends FileFieldTestBase { // Users without sufficient permissions should not see file listing. $this->drupalLogin($this->baseUser); $this->drupalGet('admin/content/files'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Log in with user with right permissions and test listing. $this->drupalLogin($this->adminUser); @@ -85,16 +85,16 @@ class FileListingTest extends FileFieldTestBase { } $this->drupalGet('admin/content/files'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('No files available.'); $this->drupalGet('admin/content/files'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Create a file with no usage. $file = $this->createFile(); $this->drupalGet('admin/content/files/usage/' . $file->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle(t('File usage information for @file | Drupal', ['@file' => $file->getFilename()])); foreach ($nodes as &$node) { @@ -142,7 +142,7 @@ class FileListingTest extends FileFieldTestBase { $file = File::load($node->file->target_id); $usage = $file_usage->listUsage($file); $this->drupalGet('admin/content/files/usage/' . $file->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($node->getTitle(), 'Node title found on usage page.'); $this->assertText('node', 'Registering entity type found on usage page.'); $this->assertText('file', 'Registering module found on usage page.'); @@ -198,7 +198,7 @@ class FileListingTest extends FileFieldTestBase { // Load the file usage page for the created and attached file. $this->drupalGet('admin/content/files/usage/' . $file->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Entity name should be displayed, but not linked if Entity::toUrl // throws an exception $this->assertText($entity_name, 'Entity name is added to file usage listing.'); diff --git a/core/modules/file/tests/src/Functional/FilePrivateTest.php b/core/modules/file/tests/src/Functional/FilePrivateTest.php index a765bbab93e..72393c4d1f6 100644 --- a/core/modules/file/tests/src/Functional/FilePrivateTest.php +++ b/core/modules/file/tests/src/Functional/FilePrivateTest.php @@ -60,11 +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); + $this->assertSession()->statusCodeEquals(200); $this->drupalLogOut(); // Ensure the file cannot be downloaded after logging out. $this->drupalGet(file_create_url($node_file->getFileUri())); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create a field with no view access. See // field_test_entity_field_access(). @@ -80,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); + $this->assertSession()->statusCodeEquals(403); // Attempt to reuse the file when editing a node. $edit = []; @@ -117,18 +117,18 @@ class FilePrivateTest extends FileFieldTestBase { $node->delete(); // Ensure the temporary file can still be downloaded by the owner. $this->drupalGet($file_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Ensure the temporary file cannot be downloaded by an anonymous user. $this->drupalLogout(); $this->drupalGet($file_url); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Ensure the temporary file cannot be downloaded by another user. $account = $this->drupalCreateUser(); $this->drupalLogin($account); $this->drupalGet($file_url); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // As an anonymous user, create a temporary file with no references and // confirm that only the session that uploaded it may view it. @@ -155,12 +155,12 @@ class FilePrivateTest extends FileFieldTestBase { $file_url = file_create_url($file->getFileUri()); // Ensure the anonymous uploader has access to the temporary file. $this->drupalGet($file_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); // As an anonymous user, create a permanent file, then remove all // references to the file (so that it becomes temporary again) and confirm @@ -185,12 +185,12 @@ class FilePrivateTest extends FileFieldTestBase { $file_url = file_create_url($file->getFileUri()); // Ensure the anonymous uploader has access to the temporary file. $this->drupalGet($file_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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. @@ -208,12 +208,12 @@ class FilePrivateTest extends FileFieldTestBase { $file_url = file_create_url($file->getFileUri()); // Ensure the anonymous uploader has access to the file. $this->drupalGet($file_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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 @@ -235,12 +235,12 @@ class FilePrivateTest extends FileFieldTestBase { $file_url = file_create_url($file->getFileUri()); // Ensure the anonymous uploader cannot access to the file. $this->drupalGet($file_url); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php index 1668274bc42..72e777b66b9 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/file/tests/src/Functional/SaveUploadFormTest.php b/core/modules/file/tests/src/Functional/SaveUploadFormTest.php index 072c5007d9a..bd7891920bd 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Check that the no hooks were called while failing. @@ -385,13 +385,13 @@ 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); + $this->assertSession()->statusCodeEquals(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.'); // Uploading failed. Now check the log. $this->drupalGet('admin/reports/dblog'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [ '@file' => $this->image->getFilename(), '@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename(), @@ -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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); // Ensure the error message is not present and the counts before and after @@ -475,7 +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); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Search for combined error message followed by a formatted list of messages. @@ -495,7 +495,7 @@ class SaveUploadFormTest extends FileManagedTestBase { 'extensions' => 'foo', ]; $this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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 caf01b1669f..c4d9ee49f38 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('You WIN!')); $this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath))); } @@ -160,7 +160,7 @@ class SaveUploadTest extends FileManagedTestBase { $edit = ['files[file_test_upload]' => \Drupal::service('file_system')->realpath($image2->uri)]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); // Received a 200 response for posted test file. - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $message = t('The file %file already exists. Enter a unique file URI.', ['%file' => $file1->getFileUri()]); $this->assertRaw($message); $max_fid_before_duplicate = $max_fid_after; @@ -184,7 +184,7 @@ class SaveUploadTest extends FileManagedTestBase { ]; $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.'); // Check that the no hooks were called while failing. @@ -398,13 +398,13 @@ class SaveUploadTest extends FileManagedTestBase { \Drupal::state()->set('file_test.disable_error_collection', TRUE); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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.'); // Uploading failed. Now check the log. $this->drupalGet('admin/reports/dblog'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('Upload error. Could not move uploaded file @file to destination @destination.', [ '@file' => $this->image->getFilename(), '@destination' => 'temporary://' . $test_directory . '/' . $this->image->getFilename(), diff --git a/core/modules/filter/tests/src/Functional/FilterAdminTest.php b/core/modules/filter/tests/src/Functional/FilterAdminTest.php index 8fd19f56234..00e2c16f245 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); // Verify access permissions to Full HTML format. $full_format = FilterFormat::load($full); diff --git a/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php b/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php index 8dbcf50f2a7..16ca25643db 100644 --- a/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php +++ b/core/modules/filter/tests/src/Functional/FilterFormatAccessTest.php @@ -163,24 +163,24 @@ class FilterFormatAccessTest extends BrowserTestBase { // Check regular user access to the filter tips pages. $this->drupalGet('filter/tips/' . $this->allowedFormat->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('filter/tips/' . $this->disallowedFormat->id()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('filter/tips/' . filter_fallback_format()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('filter/tips/invalid-format'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Check admin user access to the filter tips pages. $this->drupalLogin($this->adminUser); $this->drupalGet('filter/tips/' . $this->allowedFormat->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('filter/tips/' . $this->disallowedFormat->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('filter/tips/' . filter_fallback_format()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('filter/tips/invalid-format'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** diff --git a/core/modules/forum/tests/src/Functional/ForumTest.php b/core/modules/forum/tests/src/Functional/ForumTest.php index b68e1daa918..3ae2c55edc9 100644 --- a/core/modules/forum/tests/src/Functional/ForumTest.php +++ b/core/modules/forum/tests/src/Functional/ForumTest.php @@ -235,13 +235,13 @@ class ForumTest extends BrowserTestBase { $edit = []; $edit['comment_body[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/' . $node->id(), $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test editing a forum topic that has a comment. $this->drupalLogin($this->editAnyTopicsUser); $this->drupalGet('forum/' . $this->forum['tid']); $this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test the root forum page title change. $this->drupalGet('forum'); @@ -307,7 +307,7 @@ class ForumTest extends BrowserTestBase { // Add forum to the Tools menu. $edit = []; $this->drupalPostForm('admin/structure/menu/manage/tools', $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Edit forum taxonomy. // Restoration of the settings fails and causes subsequent tests to fail. @@ -390,7 +390,7 @@ class ForumTest extends BrowserTestBase { // Edit the vocabulary. $this->drupalPostForm('admin/structure/taxonomy/manage/' . $original_vocabulary->id(), $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('Updated vocabulary %name.', ['%name' => $edit['name']]), 'Vocabulary was edited'); // Grab the newly edited vocabulary. @@ -434,7 +434,7 @@ class ForumTest extends BrowserTestBase { // Create forum. $this->drupalPostForm('admin/structure/forum/add/' . $type, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $type = ($type == 'container') ? 'forum container' : 'forum'; $this->assertText( t( @@ -491,7 +491,7 @@ class ForumTest extends BrowserTestBase { // Assert that the forum no longer exists. $this->drupalGet('forum/' . $tid); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** @@ -533,18 +533,18 @@ class ForumTest extends BrowserTestBase { $edit['subject[0][value]'] = $this->randomMachineName(); $edit['comment_body[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/' . $node->id(), $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test replying to a comment. $this->clickLink('Reply'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertFieldByName('comment_body[0][value]'); // Log in as the first user. $this->drupalLogin($this->adminUser); // Check that forum renders properly. $this->drupalGet("forum/{$this->forum['tid']}"); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify there is no unintentional HTML tag escaping. $this->assertNoEscaped('<', ''); @@ -618,7 +618,7 @@ class ForumTest extends BrowserTestBase { // View forum help node. $this->drupalGet('admin/help/forum'); - $this->assertResponse($response2); + $this->assertSession()->statusCodeEquals($response2); if ($response2 == 200) { $this->assertTitle(t('Forum | Drupal'), 'Forum help title was displayed'); $this->assertText(t('Forum'), 'Forum help node was displayed'); @@ -633,7 +633,7 @@ class ForumTest extends BrowserTestBase { // View forum node. $this->drupalGet('node/' . $node->id()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle($node->label() . ' | Drupal', 'Forum node was displayed'); $breadcrumb_build = [ Link::createFromRoute(t('Home'), ''), @@ -649,7 +649,7 @@ class ForumTest extends BrowserTestBase { // View forum edit node. $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertTitle('Edit Forum topic ' . $node->label() . ' | Drupal', 'Forum edit node was displayed'); } @@ -678,7 +678,7 @@ class ForumTest extends BrowserTestBase { // Delete forum node. $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete')); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); $this->assertRaw(t('Forum topic %title has been deleted.', ['%title' => $edit['title[0][value]']]), 'Forum node was deleted'); } } @@ -694,7 +694,7 @@ class ForumTest extends BrowserTestBase { private function verifyForumView($forum, $parent = NULL) { // View forum page. $this->drupalGet('forum/' . $forum['tid']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertTitle($forum['name'] . ' | Drupal'); $breadcrumb_build = [ diff --git a/core/modules/forum/tests/src/Functional/ForumUninstallTest.php b/core/modules/forum/tests/src/Functional/ForumUninstallTest.php index 177dbfb5690..30a84590c1f 100644 --- a/core/modules/forum/tests/src/Functional/ForumUninstallTest.php +++ b/core/modules/forum/tests/src/Functional/ForumUninstallTest.php @@ -118,7 +118,7 @@ class ForumUninstallTest extends BrowserTestBase { $this->drupalGet('admin/structure/types/manage/forum'); $this->clickLink(t('Delete')); $this->drupalPostForm(NULL, [], t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertFalse((bool) NodeType::load('forum'), 'Node type with machine forum deleted.'); // Double check everything by reinstalling the forum module again. diff --git a/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php b/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php index 60d3d0f977b..76af811233b 100644 --- a/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php +++ b/core/modules/help/tests/src/Functional/ExperimentalHelpTest.php @@ -58,7 +58,7 @@ class ExperimentalHelpTest extends BrowserTestBase { $this->assertNoText('This module is experimental.'); // Ensure the actual help page is displayed to avoid a false positive. - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('online documentation for the Help Page Test module'); } diff --git a/core/modules/help/tests/src/Functional/HelpTest.php b/core/modules/help/tests/src/Functional/HelpTest.php index c89f5f33f4e..3efdb98ce41 100644 --- a/core/modules/help/tests/src/Functional/HelpTest.php +++ b/core/modules/help/tests/src/Functional/HelpTest.php @@ -114,7 +114,7 @@ class HelpTest extends BrowserTestBase { */ protected function verifyHelp($response = 200) { $this->drupalGet('admin/index'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText('This page shows you all available administration tasks for each module.'); } @@ -125,7 +125,7 @@ class HelpTest extends BrowserTestBase { foreach ($this->getModuleList() as $module => $name) { // View module help page. $this->drupalGet('admin/help/' . $module); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertTitle($name . ' | Drupal', new FormattableMarkup('%module title was displayed', ['%module' => $module])); $this->assertEquals($name, $this->cssSelect('h1.page-title')[0]->getText(), "$module heading was displayed"); diff --git a/core/modules/help/tests/src/Functional/NoHelpTest.php b/core/modules/help/tests/src/Functional/NoHelpTest.php index 86ba5cbdb08..63eaf6276ad 100644 --- a/core/modules/help/tests/src/Functional/NoHelpTest.php +++ b/core/modules/help/tests/src/Functional/NoHelpTest.php @@ -42,7 +42,7 @@ class NoHelpTest extends BrowserTestBase { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/help'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Module overviews are provided by modules'); $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.'); @@ -50,7 +50,7 @@ class NoHelpTest extends BrowserTestBase { // 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); + $this->assertSession()->statusCodeEquals(404); } } diff --git a/core/modules/help_topics/tests/src/Functional/HelpTopicSearchTest.php b/core/modules/help_topics/tests/src/Functional/HelpTopicSearchTest.php index 902be752cd2..76907b9f56e 100644 --- a/core/modules/help_topics/tests/src/Functional/HelpTopicSearchTest.php +++ b/core/modules/help_topics/tests/src/Functional/HelpTopicSearchTest.php @@ -251,7 +251,7 @@ class HelpTopicSearchTest extends HelpTopicTranslatedTestBase { $this->drupalPostForm(NULL, NULL, t('Uninstall')); $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.'); $this->drupalGet('admin/help'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php index 02cbba80b00..0041fa3cf7c 100644 --- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @@ -251,7 +251,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase { // Delete the 'image_crop' effect from the style. $this->drupalPostForm($style_path . '/effects/' . $uuids['image_crop'] . '/delete', [], t('Delete')); // Confirm that the form submission was successful. - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $image_crop_effect = $style->getEffect($uuids['image_crop']); $this->assertRaw(t('The image effect %name has been deleted.', ['%name' => $image_crop_effect->label()])); // Confirm that there is no longer a link to the effect. @@ -418,7 +418,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase { // Try to edit a nonexistent effect. $uuid = $this->container->get('uuid'); $this->drupalGet('admin/config/media/image-styles/manage/' . $style_name . '/effects/' . $uuid->generate()); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** diff --git a/core/modules/image/tests/src/Functional/ImageDimensionsTest.php b/core/modules/image/tests/src/Functional/ImageDimensionsTest.php index f374a9d2b26..53d9a349e04 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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 62edbb7a72c..ccd8dd21ba9 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -155,7 +155,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase { // Log out and ensure the file cannot be accessed. $this->drupalLogout(); $this->drupalGet(file_create_url($image_uri)); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Log in again. $this->drupalLogin($this->adminUser); @@ -214,7 +214,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase { // Log out and ensure the file cannot be accessed. $this->drupalLogout(); $this->drupalGet(ImageStyle::load('thumbnail')->buildUrl($image_uri)); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } // Test the image URL formatter without an image style. diff --git a/core/modules/image/tests/src/Functional/ImageStyleFlushTest.php b/core/modules/image/tests/src/Functional/ImageStyleFlushTest.php index a5036eec8f2..75a799645e9 100644 --- a/core/modules/image/tests/src/Functional/ImageStyleFlushTest.php +++ b/core/modules/image/tests/src/Functional/ImageStyleFlushTest.php @@ -112,9 +112,9 @@ class ImageStyleFlushTest extends ImageFieldTestBase { $uuids[$effect->getPluginId()] = $uuid; } $this->drupalPostForm($style_path . '/effects/' . $uuids['image_scale'] . '/delete', [], t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm($style_path, [], t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Post flush, expected 1 image in the 'public' wrapper (sample.png). $this->assertEqual($this->getImageCount($style, 'public'), 1, new FormattableMarkup('Image style %style flushed correctly for %wrapper wrapper.', ['%style' => $style->label(), '%wrapper' => 'public'])); diff --git a/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php b/core/modules/image/tests/src/Functional/ImageStylesPathAndUrlTest.php index 6c2a733a59b..2d086d901d3 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(404); // Change the parameter name so the token is missing. $this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', 'wrongparam=', $generate_url)); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet(substr_replace($nested_url_with_wrong_token, '////styles/', strrpos($nested_url_with_wrong_token, '/styles/'), strlen('/styles/'))); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Make sure the image can still be generated if a correct token is used. $this->drupalGet($nested_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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 73acb48df5f..bae4dbb9ba5 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->assertSession()->statusCodeEquals(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 2b17c5edf4f..173d3c89738 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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 da17dc04193..5ee0706cac3 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); + $this->assertSession()->statusCodeEquals(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 c04d6503e8d..567ab2a25b7 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); + $this->assertSession()->statusCodeEquals(404); // Set preferred langcode for user to NULL. $account = $this->loggedInUser; @@ -412,7 +412,7 @@ class LanguageUILanguageNegotiationTest extends BrowserTestBase { // match. Cache::invalidateTags(['route_match']); $this->drupalGet('system/files/test/private-file-test.txt'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -580,7 +580,7 @@ class LanguageUILanguageNegotiationTest extends BrowserTestBase { 'language_content[configurable]' => FALSE, ]; $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check if the language switcher block has been removed. $block = Block::load($block_id); diff --git a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php index f7561c19a30..dc5ca8e46d9 100644 --- a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php @@ -97,7 +97,7 @@ class LanguageUrlRewritingTest extends BrowserTestBase { $prefix = $stored_prefix; $this->drupalGet("$prefix/$path"); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** diff --git a/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php b/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php index a3d9582d5aa..cd0c475f8c8 100644 --- a/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php @@ -44,7 +44,7 @@ class LocaleLocaleLookupTest extends BrowserTestBase { public function testCircularDependency() { // Ensure that we can enable early_translation_test on a non-english site. $this->drupalPostForm('admin/modules', ['modules[early_translation_test][enable]' => TRUE], t('Install')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslationUiTest.php index 859c727e5ea..1b2a45bfc26 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); + $this->assertSession()->statusCodeEquals(404); $this->drupalLogout(); // Delete the string. diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php index 22ad314b421..1e590223ad2 100644 --- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php +++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php @@ -67,12 +67,12 @@ class MenuLinkContentFormTest extends BrowserTestBase { // The user should be able to edit a menu link to the page, even though // the user cannot access the page itself. $this->drupalGet('/admin/structure/menu/item/' . $menu_link->id() . '/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalLogin($this->basicUser); $this->drupalGet('/admin/structure/menu/item/' . $menu_link->id() . '/edit'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php index 42f4913c85e..4f1c2ead473 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php @@ -134,9 +134,9 @@ class MenuUiTest extends BrowserTestBase { $this->assertNoLinkByHref(Url::fromRoute('menu_ui.link_reset', ['menu_link_plugin' => $this->items[0]->getPluginId()])->toString()); // Check delete and reset access. $this->drupalGet('admin/structure/menu/item/' . $this->items[0]->id() . '/delete'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/structure/menu/link/' . $this->items[0]->getPluginId() . '/reset'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Delete menu links. foreach ($this->items as $item) { @@ -154,7 +154,7 @@ class MenuUiTest extends BrowserTestBase { $edit['weight'] = 10; $id = $instance->getPluginId(); $this->drupalPostForm("admin/structure/menu/link/$id/edit", $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('The menu link has been saved.'); $menu_link_manager->resetDefinitions(); @@ -255,7 +255,7 @@ class MenuUiTest extends BrowserTestBase { // Delete custom menu. $this->drupalPostForm("admin/structure/menu/manage/$menu_name/delete", [], t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('The menu %title has been deleted.', ['%title' => $label]), 'Custom menu was deleted'); $this->assertNull(Menu::load($menu_name), 'Custom menu was deleted'); // Test if all menu links associated with the menu were removed from @@ -474,10 +474,10 @@ class MenuUiTest extends BrowserTestBase { $item8 = $this->addMenuLink('', '/', $menu_name); $this->assertMenuLink(['route_name' => ''], $item8->getPluginId()); $this->drupalGet(''); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure we get routed correctly. $this->clickLink($item8->getTitle()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check invalid menu link parents. $this->checkInvalidParentMenuLinks(); @@ -492,7 +492,7 @@ class MenuUiTest extends BrowserTestBase { */ protected function doMenuLinkFormDefaultsTest() { $this->drupalGet("admin/structure/menu/manage/tools/add"); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertFieldByName('title[0][value]', ''); $this->assertFieldByName('link[0][uri]', ''); @@ -600,7 +600,7 @@ class MenuUiTest extends BrowserTestBase { public function addMenuLink($parent = '', $path = '/', $menu_name = 'tools', $expanded = FALSE, $weight = '0') { // View add menu link page. $this->drupalGet("admin/structure/menu/manage/$menu_name/add"); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $title = '!link_' . $this->randomMachineName(16); $edit = [ @@ -615,7 +615,7 @@ class MenuUiTest extends BrowserTestBase { // Add menu link. $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('The menu link has been saved.'); $menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(['title' => $title]); @@ -698,7 +698,7 @@ class MenuUiTest extends BrowserTestBase { public function verifyMenuLink(MenuLinkContent $item, $item_node, MenuLinkContent $parent = NULL, $parent_node = NULL) { // View home page. $this->drupalGet(''); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify parent menu link. if (isset($parent)) { @@ -739,7 +739,7 @@ class MenuUiTest extends BrowserTestBase { 'menu_parent' => $menu_name . ':' . $parent, ]; $this->drupalPostForm("admin/structure/menu/item/$mlid/edit", $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -758,7 +758,7 @@ class MenuUiTest extends BrowserTestBase { $edit = []; $edit['title[0][value]'] = $title; $this->drupalPostForm("admin/structure/menu/item/$mlid/edit", $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('The menu link has been saved.'); // Verify menu link. $this->drupalGet('admin/structure/menu/manage/' . $item->getMenuName()); @@ -776,7 +776,7 @@ class MenuUiTest extends BrowserTestBase { public function resetMenuLink(MenuLinkInterface $menu_link, $old_weight) { // Reset menu link. $this->drupalPostForm("admin/structure/menu/link/{$menu_link->getPluginId()}/reset", [], t('Reset')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('The menu link was reset to its default settings.'), 'Menu link was reset'); // Verify menu link. @@ -796,7 +796,7 @@ class MenuUiTest extends BrowserTestBase { // Delete menu link. $this->drupalPostForm("admin/structure/menu/item/$mlid/delete", [], t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('The menu link %title has been deleted.', ['%title' => $title]), 'Menu link was deleted'); // Verify deletion. @@ -937,21 +937,21 @@ class MenuUiTest extends BrowserTestBase { private function verifyAccess($response = 200) { // View menu help page. $this->drupalGet('admin/help/menu'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Menu'), 'Menu help was displayed'); } // View menu build overview page. $this->drupalGet('admin/structure/menu'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Menus'), 'Menu build overview page was displayed'); } // View tools menu customization page. $this->drupalGet('admin/structure/menu/manage/' . $this->menu->id()); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Tools'), 'Tools menu page was displayed'); } @@ -959,14 +959,14 @@ class MenuUiTest extends BrowserTestBase { // View menu edit page for a static link. $item = $this->getStandardMenuLink(); $this->drupalGet('admin/structure/menu/link/' . $item->getPluginId() . '/edit'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Edit menu item'), 'Menu edit page was displayed'); } // View add menu page. $this->drupalGet('admin/structure/menu/add'); - $this->assertResponse($response); + $this->assertSession()->statusCodeEquals($response); if ($response == 200) { $this->assertText(t('Menus'), 'Add menu page was displayed'); } diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateAccessTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateAccessTest.php index 0815b0e500f..32c93a626a5 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateAccessTest.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateAccessTest.php @@ -29,13 +29,13 @@ class MigrateAccessTest extends BrowserTestBase { public function testAccess() { $this->drupalLogin($this->rootUser); $this->drupalGet('upgrade'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Upgrade')); $user = $this->createUser(['administer software updates']); $this->drupalLogin($user); $this->drupalGet('upgrade'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertNoText(t('Upgrade')); } diff --git a/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php index 06f2bb8b4a7..f4a88c3578f 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessBaseTableTest.php @@ -145,7 +145,7 @@ class NodeAccessBaseTableTest extends NodeTestBase { else { $should_be_visible = TRUE; } - $this->assertResponse($should_be_visible ? 200 : 403, strtr('A %private node by user %uid is %visible for user %current_uid.', [ + $this->assertSession()->statusCodeEquals($should_be_visible ? 200 : 403, strtr('A %private node by user %uid is %visible for user %current_uid.', [ '%private' => $is_private ? 'private' : 'public', '%uid' => $uid, '%visible' => $should_be_visible ? 'visible' : 'not visible', @@ -166,7 +166,7 @@ class NodeAccessBaseTableTest extends NodeTestBase { foreach ($this->nodesByUser as $private_status) { foreach ($private_status as $nid => $is_private) { $this->drupalGet('node/' . $nid); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } @@ -182,7 +182,7 @@ class NodeAccessBaseTableTest extends NodeTestBase { foreach ($this->nodesByUser as $private_status) { foreach ($private_status as $nid => $is_private) { $this->drupalGet('node/' . $nid); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php b/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php index 132e4e159b3..11c646df8c7 100644 --- a/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php +++ b/core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php @@ -36,7 +36,7 @@ class NodeActionsConfigurationTest extends BrowserTestBase { $edit = []; $edit['action'] = 'node_assign_owner_action'; $this->drupalPostForm('admin/config/system/actions', $edit, t('Create')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make a POST request to the individual action configuration page. $edit = []; @@ -45,7 +45,7 @@ class NodeActionsConfigurationTest extends BrowserTestBase { $edit['id'] = strtolower($action_label); $edit['owner_uid'] = $user->id(); $this->drupalPostForm('admin/config/system/actions/add/node_assign_owner_action', $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $action_id = $edit['id']; @@ -60,7 +60,7 @@ class NodeActionsConfigurationTest extends BrowserTestBase { $edit['label'] = $new_action_label; $edit['owner_uid'] = $user->id(); $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure that the action updated properly. $this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully updated.'); @@ -70,15 +70,15 @@ class NodeActionsConfigurationTest extends BrowserTestBase { // Make sure that deletions work properly. $this->drupalGet('admin/config/system/actions'); $this->clickLink(t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = []; $this->drupalPostForm(NULL, $edit, t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure that the action was actually deleted. $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'The delete confirmation message appears after deleting the node_assign_owner_action action.'); $this->drupalGet('admin/config/system/actions'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText($new_action_label, 'The label for the node_assign_owner_action action does not appear on the actions administration page after deleting.'); $action = Action::load($action_id); diff --git a/core/modules/node/tests/src/Functional/NodeAdminTest.php b/core/modules/node/tests/src/Functional/NodeAdminTest.php index 00663b6436a..0627c413cf2 100644 --- a/core/modules/node/tests/src/Functional/NodeAdminTest.php +++ b/core/modules/node/tests/src/Functional/NodeAdminTest.php @@ -133,7 +133,7 @@ class NodeAdminTest extends NodeTestBase { // Verify view, edit, and delete links for any content. $this->drupalGet('admin/content'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $node_type_labels = $this->xpath('//td[contains(@class, "views-field-type")]'); $delta = 0; @@ -163,7 +163,7 @@ class NodeAdminTest extends NodeTestBase { $this->drupalLogout(); $this->drupalLogin($this->baseUser1); $this->drupalGet('admin/content'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('node/' . $nodes['published_page']->id()); $this->assertLinkByHref('node/' . $nodes['published_article']->id()); $this->assertNoLinkByHref('node/' . $nodes['published_page']->id() . '/edit'); @@ -183,7 +183,7 @@ class NodeAdminTest extends NodeTestBase { $this->drupalLogout(); $this->drupalLogin($this->baseUser2); $this->drupalGet('admin/content'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('node/' . $nodes['unpublished_page_2']->id()); // Verify no operation links are displayed. $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_2']->id() . '/edit'); @@ -201,7 +201,7 @@ class NodeAdminTest extends NodeTestBase { $this->drupalLogout(); $this->drupalLogin($this->baseUser3); $this->drupalGet('admin/content'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); foreach ($nodes as $node) { $this->assertLinkByHref('node/' . $node->id()); $this->assertLinkByHref('node/' . $node->id() . '/edit'); diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php index 5f1b20ab29b..f3a9c164b8c 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -48,7 +48,7 @@ class NodeCreationTest extends NodeTestBase { // Test /node/add page with only one content type. $node_type_storage->load('article')->delete(); $this->drupalGet('node/add'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertUrl('node/add/page'); // Create a node. $edit = []; @@ -253,7 +253,7 @@ class NodeCreationTest extends NodeTestBase { */ public function testNodeAddWithoutContentTypes() { $this->drupalGet('node/add'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoLinkByHref('/admin/structure/types/add'); // Test /node/add page without content types. @@ -262,7 +262,7 @@ class NodeCreationTest extends NodeTestBase { } $this->drupalGet('node/add'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $admin_content_types = $this->drupalCreateUser(['administer content types']); $this->drupalLogin($admin_content_types); diff --git a/core/modules/node/tests/src/Functional/NodeHelpTest.php b/core/modules/node/tests/src/Functional/NodeHelpTest.php index 394a326f5e6..59a127aa308 100644 --- a/core/modules/node/tests/src/Functional/NodeHelpTest.php +++ b/core/modules/node/tests/src/Functional/NodeHelpTest.php @@ -69,13 +69,13 @@ class NodeHelpTest extends BrowserTestBase { public function testNodeShowHelpText() { // Check the node add form. $this->drupalGet('node/add/' . $this->testType); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($this->testText); // Create node and check the node edit form. $node = $this->drupalCreateNode(['type' => $this->testType]); $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($this->testText); } diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php index ff12b108a60..b1daab25550 100644 --- a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php +++ b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php @@ -251,17 +251,17 @@ class NodeRevisionsTest extends NodeTestBase { $this->drupalGet("node/" . $node->id() . "/revisions"); // Verify revisions is accessible since the type has revisions enabled. - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check initial revision is shown on the node revisions overview page. $this->assertText('Simple revision message (EN)'); // Verify that delete operation is inaccessible for the default revision. $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/delete"); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Verify that revert operation is inaccessible for the default revision. $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/revert"); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create a new revision and new log message. $node = Node::load($node->id()); @@ -284,7 +284,7 @@ class NodeRevisionsTest extends NodeTestBase { $this->drupalGet("node/" . $node->id() . "/revisions"); // Verify revisions is accessible since the type has revisions enabled. - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check initial revision is shown on the node revisions overview page. $this->assertText('Simple revision message (EN)'); diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php index 2f6cc82c990..697be9a6dec 100644 --- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php +++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php @@ -261,7 +261,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase { $this->assertNoRaw('core/themes/seven/css/base/elements.css', 'Translation uses frontend theme if edit is frontend.'); // Assert presence of translation page itself (vs. DisabledBundle below). - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -284,7 +284,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase { // Ensure the translation tab is not accessible. $this->drupalGet('node/' . $node->id() . '/translations'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** @@ -500,7 +500,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase { // Should be different from regular node URL. $this->assertNotIdentical($original_revision_url, $original_revision->toUrl()->toString()); $this->drupalGet($original_revision_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Contents should be in English, of correct revision. $this->assertText('First rev en title'); @@ -513,7 +513,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase { $this->assertNotIdentical($url_fr, $original_revision->toUrl()->toString()); $this->assertNotIdentical($url_fr, $original_revision_url); $this->drupalGet($url_fr); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Contents should be in French, of correct revision. $this->assertText('First rev fr title'); diff --git a/core/modules/node/tests/src/Functional/NodeTypeTest.php b/core/modules/node/tests/src/Functional/NodeTypeTest.php index 7c42cb8f2b5..3484cef5b13 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); + $this->assertSession()->statusCodeEquals(200); // Create a content type via the user interface. $web_user = $this->drupalCreateUser(['bypass node access', 'administer content types']); @@ -204,14 +204,14 @@ class NodeTypeTest extends NodeTestBase { $this->drupalGet('admin/structure/types/manage/default'); $this->assertNoLink(t('Delete')); $this->drupalGet('admin/structure/types/manage/default/delete'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->container->get('module_installer')->uninstall(['node_test_config']); $this->container = \Drupal::getContainer(); unset($locked['default']); \Drupal::state()->set('node.type.locked', $locked); $this->drupalGet('admin/structure/types/manage/default'); $this->clickLink(t('Delete')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, [], t('Delete')); $this->assertFalse((bool) NodeType::load('default'), 'Node type with machine default deleted.'); } diff --git a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php index 5785e0e3941..f9db9c2f294 100644 --- a/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php +++ b/core/modules/node/tests/src/Functional/NodeTypeTranslationTest.php @@ -176,9 +176,9 @@ class NodeTypeTranslationTest extends BrowserTestBase { // Try re-using the email field. $this->drupalGet("es/admin/structure/types/manage/$type/fields/add-field"); $this->drupalPostForm(NULL, ['existing_storage_name' => 'field_email', 'existing_storage_label' => 'Email'], 'Save and continue'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet("es/admin/structure/types/manage/$type/fields/node.$type.field_email/translate"); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText("The configuration objects have different language codes so they cannot be translated"); } diff --git a/core/modules/node/tests/src/Functional/PagePreviewTest.php b/core/modules/node/tests/src/Functional/PagePreviewTest.php index b34b800dd74..a58943b0a5c 100644 --- a/core/modules/node/tests/src/Functional/PagePreviewTest.php +++ b/core/modules/node/tests/src/Functional/PagePreviewTest.php @@ -340,7 +340,7 @@ class PagePreviewTest extends NodeTestBase { $this->clickLink(t('Back to content editing')); $this->drupalPostForm(NULL, [], t('Save')); $this->assertUrl($node->toUrl()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); /** @var \Drupal\Core\File\FileSystemInterface $file_system */ $file_system = \Drupal::service('file_system'); diff --git a/core/modules/node/tests/src/Functional/PageViewTest.php b/core/modules/node/tests/src/Functional/PageViewTest.php index 63ac3f73358..e7c302f7a97 100644 --- a/core/modules/node/tests/src/Functional/PageViewTest.php +++ b/core/modules/node/tests/src/Functional/PageViewTest.php @@ -26,7 +26,7 @@ class PageViewTest extends NodeTestBase { // Try to edit with anonymous user. $this->drupalGet("node/" . $node->id() . "/edit"); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create a user without permission to edit node. $web_user = $this->drupalCreateUser(['access content']); @@ -34,7 +34,7 @@ class PageViewTest extends NodeTestBase { // Attempt to access edit page. $this->drupalGet("node/" . $node->id() . "/edit"); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create user with permission to edit node. $web_user = $this->drupalCreateUser(['bypass node access']); @@ -42,7 +42,7 @@ class PageViewTest extends NodeTestBase { // Attempt to access edit page. $this->drupalGet("node/" . $node->id() . "/edit"); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/node/tests/src/Functional/Views/FrontPageTest.php b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php index 642387e2dae..0ec10e3c62a 100644 --- a/core/modules/node/tests/src/Functional/Views/FrontPageTest.php +++ b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php @@ -185,7 +185,7 @@ class FrontPageTest extends ViewTestBase { $this->drupalLogin($this->rootUser); // Test frontpage view. $this->drupalGet('node'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check that the frontpage view was rendered. $this->assertPattern('/class=".+view-frontpage/', 'Frontpage view was rendered'); } diff --git a/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php b/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php index 965e2b3b92b..359ba4a626e 100644 --- a/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeIntegrationTest.php @@ -41,10 +41,10 @@ class NodeIntegrationTest extends NodeTestBase { } $this->drupalGet('test-node-view'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet('test-node-view/all'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNids($all_nids); foreach ($types as $type) { diff --git a/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php b/core/modules/node/tests/src/Functional/Views/RevisionLinkTest.php index 38f23218215..55c4d0082b1 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); + $this->assertSession()->statusCodeEquals(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 460903512d2..7c0ca9985b8 100644 --- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php +++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php @@ -203,7 +203,7 @@ class PageCacheTest extends BrowserTestBase { // Ensure a conditional request returns 304 Not Modified. $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => $etag]); - $this->assertResponse(304); + $this->assertSession()->statusCodeEquals(304); // Ensure a conditional request with obsolete If-Modified-Since date // returns 304 Not Modified. @@ -211,7 +211,7 @@ class PageCacheTest extends BrowserTestBase { 'If-Modified-Since' => gmdate(DATE_RFC822, strtotime($last_modified)), 'If-None-Match' => $etag, ]); - $this->assertResponse(304); + $this->assertSession()->statusCodeEquals(304); // Ensure a conditional request with obsolete If-Modified-Since date // returns 304 Not Modified. @@ -219,13 +219,13 @@ class PageCacheTest extends BrowserTestBase { 'If-Modified-Since' => gmdate(DATE_RFC850, strtotime($last_modified)), 'If-None-Match' => $etag, ]); - $this->assertResponse(304); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); // Ensure a conditional request with If-Modified-Since newer than @@ -234,14 +234,14 @@ class PageCacheTest extends BrowserTestBase { 'If-Modified-Since' => gmdate(DateTimePlus::RFC7231, strtotime($last_modified) + 1), 'If-None-Match' => $etag, ]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(200); $this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Absence of Page was not cached.'); } @@ -371,11 +371,11 @@ class PageCacheTest extends BrowserTestBase { foreach ($tests as $code => $content_url) { // Anonymous user, without permissions. $this->drupalGet($content_url); - $this->assertResponse($code); + $this->assertSession()->statusCodeEquals($code); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); $this->assertCacheTag('4xx-response'); $this->drupalGet($content_url); - $this->assertResponse($code); + $this->assertSession()->statusCodeEquals($code); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); $entity_values = [ 'name' => $this->randomMachineName(), @@ -391,15 +391,15 @@ class PageCacheTest extends BrowserTestBase { $entity->save(); // Saving an entity clears 4xx cache tag. $this->drupalGet($content_url); - $this->assertResponse($code); + $this->assertSession()->statusCodeEquals($code); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); $this->drupalGet($content_url); - $this->assertResponse($code); + $this->assertSession()->statusCodeEquals($code); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); // Rebuilding the router should invalidate the 4xx cache tag. $this->container->get('router.builder')->rebuild(); $this->drupalGet($content_url); - $this->assertResponse($code); + $this->assertSession()->statusCodeEquals($code); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); // Ensure the 'expire' field on the cache entry uses cache_ttl_4xx. @@ -428,7 +428,7 @@ class PageCacheTest extends BrowserTestBase { // Getting the 404 page twice should still result in a cache miss. $this->drupalGet($content_url); $this->drupalGet($content_url); - $this->assertResponse($code); + $this->assertSession()->statusCodeEquals($code); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); } } @@ -579,7 +579,7 @@ class PageCacheTest extends BrowserTestBase { $config->save(); $this->drupalGet('/system-test/custom-cache-control'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSession()->responseHeaderEquals('Cache-Control', 'bar, private'); } diff --git a/core/modules/path/tests/src/Functional/PathAliasTest.php b/core/modules/path/tests/src/Functional/PathAliasTest.php index b4f6f8bed3a..99eaa4fee0b 100644 --- a/core/modules/path/tests/src/Functional/PathAliasTest.php +++ b/core/modules/path/tests/src/Functional/PathAliasTest.php @@ -83,15 +83,15 @@ class PathAliasTest extends PathTestBase { // Confirm that the alias works. $this->drupalGet($edit['alias[0][value]']); $this->assertText($node1->label(), 'Alias works.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm that the alias works in a case-insensitive way. $this->assertTrue(ctype_lower(ltrim($edit['alias[0][value]'], '/'))); $this->drupalGet($edit['alias[0][value]']); $this->assertText($node1->label(), 'Alias works lower case.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet(mb_strtoupper($edit['alias[0][value]'])); $this->assertText($node1->label(), 'Alias works upper case.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Change alias to one containing "exotic" characters. $pid = $this->getPID($edit['alias[0][value]']); @@ -118,13 +118,13 @@ class PathAliasTest extends PathTestBase { // Confirm that the alias works. $this->drupalGet(mb_strtoupper($edit['alias[0][value]'])); $this->assertText($node1->label(), 'Changed alias works.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->container->get('path_alias.manager')->cacheClear(); // Confirm that previous alias no longer works. $this->drupalGet($previous); $this->assertNoText($node1->label(), 'Previous alias no longer works.'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Create second test node. $node2 = $this->drupalCreateNode(); @@ -154,7 +154,7 @@ class PathAliasTest extends PathTestBase { // Confirm that the alias no longer works. $this->drupalGet($edit['alias[0][value]']); $this->assertNoText($node1->label(), 'Alias was successfully deleted.'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Create a really long alias. $edit = []; @@ -203,7 +203,7 @@ class PathAliasTest extends PathTestBase { $this->drupalGet($edit['alias[0][value]']); $this->assertNoText($node4->label(), 'Previous alias no longer works.'); $this->assertText($node2->label(), 'Alias works.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Update an existing alias to use a duplicate alias. $pid = $this->getPID($node3_alias); @@ -242,7 +242,7 @@ class PathAliasTest extends PathTestBase { // Confirm that the alias works. $this->drupalGet($edit['path[0][alias]']); $this->assertText($node1->label(), 'Alias works.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm the 'canonical' and 'shortlink' URLs. $elements = $this->xpath("//link[contains(@rel, 'canonical') and contains(@href, '" . $edit['path[0][alias]'] . "')]"); @@ -273,12 +273,12 @@ class PathAliasTest extends PathTestBase { // Confirm that the alias works. $this->drupalGet(mb_strtoupper($edit['path[0][alias]'])); $this->assertText($node1->label(), 'Changed alias works.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure that previous alias no longer works. $this->drupalGet($previous); $this->assertNoText($node1->label(), 'Previous alias no longer works.'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Create second test node. $node2 = $this->drupalCreateNode(); @@ -296,7 +296,7 @@ class PathAliasTest extends PathTestBase { // Confirm that the alias no longer works. $this->drupalGet($edit['path[0][alias]']); $this->assertNoText($node1->label(), 'Alias was successfully deleted.'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Create third test node. $node3 = $this->drupalCreateNode(); @@ -308,7 +308,7 @@ class PathAliasTest extends PathTestBase { // Confirm that the alias was converted to a relative path. $this->drupalGet(trim($edit['path[0][alias]'], '/')); $this->assertText($node3->label(), 'Alias became relative.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Create fourth test node. $node4 = $this->drupalCreateNode(); @@ -320,7 +320,7 @@ class PathAliasTest extends PathTestBase { // Confirm that the alias was converted to a relative path. $this->drupalGet(trim($edit['path[0][alias]'], '/')); $this->assertText($node4->label(), 'Alias trimmed trailing slash.'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Create fifth test node. $node5 = $this->drupalCreateNode(); @@ -360,7 +360,7 @@ class PathAliasTest extends PathTestBase { $link_href = $link_xpath[0]->getAttribute('href'); $this->assertEquals($link_href, base_path() . $alias); $this->clickLink($node6->getTitle()); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** diff --git a/core/modules/path/tests/src/Functional/PathLanguageTest.php b/core/modules/path/tests/src/Functional/PathLanguageTest.php index de4032763fc..0ca320166d5 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); + $this->assertSession()->statusCodeEquals(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 c2bcd761b62..e1133669f1d 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(404); } } diff --git a/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php b/core/modules/path_alias/tests/src/Functional/UrlAlterFunctionalTest.php index d7c48a77bda..9fa1502324a 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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/ResponsiveImageAdminUITest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php index 23d285d319b..5a56b0c03b2 100644 --- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php +++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php @@ -61,7 +61,7 @@ class ResponsiveImageAdminUITest extends BrowserTestBase { $this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save')); // Check if the new group is created. - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/config/media/responsive-image-style'); $this->assertNoText('There are no responsive image styles yet.'); $this->assertText('Style One'); diff --git a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php index 22904081f56..214e5b111aa 100644 --- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php +++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageFieldDisplayTest.php @@ -271,7 +271,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase { // Log out and ensure the file cannot be accessed. $this->drupalLogout(); $this->drupalGet(file_create_url($image_uri)); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Log in again. $this->drupalLogin($this->adminUser); @@ -337,7 +337,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase { // Log out and ensure the file cannot be accessed. $this->drupalLogout(); $this->drupalGet($large_style->buildUrl($image_uri)); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(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 bd1908bcb31..1ed9aebc00e 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(406); } /** diff --git a/core/modules/rest/tests/src/Functional/Views/ExcludedFieldTokenTest.php b/core/modules/rest/tests/src/Functional/Views/ExcludedFieldTokenTest.php index d4df0e93ba2..32e28d6397c 100644 --- a/core/modules/rest/tests/src/Functional/Views/ExcludedFieldTokenTest.php +++ b/core/modules/rest/tests/src/Functional/Views/ExcludedFieldTokenTest.php @@ -72,7 +72,7 @@ class ExcludedFieldTokenTest extends ViewTestBase { */ public function testExcludedTitleTokenDisplay() { $actual_json = $this->drupalGet($this->view->getPath(), ['query' => ['_format' => 'json']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $expected = [ ['nothing' => 'Article test 10'], diff --git a/core/modules/rest/tests/src/Functional/Views/FieldCounterTest.php b/core/modules/rest/tests/src/Functional/Views/FieldCounterTest.php index 80a3952b687..ddceefd82f7 100644 --- a/core/modules/rest/tests/src/Functional/Views/FieldCounterTest.php +++ b/core/modules/rest/tests/src/Functional/Views/FieldCounterTest.php @@ -72,7 +72,7 @@ class FieldCounterTest extends ViewTestBase { */ public function testExcludedTitleTokenDisplay() { $actual_json = $this->drupalGet($this->view->getPath(), ['query' => ['_format' => 'json']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $expected = [ ['counter' => '1'], diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php index 154d9ccd94b..78a39324f8d 100644 --- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php +++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerTest.php @@ -94,13 +94,13 @@ class StyleSerializerTest extends ViewTestBase { public function testRestViewsAuthentication() { // Assume the view is hidden behind a permission. $this->drupalGet('test/serialize/auth_with_perm', ['query' => ['_format' => 'json']]); - $this->assertResponse(401); + $this->assertSession()->statusCodeEquals(401); // Not even logging in would make it possible to see the view, because then // we are denied based on authentication method (cookie). $this->drupalLogin($this->adminUser); $this->drupalGet('test/serialize/auth_with_perm', ['query' => ['_format' => 'json']]); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalLogout(); // But if we use the basic auth authentication strategy, we should be able @@ -116,7 +116,7 @@ class StyleSerializerTest extends ViewTestBase { // Ensure that any changes to variables in the other thread are picked up. $this->refreshVariables(); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -129,7 +129,7 @@ class StyleSerializerTest extends ViewTestBase { $this->executeView($view); $actual_json = $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertCacheTags($view->getCacheTags()); $this->assertCacheContexts(['languages:language_interface', 'theme', 'request_format']); // @todo Due to https://www.drupal.org/node/2352009 we can't yet test the @@ -160,7 +160,7 @@ class StyleSerializerTest extends ViewTestBase { // Test a 403 callback. $this->drupalGet('test/serialize/denied', ['query' => ['_format' => 'json']]); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Test the entity rows. $view = Views::getView('test_serializer_display_entity'); @@ -178,7 +178,7 @@ class StyleSerializerTest extends ViewTestBase { $expected = $serializer->serialize($entities, 'json'); $actual_json = $this->drupalGet('test/serialize/entity', ['query' => ['_format' => 'json']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertIdentical($actual_json, $expected, 'The expected JSON output was found.'); $expected_cache_tags = $view->getCacheTags(); $expected_cache_tags[] = 'entity_test_list'; @@ -238,19 +238,19 @@ class StyleSerializerTest extends ViewTestBase { public function testSharedPagePath() { // Test with no format as well as html explicitly. $this->drupalGet('test/serialize/shared'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSession()->responseHeaderEquals('content-type', 'text/html; charset=UTF-8'); $this->drupalGet('test/serialize/shared', ['query' => ['_format' => 'html']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSession()->responseHeaderEquals('content-type', 'text/html; charset=UTF-8'); $this->drupalGet('test/serialize/shared', ['query' => ['_format' => 'json']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSession()->responseHeaderEquals('content-type', 'application/json'); $this->drupalGet('test/serialize/shared', ['query' => ['_format' => 'xml']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSession()->responseHeaderEquals('content-type', 'text/xml; charset=UTF-8'); } @@ -267,7 +267,7 @@ class StyleSerializerTest extends ViewTestBase { $this->drupalGet('test/serialize/entity', ['query' => ['_format' => 'json']]); // Verify that the endpoint is unavailable for anonymous users. - $this->assertResponse(503); + $this->assertSession()->statusCodeEquals(503); } /** @@ -386,7 +386,7 @@ class StyleSerializerTest extends ViewTestBase { // Ensure a request with no format returns 406 Not Acceptable. $this->drupalGet('test/serialize/field'); $this->assertSession()->responseHeaderEquals('content-type', 'text/html; charset=UTF-8'); - $this->assertResponse(406); + $this->assertSession()->statusCodeEquals(406); // Select only 'xml' as an accepted format. $this->drupalPostForm($style_options, ['style_options[formats][xml]' => 'xml'], t('Apply')); @@ -395,11 +395,11 @@ class StyleSerializerTest extends ViewTestBase { // Ensure a request for JSON returns 406 Not Acceptable. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]); $this->assertSession()->responseHeaderEquals('content-type', 'application/json'); - $this->assertResponse(406); + $this->assertSession()->statusCodeEquals(406); // Ensure a request for XML returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]); $this->assertSession()->responseHeaderEquals('content-type', 'text/xml; charset=UTF-8'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Add 'json' as an accepted format, so we have multiple. $this->drupalPostForm($style_options, ['style_options[formats][json]' => 'json'], t('Apply')); @@ -408,22 +408,22 @@ 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->assertSession()->responseHeaderEquals('content-type', 'text/html; charset=UTF-8'); - $this->assertResponse(406); + $this->assertSession()->statusCodeEquals(406); // Ensure a request for HTML returns 406 Not Acceptable. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'html']]); $this->assertSession()->responseHeaderEquals('content-type', 'text/html; charset=UTF-8'); - $this->assertResponse(406); + $this->assertSession()->statusCodeEquals(406); // Ensure a request for JSON returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]); $this->assertSession()->responseHeaderEquals('content-type', 'application/json'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Ensure a request XML returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]); $this->assertSession()->responseHeaderEquals('content-type', 'text/xml; charset=UTF-8'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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')); @@ -431,17 +431,17 @@ class StyleSerializerTest extends ViewTestBase { // Ensure a request for JSON returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]); $this->assertSession()->responseHeaderEquals('content-type', 'application/json'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Ensure a request for XML returns 200 OK. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]); $this->assertSession()->responseHeaderEquals('content-type', 'text/xml; charset=UTF-8'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Should return a 406 for HTML still. $this->drupalGet('test/serialize/field', ['query' => ['_format' => 'html']]); $this->assertSession()->responseHeaderEquals('content-type', 'text/html; charset=UTF-8'); - $this->assertResponse(406); + $this->assertSession()->statusCodeEquals(406); } /** @@ -636,7 +636,7 @@ class StyleSerializerTest extends ViewTestBase { $this->drupalLogin($this->adminUser); // Click the "Update preview button". $this->drupalPostForm('admin/structure/views/view/test_serializer_display_field/edit/rest_export_1', $edit = [], t('Update preview')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check if we receive the expected result. $result = $this->xpath('//div[@id="views-live-preview"]/pre'); $json_preview = $result[0]->getText(); diff --git a/core/modules/search/tests/src/Functional/SearchBlockTest.php b/core/modules/search/tests/src/Functional/SearchBlockTest.php index d53f6f0b7d9..f20d4f52129 100644 --- a/core/modules/search/tests/src/Functional/SearchBlockTest.php +++ b/core/modules/search/tests/src/Functional/SearchBlockTest.php @@ -69,14 +69,14 @@ class SearchBlockTest extends BrowserTestBase { // Test a normal search via the block form, from the front page. $terms = ['keys' => 'test']; $this->drupalPostForm('', $terms, t('Search')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Your search yielded no results'); // Test a search from the block on a 404 page. $this->drupalGet('foo'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalPostForm(NULL, $terms, t('Search')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Your search yielded no results'); $visibility = $block->getVisibility(); @@ -84,7 +84,7 @@ class SearchBlockTest extends BrowserTestBase { $block->setVisibilityConfig('request_path', $visibility['request_path']); $this->drupalPostForm('', $terms, t('Search')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Your search yielded no results'); // Confirm that the form submits to the default search page. @@ -100,7 +100,7 @@ class SearchBlockTest extends BrowserTestBase { // Test an empty search via the block form, from the front page. $terms = ['keys' => '']; $this->drupalPostForm('', $terms, t('Search')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Please enter some keywords'); // Confirm that the user is redirected to the search page, when form is diff --git a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php index 38133f48fd0..92463e3b15e 100644 --- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php @@ -173,7 +173,7 @@ class SearchConfigSettingsFormTest extends BrowserTestBase { // Run a search from the correct search URL. $info = $plugin_info[$entity_id]; $this->drupalGet('search/' . $entity->getPath(), ['query' => ['keys' => $info['keys']]]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText('no results', $entity->label() . ' search found results'); $this->assertText($info['text'], 'Correct search text found'); @@ -195,7 +195,7 @@ class SearchConfigSettingsFormTest extends BrowserTestBase { // Try an invalid search path, which should 404. $this->drupalGet('search/not_a_plugin_path'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $entity->disable()->save(); } @@ -313,14 +313,14 @@ class SearchConfigSettingsFormTest extends BrowserTestBase { // Disable the first search page. $this->clickLink(t('Disable')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoLink(t('Disable')); $this->verifySearchPageOperations($first_id, TRUE, TRUE, FALSE, TRUE); $this->verifySearchPageOperations($second_id, TRUE, FALSE, FALSE, FALSE); // Enable the first search page. $this->clickLink(t('Enable')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->verifySearchPageOperations($first_id, TRUE, TRUE, TRUE, FALSE); $this->verifySearchPageOperations($second_id, TRUE, FALSE, FALSE, FALSE); @@ -338,11 +338,11 @@ class SearchConfigSettingsFormTest extends BrowserTestBase { public function testRouteProtection() { // Ensure that the enable and disable routes are protected. $this->drupalGet('admin/config/search/pages/manage/node_search/enable'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('admin/config/search/pages/manage/node_search/disable'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('admin/config/search/pages/manage/node_search/set-default'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** diff --git a/core/modules/search/tests/src/Functional/SearchPageTextTest.php b/core/modules/search/tests/src/Functional/SearchPageTextTest.php index f33f196bea1..dde3ac94969 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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 814f65790f6..2a30d9be5b8 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php @@ -80,7 +80,7 @@ class ShortcutLinksTest extends ShortcutTestBase { 'link[0][uri]' => $test_path, ]; $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Added a shortcut for @title.', ['@title' => $title])); $saved_set = ShortcutSet::load($set->id()); $paths = $this->getShortcutInformation($saved_set, 'link'); @@ -113,7 +113,7 @@ class ShortcutLinksTest extends ShortcutTestBase { 'link[0][uri]' => '/admin', ]; $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t("The path '@link_path' is inaccessible.", ['@link_path' => '/admin'])); $form_data = [ @@ -136,7 +136,7 @@ class ShortcutLinksTest extends ShortcutTestBase { 'link[0][uri]' => '/admin', ]; $this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $edit['id'] . '/add-link', $form_data, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -269,14 +269,14 @@ class ShortcutLinksTest extends ShortcutTestBase { public function testShortcutLinkChangeRoute() { $this->drupalLogin($this->rootUser); $this->drupalGet('admin/content'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Disable the view. View::load('content')->disable()->save(); /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */ $router_builder = \Drupal::service('router.builder'); $router_builder->rebuildIfNeeded(); $this->drupalGet('admin/content'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -407,11 +407,11 @@ class ShortcutLinksTest extends ShortcutTestBase { // Verify that set administration pages are inaccessible without the // 'access shortcuts' permission. $this->drupalGet('admin/config/user-interface/shortcut/manage/default/customize'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('admin/config/user-interface/shortcut/manage/default'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('user/' . $noaccess_user->id() . '/shortcuts'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php index ee53a5057e5..1123075e5ab 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php @@ -111,7 +111,7 @@ class ShortcutSetsTest extends ShortcutTestBase { // Attempt to switch the default shortcut set to the newly created shortcut // set. $this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', ['set' => $new_set->id()], t('Change set')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $current_set = shortcut_current_displayed_set($this->adminUser); $this->assertTrue($new_set->id() == $current_set->id(), 'Successfully switched own shortcut set.'); } @@ -198,7 +198,7 @@ class ShortcutSetsTest extends ShortcutTestBase { */ public function testShortcutSetDeleteDefault() { $this->drupalGet('admin/config/user-interface/shortcut/manage/default/delete'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** diff --git a/core/modules/statistics/tests/src/Functional/Views/IntegrationTest.php b/core/modules/statistics/tests/src/Functional/Views/IntegrationTest.php index 82b26162c49..ea53cda9e58 100644 --- a/core/modules/statistics/tests/src/Functional/Views/IntegrationTest.php +++ b/core/modules/statistics/tests/src/Functional/Views/IntegrationTest.php @@ -92,7 +92,7 @@ class IntegrationTest extends ViewTestBase { $this->drupalLogout(); $this->drupalLogin($this->deniedUser); $this->drupalGet('test_statistics_integration'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextNotContains('Total views:'); $this->assertSession()->pageTextNotContains('Views today:'); diff --git a/core/modules/system/tests/src/Functional/Common/EarlyRenderingControllerTest.php b/core/modules/system/tests/src/Functional/Common/EarlyRenderingControllerTest.php index 30e1ef992be..a31d2cc5b05 100644 --- a/core/modules/system/tests/src/Functional/Common/EarlyRenderingControllerTest.php +++ b/core/modules/system/tests/src/Functional/Common/EarlyRenderingControllerTest.php @@ -33,11 +33,11 @@ class EarlyRenderingControllerTest extends BrowserTestBase { public function testEarlyRendering() { // Render array: non-early & early. $this->drupalGet(Url::fromRoute('early_rendering_controller_test.render_array')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Hello world!'); $this->assertCacheTag('foo'); $this->drupalGet(Url::fromRoute('early_rendering_controller_test.render_array.early')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Hello world!'); $this->assertCacheTag('foo'); @@ -45,66 +45,66 @@ class EarlyRenderingControllerTest extends BrowserTestBase { // @todo Add cache tags assertion when AjaxResponse is made cacheable in // https://www.drupal.org/node/956186. $this->drupalGet(Url::fromRoute('early_rendering_controller_test.ajax_response')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Hello world!'); $this->drupalGet(Url::fromRoute('early_rendering_controller_test.ajax_response.early')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Hello world!'); // Basic Response object: non-early & early. $this->drupalGet(Url::fromRoute('early_rendering_controller_test.response')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Hello world!'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo'); $this->drupalGet(Url::fromRoute('early_rendering_controller_test.response.early')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Hello world!'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo'); // Response object with attachments: non-early & early. $this->drupalGet(Url::fromRoute('early_rendering_controller_test.response-with-attachments')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Hello world!'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo'); $this->drupalGet(Url::fromRoute('early_rendering_controller_test.response-with-attachments.early')); - $this->assertResponse(500); + $this->assertSession()->statusCodeEquals(500); $this->assertRaw('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\AttachmentsTestResponse.'); // Cacheable Response object: non-early & early. $this->drupalGet(Url::fromRoute('early_rendering_controller_test.cacheable-response')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('Hello world!'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo'); $this->drupalGet(Url::fromRoute('early_rendering_controller_test.cacheable-response.early')); - $this->assertResponse(500); + $this->assertSession()->statusCodeEquals(500); $this->assertRaw('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\CacheableTestResponse.'); // Basic domain object: non-early & early. $this->drupalGet(Url::fromRoute('early_rendering_controller_test.domain-object')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('TestDomainObject'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo'); $this->drupalGet(Url::fromRoute('early_rendering_controller_test.domain-object.early')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('TestDomainObject'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo'); // Basic domain object with attachments: non-early & early. $this->drupalGet(Url::fromRoute('early_rendering_controller_test.domain-object-with-attachments')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('AttachmentsTestDomainObject'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo'); $this->drupalGet(Url::fromRoute('early_rendering_controller_test.domain-object-with-attachments.early')); - $this->assertResponse(500); + $this->assertSession()->statusCodeEquals(500); $this->assertRaw('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\AttachmentsTestDomainObject.'); // Cacheable Response object: non-early & early. $this->drupalGet(Url::fromRoute('early_rendering_controller_test.cacheable-domain-object')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('CacheableTestDomainObject'); $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'foo'); $this->drupalGet(Url::fromRoute('early_rendering_controller_test.cacheable-domain-object.early')); - $this->assertResponse(500); + $this->assertSession()->statusCodeEquals(500); $this->assertRaw('The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\early_rendering_controller_test\CacheableTestDomainObject.'); // The exceptions are expected. Do not interpret them as a test failure. diff --git a/core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php b/core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php index 5cfdeacef63..1ccb3eddd6d 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php @@ -36,7 +36,7 @@ class EntityAddUITest extends BrowserTestBase { // Users without create access for bundles do not have access to the add // page if there are no bundles. $this->drupalGet('/entity_test_with_bundle/add'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $bundle_admin_user = $this->drupalCreateUser([ 'administer entity_test_with_bundle content', @@ -97,12 +97,12 @@ class EntityAddUITest extends BrowserTestBase { $this->assertLink('Test2 label'); $this->assertNoLink('Test3 label'); $this->clickLink(t('Test label')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Without any permissions, access must be denied. $this->drupalLogout(); $this->drupalGet('/entity_test_with_bundle/add'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create a new user that has bundle create permissions. $user = $this->drupalCreateUser([ diff --git a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php index ac73ebcfa64..79be1dad53d 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php @@ -82,7 +82,7 @@ class EntityViewControllerTest extends BrowserTestBase { // As entity_test IDs must be integers, make sure requests for non-integer // IDs return a page not found error. $this->drupalGet('entity_test/invalid'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** diff --git a/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php index f6b71ad4b73..83c3bf3faa1 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php @@ -124,7 +124,7 @@ abstract class EntityWithUriCacheTagsTestBase extends EntityCacheTagsTestBase { // Verify that after deleting the entity, there is a cache miss. $this->entity->delete(); $this->verifyPageCache($entity_url, 'MISS'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** diff --git a/core/modules/system/tests/src/Functional/Form/RedirectTest.php b/core/modules/system/tests/src/Functional/Form/RedirectTest.php index 57ee31867e5..a87e1acf6c7 100644 --- a/core/modules/system/tests/src/Functional/Form/RedirectTest.php +++ b/core/modules/system/tests/src/Functional/Form/RedirectTest.php @@ -94,17 +94,17 @@ class RedirectTest extends BrowserTestBase { // at the right URL. $expected = Url::fromRoute('form_test.route1', [], ['query' => ['test1' => 'test2'], 'absolute' => TRUE])->toString(); $this->drupalGet('foo'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalPostForm(NULL, [], t('Submit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertUrl($expected, [], 'Redirected to correct URL/query.'); // Visit the block admin page (403 page) and submit the form. Verify it // ends up at the right URL. $this->drupalGet('admin/structure/block'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalPostForm(NULL, [], t('Submit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertUrl($expected, [], 'Redirected to correct URL/query.'); } diff --git a/core/modules/system/tests/src/Functional/Form/ResponseTest.php b/core/modules/system/tests/src/Functional/Form/ResponseTest.php index bbeac92cdc1..1a08890be48 100644 --- a/core/modules/system/tests/src/Functional/Form/ResponseTest.php +++ b/core/modules/system/tests/src/Functional/Form/ResponseTest.php @@ -34,7 +34,7 @@ class ResponseTest extends BrowserTestBase { ]; $this->drupalPostForm('form-test/response', $edit, 'Submit'); $content = Json::decode($this->getSession()->getPage()->getContent()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertIdentical($edit['content'], $content, 'Response content matches'); $this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Response-Event'), 'Response handled by kernel response subscriber'); $this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Stack-Middleware'), 'Response handled by kernel middleware'); @@ -45,7 +45,7 @@ class ResponseTest extends BrowserTestBase { ]; $this->drupalPostForm('form-test/response', $edit, 'Submit'); $content = Json::decode($this->getSession()->getPage()->getContent()); - $this->assertResponse(418); + $this->assertSession()->statusCodeEquals(418); $this->assertIdentical($edit['content'], $content, 'Response content matches'); $this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Response-Event'), 'Response handled by kernel response subscriber'); $this->assertIdentical('invoked', $this->drupalGetHeader('X-Form-Test-Stack-Middleware'), 'Response handled by kernel middleware'); diff --git a/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php b/core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php index 4d31dfb427d..e3d55f8fcf6 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); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(t('You WIN!'), 'Found the success message.'); } diff --git a/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php b/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php index 62fd82dd809..a073f513af1 100644 --- a/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php +++ b/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php @@ -45,22 +45,22 @@ class MenuAccessTest extends BrowserTestBase { $this->assertLink('Test custom route access check'); // Page is still accessible but there should be no menu link. $this->drupalGet('menu_test_access_check_session'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoLink('Test custom route access check'); // Test that page is no more accessible. $this->drupalGet('menu_test_access_check_session'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Check for access to a restricted local task from a default local task. $this->drupalGet('foo/asdf'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('foo/asdf'); $this->assertLinkByHref('foo/asdf/b'); $this->assertNoLinkByHref('foo/asdf/c'); // Attempt to access a restricted local task. $this->drupalGet('foo/asdf/c'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $elements = $this->xpath('//ul[@class=:class]/li/a[@href=:href]', [ ':class' => 'tabs primary', ':href' => Url::fromRoute('menu_test.router_test1', ['bar' => 'asdf'])->toString(), diff --git a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php index 37645b1f437..47077f1d7e0 100644 --- a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php +++ b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php @@ -165,11 +165,11 @@ class MenuRouterTest extends BrowserTestBase { */ protected function doTestMenuOptionalPlaceholders() { $this->drupalGet('menu-test/optional'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Sometimes there is no placeholder.'); $this->drupalGet('menu-test/optional/foobar'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText("Sometimes there is a placeholder: 'foobar'."); } diff --git a/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php b/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php index db82fe25f84..cb855e34a90 100644 --- a/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php +++ b/core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php @@ -40,7 +40,7 @@ class ClassLoaderTest extends BrowserTestBase { // Check twice to test an unprimed and primed system_list() cache. for ($i = 0; $i < 2; $i++) { $this->drupalGet('module-test/class-loading'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($this->expected, 'Autoloader loads classes from an enabled module.'); } } @@ -57,7 +57,7 @@ class ClassLoaderTest extends BrowserTestBase { // Check twice to test an unprimed and primed system_list() cache. for ($i = 0; $i < 2; $i++) { $this->drupalGet('module-test/class-loading'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText($this->expected, 'Autoloader does not load classes from a disabled module.'); } } @@ -77,7 +77,7 @@ class ClassLoaderTest extends BrowserTestBase { // Check twice to test an unprimed and primed system_list() cache. for ($i = 0; $i < 2; $i++) { $this->drupalGet('module-test/class-loading'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoText($this->expected, 'Autoloader does not load classes from a disabled module.'); } } diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index 6757c73ff04..f2279f26aa9 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -354,7 +354,7 @@ class InstallUninstallTest extends ModuleTestBase { */ protected function assertHelp($module, $name) { $this->drupalGet('admin/help/' . $module); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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 fff122b72f8..19fa712c059 100644 --- a/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php @@ -153,7 +153,7 @@ class PrepareUninstallTest extends BrowserTestBase { // Ensure a 404 is returned when accessing a non-existent entity type. $this->drupalGet('admin/modules/uninstall/entity/node'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(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/Render/HtmlResponseAttachmentsTest.php b/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php index 11438ec1d4a..fe7c1d50c63 100644 --- a/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php +++ b/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php @@ -29,11 +29,11 @@ class HtmlResponseAttachmentsTest extends BrowserTestBase { public function testAttachments() { // Test ['#attached']['http_header] = ['Status', $code]. $this->drupalGet('/render_attached_test/teapot'); - $this->assertResponse(418); + $this->assertSession()->statusCodeEquals(418); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS'); // Repeat for the cache. $this->drupalGet('/render_attached_test/teapot'); - $this->assertResponse(418); + $this->assertSession()->statusCodeEquals(418); $this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT'); // Test ['#attached']['http_header'] with various replacement rules. @@ -83,7 +83,7 @@ class HtmlResponseAttachmentsTest extends BrowserTestBase { // Test that all our attached items are present. $this->assertFeed(); $this->assertHead(); - $this->assertResponse(418); + $this->assertSession()->statusCodeEquals(418); $this->assertTeapotHeaders(); // Reload the page, to test caching. diff --git a/core/modules/system/tests/src/Functional/Routing/DestinationTest.php b/core/modules/system/tests/src/Functional/Routing/DestinationTest.php index 22a369dd54e..ba10d839b23 100644 --- a/core/modules/system/tests/src/Functional/Routing/DestinationTest.php +++ b/core/modules/system/tests/src/Functional/Routing/DestinationTest.php @@ -81,7 +81,7 @@ class DestinationTest extends BrowserTestBase { // external URLs. \Drupal::configFactory()->getEditable('system.site')->set('page.404', '/system-test/get-destination')->save(); $this->drupalGet('http://example.com', ['external' => FALSE]); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->assertIdentical(Url::fromRoute('')->toString(), $session->getPage()->getContent(), 'External URL is not allowed on 404 pages.'); } diff --git a/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php b/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php index 69922ae1996..ebf5b3ac9ed 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php @@ -29,16 +29,16 @@ class RouterPermissionTest extends BrowserTestBase { public function testPermissionAccess() { // Ensure 403 Access Denied for a route without permission. $this->drupalGet('router_test/test7'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Ensure 403 Access Denied by default if no access specified. $this->drupalGet('router_test/test8'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $user = $this->drupalCreateUser(['access test7']); $this->drupalLogin($user); $this->drupalGet('router_test/test7'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoRaw('Access denied'); $this->assertRaw('test7text', 'The correct string was returned because the route was successful.'); } diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php index a162f18834c..b97ab7787f1 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php @@ -118,22 +118,22 @@ class RouterTest extends BrowserTestBase { // routes are declared. // @see \Drupal\Core\Routing\RouteProvider::getRoutesByPath() $this->drupalGet('router-test/duplicate-path2'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('router_test.two_duplicate1'); // Tests three routes with same the path. One of the routes the path has a // different case. $this->drupalGet('router-test/case-sensitive-duplicate-path3'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('router_test.case_sensitive_duplicate1'); // While case-insensitive matching works, exact matches are preferred. $this->drupalGet('router-test/case-sensitive-Duplicate-PATH3'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('router_test.case_sensitive_duplicate2'); // Test that case-insensitive matching works, falling back to the first // route defined. $this->drupalGet('router-test/case-sensitive-Duplicate-Path3'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('router_test.case_sensitive_duplicate1'); } @@ -145,7 +145,7 @@ class RouterTest extends BrowserTestBase { $values = ["0", $this->randomMachineName()]; foreach ($values as $value) { $this->drupalGet('router_test/test3/' . $value); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw($value, 'The correct string was returned because the route was successful.'); } @@ -163,7 +163,7 @@ class RouterTest extends BrowserTestBase { */ public function testControllerPlaceholdersDefaultValues() { $this->drupalGet('router_test/test4'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('narf', 'The correct string was returned because the route was successful.'); // Confirm that the page wrapping is being added, so we're not getting a @@ -180,7 +180,7 @@ class RouterTest extends BrowserTestBase { */ public function testControllerPlaceholdersDefaultValuesProvided() { $this->drupalGet('router_test/test4/barf'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('barf', 'The correct string was returned because the route was successful.'); // Confirm that the page wrapping is being added, so we're not getting a @@ -200,7 +200,7 @@ class RouterTest extends BrowserTestBase { public function testDynamicRoutes() { // Test the altered route. $this->drupalGet('router_test/test6'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw('test5', 'The correct string was returned because the route was successful.'); } @@ -236,12 +236,12 @@ class RouterTest extends BrowserTestBase { */ public function testRouterMatching() { $this->drupalGet('router_test/test14/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('User route "entity.user.canonical" was matched.'); // Try to match a route for a non-existent user. $this->drupalGet('router_test/test14/2'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Route not matched.'); // Check that very long paths don't cause an error. @@ -250,7 +250,7 @@ class RouterTest extends BrowserTestBase { for ($i = 0; $i < 10; $i++) { $path .= $suffix; $this->drupalGet($path); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } } @@ -259,7 +259,7 @@ class RouterTest extends BrowserTestBase { */ public function testRouterResponsePsr7() { $this->drupalGet('/router_test/test23'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('test23'); } diff --git a/core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php b/core/modules/system/tests/src/Functional/Session/SessionAuthenticationTest.php index 5b2ab797a5d..78166c6a13a 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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/SessionHttpsTest.php b/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php index 7cad08c69df..c235e4ca432 100644 --- a/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php +++ b/core/modules/system/tests/src/Functional/Session/SessionHttpsTest.php @@ -88,17 +88,17 @@ class SessionHttpsTest extends BrowserTestBase { // Verify that user is logged in on secure URL. $this->drupalGet($this->httpsUrl('admin/config')); $this->assertText(t('Configuration')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify that user is not logged in on non-secure URL. $this->drupalGet($this->httpUrl('admin/config')); $this->assertNoText(t('Configuration')); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Verify that empty SID cannot be used on the non-secure site. $browser_kit_cookie_jar->set(Cookie::fromString($this->insecureSessionName . '=', $this->baseUrl)); $this->drupalGet($this->httpUrl('admin/config')); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Remove the secure session name from the cookie jar before logging in via // HTTP on HTTPS environments. @@ -108,13 +108,13 @@ class SessionHttpsTest extends BrowserTestBase { // which creates a mock HTTP request on HTTPS test environments. $this->loginHttp($user); $this->drupalGet($this->httpUrl('admin/config')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertSessionIds($this->getSession()->getCookie($this->insecureSessionName), 'Session has the correct SID and an empty secure SID.'); // Verify that empty secure SID cannot be used on the secure site. $browser_kit_cookie_jar->set(Cookie::fromString($this->secureSessionName . '=', $this->baseUrl)); $this->drupalGet($this->httpsUrl('admin/config')); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** @@ -160,7 +160,7 @@ class SessionHttpsTest extends BrowserTestBase { // Follow the location header. $path = $this->getPathFromLocationHeader($response, FALSE); $this->drupalGet($this->httpUrl($path)); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -206,7 +206,7 @@ class SessionHttpsTest extends BrowserTestBase { // Follow the location header. $path = $this->getPathFromLocationHeader($response, TRUE); $this->drupalGet($this->httpsUrl($path)); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/system/tests/src/Functional/Session/SessionTest.php b/core/modules/system/tests/src/Functional/Session/SessionTest.php index ece2d374b90..8388ad5a91c 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); + $this->assertSession()->statusCodeEquals(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,7 +292,7 @@ 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); + $this->assertSession()->statusCodeEquals(403); } /** @@ -303,31 +303,31 @@ class SessionTest extends BrowserTestBase { $this->drupalGet('/session-test/has-bag-flag'); $this->assertSessionCookie(FALSE); $this->assertSessionEmpty(TRUE); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Set the flag. $this->drupalGet('/session-test/set-bag-flag'); $this->assertSessionCookie(TRUE); $this->assertSessionEmpty(TRUE); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Ensure the flag is set. $this->drupalGet('/session-test/has-bag-flag'); $this->assertSessionCookie(TRUE); $this->assertSessionEmpty(FALSE); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Clear the flag. $this->drupalGet('/session-test/clear-bag-flag'); $this->assertSessionCookie(FALSE); $this->assertSessionEmpty(FALSE); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Ensure the flag is absent again. $this->drupalGet('/session-test/has-bag-flag'); $this->assertSessionCookie(FALSE); $this->assertSessionEmpty(TRUE); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -340,7 +340,7 @@ class SessionTest extends BrowserTestBase { // Change cookie file for user. $this->drupalGet('session-test/get'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php index f183962eb62..79146584be0 100644 --- a/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php +++ b/core/modules/system/tests/src/Functional/System/AccessDeniedTest.php @@ -47,7 +47,7 @@ class AccessDeniedTest extends BrowserTestBase { public function testAccessDenied() { $this->drupalGet('admin'); $this->assertText(t('Access denied'), 'Found the default 403 page'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Ensure that users without permission are denied access and have the // correct path information in drupalSettings. @@ -94,7 +94,7 @@ class AccessDeniedTest extends BrowserTestBase { $this->drupalLogout(); $this->drupalGet('admin'); $this->assertText(t('Access denied'), 'Found the default 403 page'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertText(t('Username'), 'Blocks are shown on the default 403 page'); // Log back in, set the custom 403 page to /user/login and remove the block @@ -124,14 +124,14 @@ class AccessDeniedTest extends BrowserTestBase { $this->drupalGet('/system-test/always-denied'); $this->assertNoText('Admin-only 4xx response'); $this->assertText('You are not authorized to access this page.'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Verify the access cacheability metadata for custom 403 is bubbled. $this->assertCacheContext('user.roles'); $this->drupalLogin($this->adminUser); $this->drupalGet('/system-test/always-denied'); $this->assertText('Admin-only 4xx response'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Verify the access cacheability metadata for custom 403 is bubbled. $this->assertCacheContext('user.roles'); } diff --git a/core/modules/system/tests/src/Functional/System/AdminTest.php b/core/modules/system/tests/src/Functional/System/AdminTest.php index bbd1d7b3211..c79fc26d052 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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/CronRunTest.php b/core/modules/system/tests/src/Functional/System/CronRunTest.php index 6e3e9be9e61..c291b0fe845 100644 --- a/core/modules/system/tests/src/Functional/System/CronRunTest.php +++ b/core/modules/system/tests/src/Functional/System/CronRunTest.php @@ -36,17 +36,17 @@ class CronRunTest extends BrowserTestBase { public function testCronRun() { // Run cron anonymously without any cron key. $this->drupalGet('cron'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Run cron anonymously with a random cron key. $key = $this->randomMachineName(16); $this->drupalGet('cron/' . $key); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Run cron anonymously with the valid cron key. $key = \Drupal::state()->get('system.cron_key'); $this->drupalGet('cron/' . $key); - $this->assertResponse(204); + $this->assertSession()->statusCodeEquals(204); } /** @@ -140,11 +140,11 @@ class CronRunTest extends BrowserTestBase { $this->drupalLogin($admin_user); $this->drupalGet('admin/reports/status/run-cron'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('admin/reports/status'); $this->clickLink(t('Run cron')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('Cron ran successfully.')); } diff --git a/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php b/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php index d09d8d13480..69fb3c28f39 100644 --- a/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php +++ b/core/modules/system/tests/src/Functional/System/DateFormatsLockedTest.php @@ -33,15 +33,15 @@ class DateFormatsLockedTest extends BrowserTestBase { // Locked date formats are not editable. $this->drupalGet('admin/config/regional/date-time/formats/manage/short'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/config/regional/date-time/formats/manage/html_date'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Locked date formats are not deletable. $this->drupalGet('admin/config/regional/date-time/formats/manage/short/delete'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/config/regional/date-time/formats/manage/html_date/delete'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/system/tests/src/Functional/System/DateTimeTest.php b/core/modules/system/tests/src/Functional/System/DateTimeTest.php index 311a35312f5..73df3934295 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); + $this->assertSession()->statusCodeEquals(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 b01a4218620..a5b9496ad15 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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 ec3b3c8d021..f57e82c97fa 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); + $this->assertSession()->statusCodeEquals(403); // Test that it is possible to have path aliases containing .php. $type = $this->drupalCreateContentType(); @@ -121,14 +121,14 @@ class HtaccessTest extends BrowserTestBase { ]); $node->save(); $this->drupalGet('test.php'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('This is a node'); // Update node's alias to test.php/test. $node->path = '/test.php/test'; $node->save(); $this->drupalGet('test.php/test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('This is a node'); } @@ -151,7 +151,7 @@ class HtaccessTest extends BrowserTestBase { */ public function testSvgzContentEncoding() { $this->drupalGet('core/modules/system/tests/logo.svgz'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Use x-encoded-content-encoding because of Content-Encoding responses // (gzip, deflate, etc.) are automatically decoded by Guzzle. diff --git a/core/modules/system/tests/src/Functional/System/IndexPhpTest.php b/core/modules/system/tests/src/Functional/System/IndexPhpTest.php index 9896e850bdc..2599abb5eb7 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); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet($index_php . '/user', ['external' => TRUE]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php index 74efe98c172..87a0c1ec232 100644 --- a/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php +++ b/core/modules/system/tests/src/Functional/System/PageNotFoundTest.php @@ -74,7 +74,7 @@ class PageNotFoundTest extends BrowserTestBase { $this->drupalGet('/this-path-does-not-exist'); $this->assertNoText('Admin-only 4xx response'); $this->assertText('The requested page could not be found.'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Verify the access cacheability metadata for custom 404 is bubbled. $this->assertCacheContext('user.roles'); @@ -82,7 +82,7 @@ class PageNotFoundTest extends BrowserTestBase { $this->drupalGet('/this-path-does-not-exist'); $this->assertText('Admin-only 4xx response'); $this->assertNoText('The requested page could not be found.'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Verify the access cacheability metadata for custom 404 is bubbled. $this->assertCacheContext('user.roles'); } diff --git a/core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php b/core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php index 3d44528b7fb..cfb2a868e21 100644 --- a/core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php +++ b/core/modules/system/tests/src/Functional/System/ResponseGeneratorTest.php @@ -47,13 +47,13 @@ class ResponseGeneratorTest extends BrowserTestBase { // Check to see if the header is added when viewing a normal content page $this->drupalGet($node->toUrl()); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertEqual('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type')); $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator')); // Check to see if the header is also added for a non-successful response $this->drupalGet('llama'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->assertEqual('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type')); $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator')); @@ -67,7 +67,7 @@ class ResponseGeneratorTest extends BrowserTestBase { // Tests to see if this also works for a non-html request $this->drupalGet($node->toUrl()->setOption('query', ['_format' => 'hal_json'])); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertEqual('application/hal+json', $this->drupalGetHeader('Content-Type')); $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator')); diff --git a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php index 60491da1970..0da67f459f3 100644 --- a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php +++ b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php @@ -160,7 +160,7 @@ class SiteMaintenanceTest extends BrowserTestBase { foreach ($formats as $format) { $this->pass('Testing format ' . $format); $this->drupalGet('', ['query' => ['_format' => $format]]); - $this->assertResponse(503); + $this->assertSession()->statusCodeEquals(503); $this->assertRaw('Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.'); $this->assertSession()->responseHeaderEquals('Content-Type', 'text/plain; charset=UTF-8'); } diff --git a/core/modules/system/tests/src/Functional/System/StatusTest.php b/core/modules/system/tests/src/Functional/System/StatusTest.php index a4b5557d146..09f27a5ba00 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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 a7ff1560066..cb2d7993114 100644 --- a/core/modules/system/tests/src/Functional/System/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php @@ -55,14 +55,14 @@ class ThemeTest extends BrowserTestBase { public function testThemeSettings() { // Ensure a disabled theme settings form URL returns 404. $this->drupalGet('admin/appearance/settings/bartik'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Ensure a non existent theme settings form URL returns 404. $this->drupalGet('admin/appearance/settings/' . $this->randomMachineName()); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(404); // Specify a filesystem path to be used for the logo. $file = current($this->drupalGetTestFiles('image')); @@ -213,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); + $this->assertSession()->statusCodeEquals(200); // Ensure default logo and favicons are not triggering custom path // validation errors if their custom paths are set on the form. @@ -311,7 +311,7 @@ class ThemeTest extends BrowserTestBase { $normal_user = $this->drupalCreateUser(['view the administration theme']); $this->drupalLogin($normal_user); $this->drupalGet('admin/config'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.'); $this->drupalLogin($this->adminUser); diff --git a/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php b/core/modules/system/tests/src/Functional/System/TrustedHostsTest.php index 83613f72b0f..bdf65203ddb 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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/Theme/EntityFilteringThemeTest.php b/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php index bf95bcbc542..cfc9226f61b 100644 --- a/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php @@ -143,7 +143,7 @@ class EntityFilteringThemeTest extends BrowserTestBase { ->save(); foreach ($paths as $path) { $this->drupalGet($path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoRaw($this->xssLabel); } } diff --git a/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php b/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php index adefc94dc2c..4abbfdb63a5 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php @@ -132,9 +132,9 @@ class TwigSettingsTest extends BrowserTestBase { $this->rebuildContainer(); $this->drupalGet('theme-test/inline-template-test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('theme-test/inline-template-test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php index b49217b68e4..60c1ef7d8f8 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php @@ -125,7 +125,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { $this->assertText('Test 1'); $this->assertRaw('0.01'); $this->drupalPostForm('node/8/edit', [], 'Save (this translation)'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('node/8/edit', ['language' => $spanish]); $this->assertText('Test title Spanish'); $this->assertText('Test body Spanish'); @@ -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->assertSession()->statusCodeEquals(200); // Make sure our feed still exists. $this->drupalGet('admin/config/services/aggregator'); @@ -262,7 +262,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { $this->drupalGet('admin/structure/display-modes/view'); $this->assertText('New view mode'); $this->drupalGet('admin/structure/display-modes/view/manage/node.new_view_mode'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure our other language is still there. $this->drupalGet('admin/config/regional/language'); @@ -282,7 +282,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { // Make sure our custom responsive image style exists. $this->drupalGet('admin/config/media/responsive-image-style/test'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('Test'); // Make sure our custom shortcut exists. @@ -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->assertSession()->statusCodeEquals(200); // Make sure the terms are still translated. $this->drupalGet('taxonomy/term/2/translations'); diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathWithBrokenRoutingTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathWithBrokenRoutingTest.php index 1d014a72293..61271818a9a 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathWithBrokenRoutingTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathWithBrokenRoutingTest.php @@ -36,7 +36,7 @@ class UpdatePathWithBrokenRoutingTest extends BrowserTestBase { \Drupal::state()->set('update_script_test_broken_inbound', TRUE); $this->resetAll(); $this->drupalGet(''); - $this->assertResponse(500); + $this->assertSession()->statusCodeEquals(500); $this->runUpdates(Url::fromRoute('system.db_update', [], ['path_processing' => FALSE])); @@ -44,7 +44,7 @@ class UpdatePathWithBrokenRoutingTest extends BrowserTestBase { // the front page again. \Drupal::state()->set('update_script_test_broken_inbound', FALSE); $this->drupalGet(''); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php index d099edbe8b4..38a6120d8fb 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php @@ -82,7 +82,7 @@ class UpdateScriptTest extends BrowserTestBase { $regular_user = $this->drupalCreateUser(); $this->drupalLogin($regular_user); $this->drupalGet($this->updateUrl, ['external' => TRUE]); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Check that a link to the update page is not accessible to regular users. $this->drupalGet('/update-script-test/database-updates-menu-item'); @@ -91,7 +91,7 @@ class UpdateScriptTest extends BrowserTestBase { // Try accessing update.php as an anonymous user. $this->drupalLogout(); $this->drupalGet($this->updateUrl, ['external' => TRUE]); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Check that a link to the update page is not accessible to anonymous // users. @@ -101,7 +101,7 @@ class UpdateScriptTest extends BrowserTestBase { // Access the update page with the proper permission. $this->drupalLogin($this->updateUser); $this->drupalGet($this->updateUrl, ['external' => TRUE]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check that a link to the update page is accessible to users with proper // permissions. @@ -111,7 +111,7 @@ class UpdateScriptTest extends BrowserTestBase { // Access the update page as user 1. $this->drupalLogin($this->rootUser); $this->drupalGet($this->updateUrl, ['external' => TRUE]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check that a link to the update page is accessible to user 1. $this->drupalGet('/update-script-test/database-updates-menu-item'); @@ -522,7 +522,7 @@ class UpdateScriptTest extends BrowserTestBase { $this->assertNoLink('Administration pages'); $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php'])); $this->clickLink('Front page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Click through update.php with 'access administration pages' permission. $admin_user = $this->drupalCreateUser(['administer software updates', 'access administration pages']); @@ -534,7 +534,7 @@ class UpdateScriptTest extends BrowserTestBase { $this->assertLink('Administration pages'); $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php'])); $this->clickLink('Administration pages'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -570,7 +570,7 @@ class UpdateScriptTest extends BrowserTestBase { $this->assertLink('Administration pages'); $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php'])); $this->clickLink('Administration pages'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -622,7 +622,7 @@ class UpdateScriptTest extends BrowserTestBase { // Visit status report page and ensure, that link to update.php has no path prefix set. $this->drupalGet('en/admin/reports/status', ['external' => TRUE]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('/update.php'); $this->assertNoLinkByHref('en/update.php'); @@ -638,7 +638,7 @@ class UpdateScriptTest extends BrowserTestBase { $this->assertLink('Administration pages'); $this->assertEmpty($this->xpath('//main//a[contains(@href, :href)]', [':href' => 'update.php'])); $this->clickLink('Administration pages'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** @@ -652,9 +652,9 @@ class UpdateScriptTest extends BrowserTestBase { ]); $this->drupalLogin($admin_user); $this->drupalGet($this->updateUrl, ['external' => TRUE]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->clickLink('maintenance mode'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertEquals('Maintenance mode', $this->cssSelect('main h1')[0]->getText()); } @@ -700,7 +700,7 @@ class UpdateScriptTest extends BrowserTestBase { // Verify the front page can be visited following the upgrade. $this->clickLink('Front page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } /** diff --git a/core/modules/taxonomy/tests/src/Functional/RssTest.php b/core/modules/taxonomy/tests/src/Functional/RssTest.php index 252950ce736..3befd2336d9 100644 --- a/core/modules/taxonomy/tests/src/Functional/RssTest.php +++ b/core/modules/taxonomy/tests/src/Functional/RssTest.php @@ -122,7 +122,7 @@ class RssTest extends TaxonomyTestBase { // Check that the "Exception value" is disabled by default. $this->drupalGet('taxonomy/term/all/feed'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Set the exception value to 'all'. $view = Views::getView('taxonomy_term'); $arguments = $view->getDisplay()->getOption('arguments'); diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php index 8a009298c9c..ff60bfbda17 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php @@ -102,13 +102,13 @@ class TaxonomyImageTest extends TaxonomyTestBase { // 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/taxonomy/tests/src/Functional/TermTest.php b/core/modules/taxonomy/tests/src/Functional/TermTest.php index 8572bd5f4b8..b4ca5364db9 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(404); } /** diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php index 9b153abf593..a64a0590f8d 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php @@ -131,12 +131,12 @@ class TermTranslationUITest extends ContentTranslationUITestBase { // Verify translation links. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('term/' . $translatable_tid . '/translations', 0, 'The translations link exists for a translatable vocabulary.'); $this->assertLinkByHref('term/' . $translatable_tid . '/edit', 0, 'The edit link exists for a translatable vocabulary.'); $this->drupalGet('admin/structure/taxonomy/manage/' . $untranslatable_vocabulary->id() . '/overview'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('term/' . $untranslatable_tid . '/edit'); $this->assertNoLinkByHref('term/' . $untranslatable_tid . '/translations'); } diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php index 1799ca65120..56b30fd047e 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermViewTest.php @@ -156,9 +156,9 @@ class TaxonomyTermViewTest extends TaxonomyTestBase { // Test the default views disclose no data by default. $this->drupalLogout(); $this->drupalGet('taxonomy/term/' . $term->id()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('taxonomy/term/' . $term->id() . '/feed'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php index 0342c3838a8..2a7229c0e02 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); + $this->assertSession()->statusCodeEquals(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 c6b1c81f9ba..85d17a3b150 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyPermissionsTest.php @@ -235,7 +235,7 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { // Visit the main taxonomy administration page. $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertField('edit-name-0-value', 'Add taxonomy term form opened successfully.'); // Submit the term. @@ -256,7 +256,7 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { // Edit the term. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($edit['name[0][value]'], 'Edit taxonomy term form opened successfully.'); $edit['name[0][value]'] = $this->randomMachineName(); @@ -306,14 +306,14 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { // Ensure the taxonomy term add form is denied. $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create a test term. $term = $this->createTerm($vocabulary); // Edit the term. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($term->getName(), 'Edit taxonomy term form opened successfully.'); $edit['name[0][value]'] = $this->randomMachineName(); @@ -326,7 +326,7 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { // Ensure the term cannot be deleted. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Test as user with "delete" permissions. $user = $this->drupalCreateUser(["delete terms in {$vocabulary->id()}"]); @@ -334,14 +334,14 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { // Ensure the taxonomy term add form is denied. $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create a test term. $term = $this->createTerm($vocabulary); // Ensure that the term cannot be edited. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Delete the vocabulary. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); @@ -357,18 +357,18 @@ class VocabularyPermissionsTest extends TaxonomyTestBase { // Ensure the taxonomy term add form is denied. $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create a test term. $term = $this->createTerm($vocabulary); // Ensure that the term cannot be edited. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Ensure the term cannot be deleted. $this->drupalGet('taxonomy/term/' . $term->id() . '/delete'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/modules/text/tests/src/Functional/TextFieldTest.php b/core/modules/text/tests/src/Functional/TextFieldTest.php index a73e2d9362c..7d2ba628be0 100644 --- a/core/modules/text/tests/src/Functional/TextFieldTest.php +++ b/core/modules/text/tests/src/Functional/TextFieldTest.php @@ -127,12 +127,12 @@ class TextFieldTest extends StringFieldTest { $test_file = current($this->drupalGetTestFiles('text')); $edit['files[file_field_0]'] = \Drupal::service('file_system')->realpath($test_file->uri); $this->drupalPostForm('entity_test/add', $edit, 'Upload'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $edit = [ 'text_long[0][value]' => 'Long text', ]; $this->drupalPostForm(NULL, $edit, 'Save'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('entity_test/1'); $this->assertText('Long text'); } diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php index c7af80dcb68..4544a977407 100644 --- a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php +++ b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php @@ -100,7 +100,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { $this->drupalLogin($this->adminUser); $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Assert that the toolbar is present in the HTML. $this->assertRaw('id="toolbar-administration"'); @@ -148,7 +148,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { $edit = []; $edit['enabled'] = FALSE; $this->drupalPostForm("admin/structure/menu/link/" . $admin_menu_link_id . "/edit", $edit, t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('The menu link has been saved.'); // Assert that the subtrees hash has been altered because the subtrees @@ -178,7 +178,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { // Get the hash for a second user. $this->drupalLogin($this->adminUser2); $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Assert that the toolbar is present in the HTML. $this->assertRaw('id="toolbar-administration"'); @@ -188,7 +188,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { // Log in the first admin user again. $this->drupalLogin($this->adminUser); $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Assert that the toolbar is present in the HTML. $this->assertRaw('id="toolbar-administration"'); @@ -211,7 +211,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { // Request a new page to refresh the drupalSettings object. $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $new_subtree_hash = $this->getSubtreesHash(); // Assert that the old admin menu subtree hash and the new admin menu @@ -235,7 +235,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { // Get the subtree hash for adminUser2 to check later that it has not // changed. Request a new page to refresh the drupalSettings object. $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $admin_user_2_hash = $this->getSubtreesHash(); // Assign the role to the user. @@ -288,7 +288,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { // Have the adminUser request a page in the new language. $this->drupalGet($langcode . '/test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Get a baseline hash for the admin menu subtrees before translating one // of the menu link items. @@ -328,7 +328,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { $this->drupalLogin($admin_user); // Have the adminUser request a page in the new language. $this->drupalGet($langcode . '/test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $new_subtree_hash = $this->getSubtreesHash(); // Assert that the old admin menu subtrees hash and the new admin menu @@ -430,7 +430,7 @@ class ToolbarAdminMenuTest extends BrowserTestBase { private function assertDifferentHash() { // Request a new page to refresh the drupalSettings object. $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $new_subtree_hash = $this->getSubtreesHash(); // Assert that the old admin menu subtree hash and the new admin menu diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php index c3a6a724bfc..fee6f2666bb 100644 --- a/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php +++ b/core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php @@ -43,7 +43,7 @@ class ToolbarHookToolbarTest extends BrowserTestBase { */ public function testHookToolbar() { $this->drupalGet('test-page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Assert that the toolbar is present in the HTML. $this->assertRaw('id="toolbar-administration"'); diff --git a/core/modules/update/tests/src/Functional/UpdateCoreTest.php b/core/modules/update/tests/src/Functional/UpdateCoreTest.php index 9b0564187ec..8d60257aad0 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); + $this->assertSession()->statusCodeEquals(403); foreach ([0, 1] as $minor_version) { foreach (['-alpha1', '-beta1', ''] as $extra_version) { diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php index 8b0a4309b13..bf61745493f 100644 --- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php +++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php @@ -96,7 +96,7 @@ class UpdateUploadTest extends UpdateTestBase { $this->assertLinkByHref(Url::fromRoute('system.admin')->toString()); // Ensure we can reach the "Install another module" link. $this->clickLink(t('Install another module')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertUrl('admin/modules/install'); // Check that the module has the correct version before trying to update diff --git a/core/modules/user/tests/src/Functional/AccessRoleUITest.php b/core/modules/user/tests/src/Functional/AccessRoleUITest.php index 1be9d869109..5475e1d47e4 100644 --- a/core/modules/user/tests/src/Functional/AccessRoleUITest.php +++ b/core/modules/user/tests/src/Functional/AccessRoleUITest.php @@ -49,7 +49,7 @@ class AccessRoleUITest extends UITestBase { $entity_type_manager->getStorage('user_role')->create(['id' => 'custom_role', 'label' => 'Custom role'])->save(); $access_url = "admin/structure/views/nojs/display/test_access_role/default/access_options"; $this->drupalPostForm($access_url, ['access_options[role][custom_role]' => 1], t('Apply')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, [], t('Save')); $view = $entity_type_manager->getStorage('view')->load('test_access_role'); diff --git a/core/modules/user/tests/src/Functional/UserAdminListingTest.php b/core/modules/user/tests/src/Functional/UserAdminListingTest.php index 225e34b5206..aac4757e491 100644 --- a/core/modules/user/tests/src/Functional/UserAdminListingTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminListingTest.php @@ -24,7 +24,7 @@ class UserAdminListingTest extends BrowserTestBase { public function testUserListing() { // Ensure the anonymous user cannot access the admin listing. $this->drupalGet('admin/people'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Create a bunch of users. $accounts = []; @@ -65,7 +65,7 @@ class UserAdminListingTest extends BrowserTestBase { // Ensure the admin user can access the admin listing. $this->drupalGet('admin/people'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(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 357a3fb7f66..8b67a1c890f 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); + $this->assertSession()->statusCodeEquals(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/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php index bd77307fc89..af9611f1642 100644 --- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -77,7 +77,7 @@ class UserPasswordResetTest extends BrowserTestBase { // Verify that accessing the password reset form without having the session // variables set results in an access denied message. $this->drupalGet(Url::fromRoute('user.reset.form', ['uid' => $this->account->id()])); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Try to reset the password for an invalid account. $this->drupalGet('user/password'); @@ -159,7 +159,7 @@ class UserPasswordResetTest extends BrowserTestBase { $blocked_account = $this->drupalCreateUser()->block(); $blocked_account->save(); $this->drupalGet("user/reset/" . $blocked_account->id() . "/$timestamp/" . user_pass_rehash($blocked_account, $timestamp)); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Verify a blocked user can not request a new password. $this->drupalGet('user/password'); @@ -198,11 +198,11 @@ class UserPasswordResetTest extends BrowserTestBase { $blocked_account = $this->drupalCreateUser()->block(); $blocked_account->save(); $this->drupalGet("user/reset/" . $blocked_account->id() . "/$timestamp/" . user_pass_rehash($blocked_account, $timestamp) . '/login'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $blocked_account->delete(); $this->drupalGet("user/reset/" . $blocked_account->id() . "/$timestamp/" . user_pass_rehash($blocked_account, $timestamp) . '/login'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** @@ -263,9 +263,9 @@ class UserPasswordResetTest extends BrowserTestBase { // user.reset.form routes. $timestamp = REQUEST_TIME - 1; $this->drupalGet("user/reset/" . $this->account->id() . "/$timestamp/" . user_pass_rehash($this->account, $timestamp) . '/login'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet("user/reset/" . $this->account->id()); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** diff --git a/core/modules/user/tests/src/Functional/UserRegistrationTest.php b/core/modules/user/tests/src/Functional/UserRegistrationTest.php index adabd94ba4c..fece43d6a48 100644 --- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php +++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php @@ -38,7 +38,7 @@ class UserRegistrationTest extends BrowserTestBase { // page is inaccessible. $config->set('register', UserInterface::REGISTER_ADMINISTRATORS_ONLY)->save(); $this->drupalGet('user/register'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Allow registration by site visitors without administrator approval. $config->set('register', UserInterface::REGISTER_VISITORS)->save(); @@ -212,7 +212,7 @@ class UserRegistrationTest extends BrowserTestBase { // Create one account. $this->drupalPostForm('user/register', $edit, t('Create new account')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $user_storage = \Drupal::entityTypeManager()->getStorage('user'); @@ -225,7 +225,7 @@ class UserRegistrationTest extends BrowserTestBase { $edit['pass[pass2]'] = $edit['pass[pass1]'] = $this->randomMachineName(); $this->drupalPostForm('user/register', $edit, t('Create new account')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNotEmpty($user_storage->loadByProperties(['name' => $edit['name']])); } diff --git a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php index c9db3001115..8e11fd19b5c 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); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(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 3f54c9945af..539112e916e 100644 --- a/core/modules/user/tests/src/Functional/UserSearchTest.php +++ b/core/modules/user/tests/src/Functional/UserSearchTest.php @@ -113,14 +113,14 @@ class UserSearchTest extends BrowserTestBase { $user3 = $this->drupalCreateUser(['search content']); $this->drupalLogin($user3); $this->drupalGet('search/user'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(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); + $this->assertSession()->statusCodeEquals(403); $this->drupalLogout(); } diff --git a/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php b/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php index e885603f9a5..166ce5850d3 100644 --- a/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php +++ b/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php @@ -60,12 +60,12 @@ class AccessRoleTest extends AccessTestBase { $this->drupalLogin($this->webUser); $this->drupalGet('test-role'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertCacheContext('user.roles'); $this->drupalLogin($this->normalUser); $this->drupalGet('test-role'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertCacheContext('user.roles'); // Test allowing multiple roles. @@ -89,15 +89,15 @@ class AccessRoleTest extends AccessTestBase { $this->assertIdentical($expected, $view->calculateDependencies()->getDependencies()); $this->drupalLogin($this->webUser); $this->drupalGet('test-role'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->assertCacheContext('user.roles'); $this->drupalLogout(); $this->drupalGet('test-role'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertCacheContext('user.roles'); $this->drupalLogin($this->normalUser); $this->drupalGet('test-role'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertCacheContext('user.roles'); } diff --git a/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php index ce27dab51c6..ec6378157e3 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); + $this->assertSession()->statusCodeEquals(403); // Test blocking the account "no_edit". $edit = [ @@ -57,7 +57,7 @@ class BulkFormAccessTest extends UserTestBase { 'action' => 'user_block_user_action', ]; $this->drupalPostForm('test-user-bulk-form', $edit, t('Apply to selected items')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertRaw(new FormattableMarkup('No access to execute %action on the @entity_type_label %entity_label.', [ '%action' => 'Block the selected user(s)', @@ -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); + $this->assertSession()->statusCodeEquals(403); // Ensure that the account "may_delete" *can* be deleted. $this->drupalGet('user/' . $account2->id() . '/cancel'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test deleting the accounts "no_delete" and "may_delete". $edit = [ diff --git a/core/modules/views/tests/src/Functional/DefaultViewsTest.php b/core/modules/views/tests/src/Functional/DefaultViewsTest.php index a0262ef36d9..b202e10d2b6 100644 --- a/core/modules/views/tests/src/Functional/DefaultViewsTest.php +++ b/core/modules/views/tests/src/Functional/DefaultViewsTest.php @@ -240,7 +240,7 @@ class DefaultViewsTest extends ViewTestBase { \Drupal::service('router.builder')->rebuild(); $this->drupalGet('archive'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/views/tests/src/Functional/Entity/ViewNonTranslatableEntityTest.php b/core/modules/views/tests/src/Functional/Entity/ViewNonTranslatableEntityTest.php index 4b43df5bdf2..d4b6e9c8fe2 100644 --- a/core/modules/views/tests/src/Functional/Entity/ViewNonTranslatableEntityTest.php +++ b/core/modules/views/tests/src/Functional/Entity/ViewNonTranslatableEntityTest.php @@ -43,7 +43,7 @@ class ViewNonTranslatableEntityTest extends BrowserTestBase { // Visit the view page and assert it is displayed properly. $this->drupalGet('no-entity-translation-view'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('No Entity Translation View'); $this->assertText($no_language_entity->uuid()); } diff --git a/core/modules/views/tests/src/Functional/GlossaryTest.php b/core/modules/views/tests/src/Functional/GlossaryTest.php index 0c055a9355a..b55773b9e19 100644 --- a/core/modules/views/tests/src/Functional/GlossaryTest.php +++ b/core/modules/views/tests/src/Functional/GlossaryTest.php @@ -110,7 +110,7 @@ class GlossaryTest extends ViewTestBase { // Check the actual page response. $this->drupalGet($url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); foreach ($nodes_per_char as $char => $count) { $href = Url::fromRoute('view.glossary.page_1', ['arg_0' => $char])->toString(); $label = mb_strtoupper($char); diff --git a/core/modules/views/tests/src/Functional/Handler/AreaHTTPStatusCodeTest.php b/core/modules/views/tests/src/Functional/Handler/AreaHTTPStatusCodeTest.php index 7a103ad1bc7..d6180ca838f 100644 --- a/core/modules/views/tests/src/Functional/Handler/AreaHTTPStatusCodeTest.php +++ b/core/modules/views/tests/src/Functional/Handler/AreaHTTPStatusCodeTest.php @@ -37,7 +37,7 @@ class AreaHTTPStatusCodeTest extends ViewTestBase { */ public function testHTTPStatusCodeHandler() { $this->drupalGet('test-http-status-code'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Change the HTTP status code to 418. $view = Views::getView('test_http_status_code'); @@ -47,7 +47,7 @@ class AreaHTTPStatusCodeTest extends ViewTestBase { // Test that the HTTP response is "I'm a teapot". $this->drupalGet('test-http-status-code'); - $this->assertResponse(418); + $this->assertSession()->statusCodeEquals(418); } } diff --git a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php index 9339edebcf5..a270c717615 100644 --- a/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php +++ b/core/modules/views/tests/src/Functional/Handler/FieldWebTest.php @@ -67,7 +67,7 @@ class FieldWebTest extends ViewTestBase { */ public function testClickSorting() { $this->drupalGet('test_click_sort'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Only the id and name should be click sortable, but not the name. $this->assertLinkByHref(Url::fromRoute('', [], ['query' => ['order' => 'id', 'sort' => 'asc']])->toString()); diff --git a/core/modules/views/tests/src/Functional/Plugin/AccessTest.php b/core/modules/views/tests/src/Functional/Plugin/AccessTest.php index eeb94d74fe6..28590209d9a 100644 --- a/core/modules/views/tests/src/Functional/Plugin/AccessTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/AccessTest.php @@ -92,7 +92,7 @@ class AccessTest extends ViewTestBase { $this->assertFalse($access_plugin->access($this->normalUser)); $this->drupalGet('test_access_static'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $display = &$view->storage->getDisplay('default'); $display['display_options']['access']['options']['access'] = TRUE; @@ -105,7 +105,7 @@ class AccessTest extends ViewTestBase { $this->assertTrue($access_plugin->access($this->normalUser)); $this->drupalGet('test_access_static'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/views/tests/src/Functional/Plugin/CacheWebTest.php b/core/modules/views/tests/src/Functional/Plugin/CacheWebTest.php index 11780b86966..850d91e0f90 100644 --- a/core/modules/views/tests/src/Functional/Plugin/CacheWebTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/CacheWebTest.php @@ -69,7 +69,7 @@ class CacheWebTest extends ViewTestBase { $this->assertFalse($render_cache->get($cache_element)); $this->drupalGet('test-display'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNotEmpty($render_cache->get($cache_element)); $cache_tags = [ 'config:user.role.anonymous', @@ -80,7 +80,7 @@ class CacheWebTest extends ViewTestBase { $this->assertCacheTags($cache_tags); $this->drupalGet('test-display'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNotEmpty($render_cache->get($cache_element)); $this->assertCacheTags($cache_tags); } diff --git a/core/modules/views/tests/src/Functional/Plugin/DisabledDisplayTest.php b/core/modules/views/tests/src/Functional/Plugin/DisabledDisplayTest.php index 38bf59247f4..879caeeea55 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisabledDisplayTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisabledDisplayTest.php @@ -67,7 +67,7 @@ class DisabledDisplayTest extends ViewTestBase { // Disabled page view should 404. $this->drupalGet('test-disabled-display-2'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Enable each disabled display and save the view. foreach ($display_ids as $display_id) { @@ -96,11 +96,11 @@ class DisabledDisplayTest extends ViewTestBase { // Check that the page_1 display still works. $this->drupalGet('test-disabled-display'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Check that the page_2 display is now disabled again. $this->drupalGet('test-disabled-display-2'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } } diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php index dbacf0d4189..5560abaa8dd 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTest.php @@ -180,7 +180,7 @@ class DisplayFeedTest extends ViewTestBase { // Ensure the feed attachment returns 'Not found'. $this->drupalGet('/test-attached-disabled.xml'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); } /** @@ -197,10 +197,10 @@ class DisplayFeedTest extends ViewTestBase { \Drupal::service('router.builder')->rebuild(); $this->drupalGet('test-attached-disabled'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Ensure the feed can still be reached. $this->drupalGet('test-attached-disabled.xml'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTranslationTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTranslationTest.php index 00fed1999af..e692a3976c2 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTranslationTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayFeedTranslationTest.php @@ -161,7 +161,7 @@ class DisplayFeedTranslationTest extends ViewTestBase { } $this->drupalGet('test-feed-display-fields.xml'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $items = $this->getSession()->getDriver()->find('//channel/item'); // There should only be 3 items in the feed. diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php index 87c6c0f6983..c42b5aaf195 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php @@ -49,39 +49,39 @@ class DisplayPageWebTest extends ViewTestBase { */ public function testArguments() { $this->drupalGet('test_route_without_arguments'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $result = $this->xpath('//span[@class="field-content"]'); $this->assertCount(5, $result, 'All entries was returned'); $this->drupalGet('test_route_without_arguments/1'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet('test_route_with_argument/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url']); $result = $this->xpath('//span[@class="field-content"]'); $this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.'); $this->assertEqual($result[0]->getText(), 1, 'The passed ID was returned.'); $this->drupalGet('test_route_with_suffix/1/suffix'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $result = $this->xpath('//span[@class="field-content"]'); $this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.'); $this->assertEqual($result[0]->getText(), 1, 'The passed ID was returned.'); $this->drupalGet('test_route_with_suffix_and_argument/1/suffix/2'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $result = $this->xpath('//span[@class="field-content"]'); $this->assertCount(0, $result, 'No result was returned.'); $this->drupalGet('test_route_with_suffix_and_argument/1/suffix/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $result = $this->xpath('//span[@class="field-content"]'); $this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.'); $this->assertEqual($result[0]->getText(), 1, 'The passed ID was returned.'); $this->drupalGet('test_route_with_long_argument/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $result = $this->xpath('//span[@class="field-content"]'); $this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.'); $this->assertEqual($result[0]->getText(), 1, 'The passed ID was returned.'); @@ -93,7 +93,7 @@ class DisplayPageWebTest extends ViewTestBase { public function testPageDisplayMenu() { // Check local tasks. $this->drupalGet('test_page_display_menu'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]/child::text()', [ ':ul_class' => 'tabs primary', ':a_class' => 'is-active', @@ -102,10 +102,10 @@ class DisplayPageWebTest extends ViewTestBase { $this->assertTitle(t('Test default page | Drupal')); $this->drupalGet('test_page_display_menu/default'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->drupalGet('test_page_display_menu/local'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]/child::text()', [ ':ul_class' => 'tabs primary', ':a_class' => 'is-active', @@ -169,10 +169,10 @@ class DisplayPageWebTest extends ViewTestBase { $this->container->get('router.builder')->rebuild(); // Check if we successfully changed the path. $this->drupalGet($path); - $success = $this->assertResponse(200); + $success = $this->assertSession()->statusCodeEquals(200); // Check if we don't get any error on the view edit page. $this->drupalGet('admin/structure/views/view/test_page_display_path'); - return $success && $this->assertResponse(200); + return $success && $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php index bb0d9cc18f8..d1d1e11052e 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayTest.php @@ -298,7 +298,7 @@ class DisplayTest extends ViewTestBase { */ public function testInvalidDisplayPlugins() { $this->drupalGet('test_display_invalid'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Change the page plugin id to an invalid one. Bypass the entity system // so no menu rebuild was executed (so the path is still available). @@ -307,7 +307,7 @@ class DisplayTest extends ViewTestBase { $config->save(); $this->drupalGet('test_display_invalid'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('The "invalid" plugin does not exist.'); // Rebuild the router, and ensure that the path is not accessible anymore. @@ -315,7 +315,7 @@ class DisplayTest extends ViewTestBase { \Drupal::service('router.builder')->rebuildIfNeeded(); $this->drupalGet('test_display_invalid'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); // Change the display plugin ID back to the correct ID. $config = $this->config('views.view.test_display_invalid'); @@ -326,7 +326,7 @@ class DisplayTest extends ViewTestBase { $block = $this->drupalPlaceBlock('views_block:test_display_invalid-block_1', ['label' => 'Invalid display']); $this->drupalGet(''); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertCount(1, $this->xpath('//div[@id = :id]', [':id' => 'block-' . $block->id()])); // Change the block plugin ID to an invalid one. @@ -337,7 +337,7 @@ class DisplayTest extends ViewTestBase { // Test the page is still displayed, the block not present, and has the // plugin warning message. $this->drupalGet(''); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText('The "invalid" plugin does not exist.'); $this->assertCount(0, $this->xpath('//div[@id = :id]', [':id' => 'block-' . $block->id()])); } diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index 2407caa3b36..efe4615eace 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -57,7 +57,7 @@ class ExposedFormTest extends ViewTestBase { public function testSubmitButton() { // Test the submit button value defaults to 'Apply'. $this->drupalGet('test_exposed_form_buttons'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', t('Apply')); // Rename the label of the submit button. @@ -164,7 +164,7 @@ class ExposedFormTest extends ViewTestBase { // Test the reset works. $this->drupalGet('test_exposed_form_buttons', ['query' => ['op' => 'Reset']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test the type has been reset. $this->assertFieldById('edit-type', 'All', 'Article type filter has been reset.'); @@ -173,7 +173,7 @@ class ExposedFormTest extends ViewTestBase { // Test the reset works with type set. $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article', 'op' => 'Reset']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertFieldById('edit-type', 'All', 'Article type filter has been reset.'); // Test the button is hidden after reset. @@ -191,7 +191,7 @@ class ExposedFormTest extends ViewTestBase { // Look whether the reset button label changed. $this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->helperButtonHasLabel('edit-reset', $expected_label); } @@ -263,7 +263,7 @@ class ExposedFormTest extends ViewTestBase { $view->save(); $this->drupalGet('test_exposed_form_buttons'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->helperButtonHasLabel('edit-submit-test-exposed-form-buttons', t('Apply')); // Ensure that no results are displayed. @@ -393,14 +393,14 @@ class ExposedFormTest extends ViewTestBase { */ public function testFormErrorWithExposedForm() { $this->drupalGet('views_test_data_error_form_page'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $form = $this->cssSelect('form.views-exposed-form'); $this->assertNotEmpty($form, 'The exposed form element was found.'); $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered before submitting the normal form.'); $this->assertRaw('
', 'Views result shown.'); $this->drupalPostForm(NULL, [], t('Submit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $form = $this->cssSelect('form.views-exposed-form'); $this->assertNotEmpty($form, 'The exposed form element was found.'); $this->assertRaw(t('Apply'), 'Ensure the exposed form is rendered after submitting the normal form.'); diff --git a/core/modules/views/tests/src/Functional/Plugin/FilterTest.php b/core/modules/views/tests/src/Functional/Plugin/FilterTest.php index 8ddf80818cd..c2c74aa1339 100644 --- a/core/modules/views/tests/src/Functional/Plugin/FilterTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/FilterTest.php @@ -176,7 +176,7 @@ class FilterTest extends ViewTestBase { public function testLimitExposedOperators() { $this->drupalGet('test_filter_in_operator_ui'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertOption('edit-nid-op', '<'); $this->assertOption('edit-nid-op', '<='); $this->assertOption('edit-nid-op', '='); @@ -196,7 +196,7 @@ class FilterTest extends ViewTestBase { $this->drupalPostForm('admin/structure/views/view/test_filter_in_operator_ui/edit/default', [], t('Save')); $this->drupalGet('test_filter_in_operator_ui'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoOption('edit-nid-op', '<'); $this->assertNoOption('edit-nid-op', '<='); $this->assertNoOption('edit-nid-op', '='); diff --git a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php index 4a7d04e9258..acc6a9ca099 100644 --- a/core/modules/views/tests/src/Functional/Wizard/BasicTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/BasicTest.php @@ -40,7 +40,7 @@ class BasicTest extends WizardTestBase { $view1['description'] = $this->randomMachineName(16); $view1['page[create]'] = FALSE; $this->drupalPostForm('admin/structure/views/add', $view1, t('Save and edit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/structure/views'); $this->assertText($view1['label']); $this->assertText($view1['description']); @@ -71,7 +71,7 @@ class BasicTest extends WizardTestBase { $view2['page[feed_properties][path]'] = $this->randomMachineName(16); $this->drupalPostForm('admin/structure/views/add', $view2, t('Save and edit')); $this->drupalGet($view2['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Since the view has a page, we expect to be automatically redirected to // it. @@ -122,7 +122,7 @@ class BasicTest extends WizardTestBase { $view3['block[title]'] = $this->randomMachineName(16); $this->drupalPostForm('admin/structure/views/add', $view3, t('Save and edit')); $this->drupalGet($view3['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure the view only displays the node we expect. $this->assertUrl($view3['page[path]']); @@ -171,7 +171,7 @@ class BasicTest extends WizardTestBase { // Check that the REST export path works. JSON will work, as all core // formats will be allowed. JSON and XML by default. $this->drupalGet($view4['rest_export[path]'], ['query' => ['_format' => 'json']]); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $data = Json::decode($this->getSession()->getPage()->getContent()); $this->assertCount(1, $data, 'Only the node of type page is exported.'); $node = reset($data); diff --git a/core/modules/views/tests/src/Functional/Wizard/ItemsPerPageTest.php b/core/modules/views/tests/src/Functional/Wizard/ItemsPerPageTest.php index d5c02ca3472..13e65046066 100644 --- a/core/modules/views/tests/src/Functional/Wizard/ItemsPerPageTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/ItemsPerPageTest.php @@ -56,7 +56,7 @@ class ItemsPerPageTest extends WizardTestBase { $view['block[items_per_page]'] = 3; $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); $this->drupalGet($view['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure the page display shows the nodes we expect, and that they // appear in the expected order. diff --git a/core/modules/views/tests/src/Functional/Wizard/MenuTest.php b/core/modules/views/tests/src/Functional/Wizard/MenuTest.php index 98f7d619df4..f35b851ea4d 100644 --- a/core/modules/views/tests/src/Functional/Wizard/MenuTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/MenuTest.php @@ -39,7 +39,7 @@ class MenuTest extends WizardTestBase { // Make sure there is a link to the view from the front page (where we // expect the main menu to display). $this->drupalGet(''); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLink($view['page[link_properties][title]']); $this->assertLinkByHref(Url::fromUri('base:' . $view['page[path]'])->toString()); diff --git a/core/modules/views/tests/src/Functional/Wizard/SortingTest.php b/core/modules/views/tests/src/Functional/Wizard/SortingTest.php index bdd236af3d2..a73b011be1f 100644 --- a/core/modules/views/tests/src/Functional/Wizard/SortingTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/SortingTest.php @@ -42,7 +42,7 @@ class SortingTest extends WizardTestBase { $view1['page[path]'] = $this->randomMachineName(16); $this->drupalPostForm('admin/structure/views/add', $view1, t('Save and edit')); $this->drupalGet($view1['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure the view shows the nodes in the expected order. $this->assertUrl($view1['page[path]']); @@ -67,7 +67,7 @@ class SortingTest extends WizardTestBase { $view2['page[path]'] = $this->randomMachineName(16); $this->drupalPostForm('admin/structure/views/add', $view2, t('Save and edit')); $this->drupalGet($view2['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Make sure the view shows the nodes in the expected order. $this->assertUrl($view2['page[path]']); diff --git a/core/modules/views/tests/src/Functional/Wizard/TaggedWithTest.php b/core/modules/views/tests/src/Functional/Wizard/TaggedWithTest.php index fb560a5a491..53c12604c9b 100644 --- a/core/modules/views/tests/src/Functional/Wizard/TaggedWithTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/TaggedWithTest.php @@ -158,7 +158,7 @@ class TaggedWithTest extends WizardTestBase { // Visit the page and check that the nodes we expect are present and the // ones we don't expect are absent. $this->drupalGet($view1['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($node_tag1_title); $this->assertText($node_tag1_tag2_title); $this->assertNoText($node_no_tags_title); @@ -168,7 +168,7 @@ class TaggedWithTest extends WizardTestBase { $view2 = []; $view2['show[type]'] = $this->nodeTypeWithTags->id(); $this->drupalPostForm('admin/structure/views/add', $view2, t('Update "of type" choice')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $view2['label'] = $this->randomMachineName(16); $view2['id'] = strtolower($this->randomMachineName(16)); $view2['description'] = $this->randomMachineName(16); @@ -177,7 +177,7 @@ class TaggedWithTest extends WizardTestBase { $view2['page[title]'] = $this->randomMachineName(16); $view2['page[path]'] = $this->randomMachineName(16); $this->drupalPostForm(NULL, $view2, t('Save and edit')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet($view2['page[path]']); $this->assertNoText($node_tag1_title); $this->assertText($node_tag1_tag2_title); diff --git a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php index da2d440f682..74d23b56185 100644 --- a/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php +++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php @@ -64,7 +64,7 @@ class DefaultViewsTest extends UITestBase { $this->drupalPostForm('admin/structure/views/nojs/display/glossary/page_1/title', $edit, t('Apply')); $this->drupalPostForm('admin/structure/views/view/glossary/edit/page_1', [], t('Save')); $this->drupalGet('glossary'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($new_title); // Save another view in the UI. @@ -125,9 +125,9 @@ class DefaultViewsTest extends UITestBase { // Test the default views disclose no data by default. $this->drupalLogout(); $this->drupalGet('glossary'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); $this->drupalGet('archive'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); // Test deleting a view. $this->drupalLogin($this->fullAdminUser); @@ -140,7 +140,7 @@ class DefaultViewsTest extends UITestBase { $this->assertNoLinkByHref($edit_href); // Ensure the view is no longer available. $this->drupalGet($edit_href); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->assertText('Page not found'); // Delete all duplicated Glossary views. @@ -150,14 +150,14 @@ class DefaultViewsTest extends UITestBase { $this->drupalPostForm(NULL, [], t('Delete')); $this->drupalGet('glossary'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/structure/views'); $this->clickViewsOperationLink(t('Delete'), $random_name); // Submit the confirmation form. $this->drupalPostForm(NULL, [], t('Delete')); $this->drupalGet('glossary'); - $this->assertResponse(404); + $this->assertSession()->statusCodeEquals(404); $this->assertText('Page not found'); } @@ -194,7 +194,7 @@ class DefaultViewsTest extends UITestBase { // Attempt to disable the view by path directly, with no token. $this->drupalGet('admin/structure/views/view/test_view_status/disable'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } /** diff --git a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php index 9f6e07633d8..3ab3c386418 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php @@ -94,7 +94,7 @@ class DisplayCRUDTest extends UITestBase { $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/display_id", ['display_id' => $machine_name], 'Apply'); $this->drupalPostForm(NULL, [], 'Delete Page'); $this->drupalPostForm(NULL, [], t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertNoLinkByHref($path_prefix . '/new_machine_name', 'Make sure there is no display tab for the deleted display.'); } diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php index 991d2af3694..bec61e28d0d 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -151,11 +151,11 @@ class DisplayPathTest extends UITestBase { $this->drupalGet('admin/structure/views/view/test_view'); $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/menu', ['menu[type]' => 'default tab', 'menu[title]' => 'Test tab title'], t('Apply')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertUrl('admin/structure/views/nojs/display/test_view/page_1/tab_options'); $this->drupalPostForm(NULL, ['tab_options[type]' => 'tab', 'tab_options[title]' => $this->randomString()], t('Apply')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertUrl('admin/structure/views/view/test_view/edit/page_1'); $this->drupalGet('admin/structure/views/view/test_view'); @@ -165,7 +165,7 @@ class DisplayPathTest extends UITestBase { // Ensure that you can select a parent in case the parent does not exist. $this->drupalGet('admin/structure/views/nojs/display/test_page_display_menu/page_5/menu'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $menu_parent = $this->xpath('//select[@id="edit-menu-parent"]'); $menu_options = (array) $menu_parent[0]->findAll('css', 'option'); unset($menu_options['@attributes']); @@ -256,7 +256,7 @@ class DisplayPathTest extends UITestBase { $this->drupalPostForm(NULL, [], t('Save')); // Assert that saving the view will not cause an exception. - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php index 10578a85846..28eef978645 100644 --- a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php @@ -299,7 +299,7 @@ class ExposedFormUITest extends UITestBase { $this->drupalPostForm(NULL, $edit, t('Apply')); // Check that the view is saved without errors. $this->drupalPostForm(NULL, [], t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Click the Expose filter button. $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', ['name[node_field_data.status]' => 1], t('Add and configure filter criteria')); @@ -320,7 +320,7 @@ class ExposedFormUITest extends UITestBase { $this->drupalPostForm(NULL, $edit, t('Apply')); // Check that the view is saved without errors. $this->drupalPostForm(NULL, [], t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status'); // Assert the same settings defined before still are there. diff --git a/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php b/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php index e9fc12ea4e7..2354eba1b72 100644 --- a/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php +++ b/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php @@ -51,7 +51,7 @@ class OverrideDisplaysTest extends UITestBase { // Make sure the title appears in the page. $this->drupalGet($view_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($original_title); // Confirm that the view block is available in the block administration UI. @@ -74,7 +74,7 @@ class OverrideDisplaysTest extends UITestBase { $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/title", $edit, t('Apply')); $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], t('Save')); $this->drupalGet($view_path); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($new_title); $this->assertText($original_title); } @@ -106,11 +106,11 @@ class OverrideDisplaysTest extends UITestBase { // Make sure that the feed, page and block all start off with the correct // titles. $this->drupalGet($view['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($view['page[title]']); $this->assertNoText($view['block[title]']); $this->drupalGet($view['page[feed_properties][path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($view['page[title]']); $this->assertNoText($view['block[title]']); @@ -142,12 +142,12 @@ class OverrideDisplaysTest extends UITestBase { $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/title", $edit, t('Apply')); $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], t('Save')); $this->drupalGet($view['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($new_default_title); $this->assertNoText($view['page[title]']); $this->assertNoText($view['block[title]']); $this->drupalGet($view['page[feed_properties][path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($new_default_title); $this->assertNoText($view['page[title]']); $this->assertNoText($view['block[title]']); @@ -163,10 +163,10 @@ class OverrideDisplaysTest extends UITestBase { $this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/block_1/title", $edit, t('Apply')); $this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", [], t('Save')); $this->drupalGet($view['page[path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($new_default_title); $this->drupalGet($view['page[feed_properties][path]']); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText($new_default_title); $this->assertNoText($new_block_title); $this->drupalGet(''); diff --git a/core/modules/views_ui/tests/src/Functional/PreviewTest.php b/core/modules/views_ui/tests/src/Functional/PreviewTest.php index 65dbaef25a2..735c0c4c72a 100644 --- a/core/modules/views_ui/tests/src/Functional/PreviewTest.php +++ b/core/modules/views_ui/tests/src/Functional/PreviewTest.php @@ -29,7 +29,7 @@ class PreviewTest extends UITestBase { $this->resetAll(); $this->drupalGet('admin/structure/views/view/test_preview/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, $edit = [], t('Update preview')); $elements = $this->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', [':ul-class' => 'contextual-links', ':li-class' => 'filter-add']); @@ -49,7 +49,7 @@ class PreviewTest extends UITestBase { */ public function testPreviewUI() { $this->drupalGet('admin/structure/views/view/test_preview/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, $edit = [], t('Update preview')); @@ -138,7 +138,7 @@ SQL; $this->resetAll(); $this->drupalGet('admin/structure/views/view/test_preview/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, $edit = [], t('Update preview')); @@ -156,7 +156,7 @@ SQL; */ public function testPreviewError() { $this->drupalGet('admin/structure/views/view/test_preview_error/edit'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, $edit = [], t('Update preview')); diff --git a/core/modules/views_ui/tests/src/Functional/ReportTest.php b/core/modules/views_ui/tests/src/Functional/ReportTest.php index 53363a1f2ee..bc91ec58459 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); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/modules/views_ui/tests/src/Functional/RowUITest.php b/core/modules/views_ui/tests/src/Functional/RowUITest.php index 637bbb576d5..53c74ea4dd9 100644 --- a/core/modules/views_ui/tests/src/Functional/RowUITest.php +++ b/core/modules/views_ui/tests/src/Functional/RowUITest.php @@ -62,7 +62,7 @@ class RowUITest extends UITestBase { $this->drupalPostForm($row_plugin_url, ['row[type]' => 'fields'], 'Apply'); $this->drupalGet($row_plugin_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertFieldByName('row[type]', 'fields', 'Make sure that the fields got saved as used row plugin.'); // Ensure that entity row plugins appear. diff --git a/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php b/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php index 5a5e4a5b29f..be5d1387f61 100644 --- a/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php +++ b/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php @@ -53,29 +53,29 @@ class UnsavedPreviewTest extends UITestBase { } $this->drupalGet('admin/structure/views/view/content'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, [], t('Add Page')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/structure/views/nojs/display/content/page_2/path'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, ['path' => 'foobarbaz'], t('Apply')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, [], t('Update preview')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertText(t('This display has no path')); $this->drupalGet('admin/structure/views/view/content/edit/page_2'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, [], t('Save')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalPostForm(NULL, [], t('Update preview')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLinkByHref('foobarbaz'); } diff --git a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php index 5a3905d5215..c5cef7402cc 100644 --- a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php +++ b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php @@ -132,7 +132,7 @@ class ViewEditTest extends UITestBase { ]; foreach ($test_views as $view_name => $display) { $this->drupalGet('admin/structure/views/view/' . $view_name); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language'; $this->assertNoLinkByHref($langcode_url); $assert_session->linkNotExistsExact(t('@type language selected for page', ['@type' => t('Content')])); @@ -148,7 +148,7 @@ class ViewEditTest extends UITestBase { // Language options should now exist with entity language the default. foreach ($test_views as $view_name => $display) { $this->drupalGet('admin/structure/views/view/' . $view_name); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language'; if ($view_name == 'test_view') { $this->assertNoLinkByHref($langcode_url); @@ -162,7 +162,7 @@ class ViewEditTest extends UITestBase { } $this->drupalGet($langcode_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); if ($view_name == 'test_view') { $this->assertText(t('The view is not based on a translatable entity type or the site is not multilingual.')); } @@ -218,7 +218,7 @@ class ViewEditTest extends UITestBase { // Check the order for the langcode filter. $langcode_url = 'admin/structure/views/nojs/handler/' . $view_name . '/' . $display . '/filter/langcode'; $this->drupalGet($langcode_url); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $expected_elements = [ 'all', diff --git a/core/modules/views_ui/tests/src/Functional/ViewsListTest.php b/core/modules/views_ui/tests/src/Functional/ViewsListTest.php index 63500d0add4..34f6841bc24 100644 --- a/core/modules/views_ui/tests/src/Functional/ViewsListTest.php +++ b/core/modules/views_ui/tests/src/Functional/ViewsListTest.php @@ -49,7 +49,7 @@ class ViewsListTest extends UITestBase { public function testViewsListLimit() { // Check if we can access the main views admin page. $this->drupalGet('admin/structure/views'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertLink(t('Add view')); // Check that there is a link to the content view without a destination diff --git a/core/profiles/minimal/tests/src/Functional/MinimalTest.php b/core/profiles/minimal/tests/src/Functional/MinimalTest.php index b0c587e937a..48894a13b71 100644 --- a/core/profiles/minimal/tests/src/Functional/MinimalTest.php +++ b/core/profiles/minimal/tests/src/Functional/MinimalTest.php @@ -29,7 +29,7 @@ class MinimalTest extends BrowserTestBase { $this->drupalGet(''); // Check the login block is present. $this->assertLink(t('Create new account')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Create a user to test tools and navigation blocks for logged in users // with appropriate permissions. diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php index 45efb5c5793..2acd63c7bb1 100644 --- a/core/profiles/standard/tests/src/Functional/StandardTest.php +++ b/core/profiles/standard/tests/src/Functional/StandardTest.php @@ -40,7 +40,7 @@ class StandardTest extends BrowserTestBase { $this->drupalGet(''); $this->assertLink(t('Contact')); $this->clickLink(t('Contact')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Test anonymous user can access 'Main navigation' block. $this->adminUser = $this->drupalCreateUser([ @@ -153,7 +153,7 @@ class StandardTest extends BrowserTestBase { $this->adminUser->addRole($role->id()); $this->adminUser->save(); $this->drupalGet('node/add'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Ensure that there are no pending updates after installation. $this->drupalLogin($this->rootUser); diff --git a/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php b/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php index af1673318c9..896675d5649 100644 --- a/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php +++ b/core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php @@ -73,7 +73,7 @@ class ToolkitSetupFormTest extends BrowserTestBase { // Test access without the permission 'administer site configuration'. $this->drupalLogin($this->drupalCreateUser(['access administration pages'])); $this->drupalGet('admin/config/media/image-toolkit'); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } } diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php index 4b3c13af587..1461101f051 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php @@ -115,7 +115,7 @@ class DistributionProfileExistingSettingsTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getAccountName()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php index bb7801e7d9e..b83c711b4a2 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php @@ -72,7 +72,7 @@ class DistributionProfileTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('myrootuser'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getAccountName()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php index a2a86270b00..c7508811a67 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationQueryTest.php @@ -112,7 +112,7 @@ class DistributionProfileTranslationQueryTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getDisplayName()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php index e137eae8e4d..0a0f66f8758 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTranslationTest.php @@ -103,7 +103,7 @@ class DistributionProfileTranslationTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getDisplayName()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php index 29c144d0ca3..6fbc9c9e3e1 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerConfigDirectorySetNoDirectoryTest.php @@ -40,7 +40,7 @@ class InstallerConfigDirectorySetNoDirectoryTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertDirectoryExists($this->syncDirectory); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerEmptySettingsTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerEmptySettingsTest.php index 2f3e5acc660..447adc5c6c9 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerEmptySettingsTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerEmptySettingsTest.php @@ -29,7 +29,7 @@ class InstallerEmptySettingsTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php index 7f93dd6c7a4..88580620d40 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigDirectoryTest.php @@ -39,7 +39,7 @@ class InstallerExistingConfigDirectoryTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertEqual($this->expectedFilePerms, fileperms($this->siteDirectory . '/config_read_only')); $this->assertEqual([], glob($this->siteDirectory . '/config_read_only/*'), 'The sync directory is empty after install because it is read-only.'); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingDatabaseSettingsTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingDatabaseSettingsTest.php index 021abd42f74..40b7f9fc6ba 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingDatabaseSettingsTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingDatabaseSettingsTest.php @@ -60,7 +60,7 @@ class InstallerExistingDatabaseSettingsTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsNoProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsNoProfileTest.php index 42f35422120..f9cdf8b8324 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsNoProfileTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsNoProfileTest.php @@ -65,7 +65,7 @@ class InstallerExistingSettingsNoProfileTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertEqual('testing', \Drupal::installProfile()); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php index 141f047a3c1..1615f8c6e2d 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php @@ -78,7 +78,7 @@ class InstallerExistingSettingsTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); $this->assertEqual('testing', \Drupal::installProfile()); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguageDirectionTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguageDirectionTest.php index 48d50af4d1e..de7d040ceca 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguageDirectionTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguageDirectionTest.php @@ -46,7 +46,7 @@ class InstallerLanguageDirectionTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php index 692dd314b1c..f08eb5327a8 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerLanguagePageTest.php @@ -43,7 +43,7 @@ class InstallerLanguagePageTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); } } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerNonDefaultDatabaseDriverTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonDefaultDatabaseDriverTest.php index fd2400a6cab..f2672714984 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerNonDefaultDatabaseDriverTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerNonDefaultDatabaseDriverTest.php @@ -52,7 +52,7 @@ class InstallerNonDefaultDatabaseDriverTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Assert that in the settings.php the database connection array has the // correct values set. diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php index b3ad2445292..b7f250d8233 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php @@ -19,7 +19,7 @@ class InstallerTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getAccountName()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php index 3a03aa309a7..4601653bdc2 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php @@ -59,7 +59,7 @@ class InstallerTranslationQueryTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify German was configured but not English. $this->drupalGet('admin/config/regional/language'); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php index 468e2ddba24..fb69ea772d6 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationTest.php @@ -70,7 +70,7 @@ class InstallerTranslationTest extends InstallerTestBase { */ public function testInstaller() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Verify German was configured but not English. $this->drupalGet('admin/config/regional/language'); @@ -89,7 +89,7 @@ class InstallerTranslationTest extends InstallerTestBase { // Ensure that we can enable basic_auth on a non-english site. $this->drupalPostForm('admin/modules', ['modules[basic_auth][enable]' => TRUE], t('Install')); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Assert that the theme CSS was added to the page. $edit = ['preprocess_css' => FALSE]; diff --git a/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php index a0f2069cba5..33bf61f17f6 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php @@ -76,7 +76,7 @@ class MultipleDistributionsProfileTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getAccountName()); diff --git a/core/tests/Drupal/FunctionalTests/Installer/SingleVisibleProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/SingleVisibleProfileTest.php index e632f8dcb7f..99172417022 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/SingleVisibleProfileTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/SingleVisibleProfileTest.php @@ -57,7 +57,7 @@ class SingleVisibleProfileTest extends InstallerTestBase { */ public function testInstalled() { $this->assertUrl('user/1'); - $this->assertResponse(200); + $this->assertSession()->statusCodeEquals(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getAccountName()); // Confirm that the minimal profile was installed.