Skip to content

Commit

Permalink
Issue #3139218 by sja112, mondrake, xjm, ketikagrover, daffie: Replac…
Browse files Browse the repository at this point in the history
…e usages of AssertLegacyTrait::assertResponse(), which is deprecated

(cherry picked from commit 8972542f9fdbdd04d86c01002b3f3df7529ff308)
  • Loading branch information
xjm committed May 28, 2020
1 parent f75f77c commit 759f796
Show file tree
Hide file tree
Showing 237 changed files with 863 additions and 863 deletions.
12 changes: 6 additions & 6 deletions modules/action/tests/src/Functional/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testActionConfiguration() {
$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 = [];
Expand All @@ -47,7 +47,7 @@ public function testActionConfiguration() {
$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'];

Expand All @@ -63,7 +63,7 @@ public function testActionConfiguration() {
$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.");
Expand All @@ -77,15 +77,15 @@ public function testActionConfiguration() {
// 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);
Expand Down
6 changes: 3 additions & 3 deletions modules/aggregator/tests/src/Functional/AddFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testAddFeed() {

// 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());

Expand All @@ -61,7 +61,7 @@ public function testFeedLabelEscaping() {
$this->checkForMetaRefresh();

$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200);
$this->assertSession()->statusCodeEquals(200);

$this->assertEscaped('Test feed title <script>alert(123);</script>');
$this->assertNoRaw('Test feed title <script>alert(123);</script>');
Expand Down Expand Up @@ -91,7 +91,7 @@ public function testAddLongFeed() {

// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200);
$this->assertSession()->statusCodeEquals(200);
$this->assertText($feed->label(), 'Page title');

// Delete feeds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testSettingsPage() {
$this->container->get('module_installer')->uninstall(['aggregator_test']);
$this->resetAll();
$this->drupalGet('admin/config/services/aggregator/settings');
$this->assertResponse(200);
$this->assertSession()->statusCodeEquals(200);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ public function testFeedPage() {
// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ public function getDefaultFeedItemCount() {
public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
// First, let's ensure we can get to the rss xml.
$this->drupalGet($feed->getUrl());
$this->assertResponse(200);
$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');
Expand Down
2 changes: 1 addition & 1 deletion modules/aggregator/tests/src/Functional/DeleteFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testDeleteFeed() {

// 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testFeedUpdateFields() {
$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.
Expand Down
6 changes: 3 additions & 3 deletions modules/aggregator/tests/src/Functional/FeedParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testRSS091Sample() {
$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.');
Expand All @@ -60,7 +60,7 @@ public function testAtomSample() {
$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.');
Expand All @@ -84,7 +84,7 @@ public function testHtmlEntitiesSample() {
$feed = $this->createFeed($this->getHtmlEntitiesSample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200);
$this->assertSession()->statusCodeEquals(200);
$this->assertRaw("Quote&quot; Amp&amp;");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testUpdateFeedItem() {
];

$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]']]));
Expand Down Expand Up @@ -75,7 +75,7 @@ public function testUpdateFeedItem() {
$this->enableTestPlugins();
$this->container->get('module_installer')->uninstall(['aggregator_test']);
$this->updateFeedItems($feed);
$this->assertResponse(200);
$this->assertSession()->statusCodeEquals(200);
}

}
2 changes: 1 addition & 1 deletion modules/aggregator/tests/src/Functional/UpdateFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testUpdateFeed() {

// 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.
Expand Down
36 changes: 18 additions & 18 deletions modules/basic_auth/tests/src/Functional/BasicAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testBasicAuth() {
// 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.
Expand All @@ -59,25 +59,25 @@ public function testBasicAuth() {
// 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
Expand Down Expand Up @@ -113,7 +113,7 @@ public function testGlobalLoginFloodControl() {

// IP limit has reached to its limit. Even valid user credentials will fail.
$this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw);
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
}

/**
Expand All @@ -137,7 +137,7 @@ public function testPerUserLoginFloodControl() {

// A successful login will reset the per-user flood control count.
$this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw);
$this->assertResponse(200);
$this->assertSession()->statusCodeEquals(200);

// Try 2 failed logins for a user. They will trigger flood control.
for ($i = 0; $i < 2; $i++) {
Expand All @@ -146,12 +146,12 @@ public function testPerUserLoginFloodControl() {

// 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);
}

/**
Expand All @@ -166,7 +166,7 @@ public function testLocale() {

$this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw);
$this->assertText($account->getAccountName(), 'Account name is displayed.');
$this->assertResponse(200);
$this->assertSession()->statusCodeEquals(200);
}

/**
Expand All @@ -178,24 +178,24 @@ public function testUnauthorizedErrorMessage() {

// 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");
}

Expand Down Expand Up @@ -247,19 +247,19 @@ public function testCacheabilityOf401Response() {
*/
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');
}

Expand Down
4 changes: 2 additions & 2 deletions modules/block/tests/src/Functional/BlockAdminThemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public function testAdminTheme() {
// 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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions modules/block/tests/src/Functional/BlockCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ public function testCachePerPage() {
\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.');
}

Expand Down
6 changes: 3 additions & 3 deletions modules/block/tests/src/Functional/BlockDemoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testBlockDemo() {
$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);

Expand All @@ -55,14 +55,14 @@ public function testBlockDemo() {
$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);
}

}
4 changes: 2 additions & 2 deletions modules/block/tests/src/Functional/BlockFormInBlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testCachePerPage() {

// 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
Expand All @@ -53,7 +53,7 @@ public function testCachePerPage() {

// 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
Expand Down

0 comments on commit 759f796

Please sign in to comment.