Issue #3139218 by sja112, mondrake, xjm, ketikagrover, daffie: Replace usages of AssertLegacyTrait::assertResponse(), which is deprecated

merge-requests/28/head
xjm 2020-05-28 14:02:21 -05:00
parent 79495e89d7
commit 8972542f9f
237 changed files with 863 additions and 863 deletions

View File

@ -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);

View File

@ -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 <script>alert(123);</script>');
$this->assertNoRaw('Test feed title <script>alert(123);</script>');
@ -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.

View File

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

View File

@ -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.

View File

@ -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');

View File

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

View File

@ -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.

View File

@ -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&quot; Amp&amp;");
}

View File

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

View File

@ -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.

View File

@ -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');
}

View File

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

View File

@ -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.');
}

View File

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

View File

@ -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

View File

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

View File

@ -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], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>');
$this->assertIdentical($json[$cached_id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $cached_block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>');

View File

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

View File

@ -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);

View File

@ -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);

View File

@ -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('<front>');
$this->assertRaw(t('This block is broken or missing. You may be missing content or you might need to enable the original module.'));
}

View File

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

View File

@ -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) {

View File

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

View File

@ -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');

View File

@ -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.');
}

View File

@ -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'));

View File

@ -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.

View File

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

View File

@ -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).

View File

@ -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.

View File

@ -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');
}

View File

@ -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 = [

View File

@ -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');

View File

@ -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');

View File

@ -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.');
}

View File

@ -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'));

View File

@ -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());
}

View File

@ -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');

View File

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

View File

@ -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];

View File

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

View File

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

View File

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

View File

@ -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');
}

View File

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

View File

@ -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'));

View File

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

View File

@ -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');
}

View File

@ -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'));

View File

@ -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

View File

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

View File

@ -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']);
}
/**

View File

@ -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', '=');

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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' => "&lt;script&gt;alert('foo');&lt;/script&gt;<strong>Lorem</strong> 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(&#039;foo&#039;);Lorem');
$this->assertNoRaw("<script>alert('foo');</script>");

View File

@ -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);

View File

@ -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',

View File

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

View File

@ -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("<script>alert('a configurable field');</script>");

View File

@ -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"]');

View File

@ -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.');

View File

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

View File

@ -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 <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component &#039;http://example.com&#039; is external. You are not allowed to specify an external URL together with internal:/.</em>.');
}
@ -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);
}
}

View File

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

View File

@ -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.');

View File

@ -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

View File

@ -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.');

View File

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

View File

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

View File

@ -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:') . ' <em class="placeholder">' . $extensions . '</em>';
$this->assertRaw($message, 'Cannot upload a disallowed extension');
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
@ -184,7 +184,7 @@ 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') . ' <em class="placeholder">' . $this->phpfile->filename . '.txt' . '</em>';
$this->assertRaw($message, 'Dangerous file was renamed.');
$this->assertRaw(t('File MIME type is text/plain.'), "Dangerous file's MIME type was changed.");
@ -242,7 +242,7 @@ 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.');
}

View File

@ -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:') . ' <em class="placeholder">' . $extensions . '</em>';
$this->assertRaw($message, 'Cannot upload a disallowed extension');
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
@ -204,7 +204,7 @@ 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') . ' <em class="placeholder">' . $this->phpfile->filename . '.txt' . '</em>';
$this->assertRaw($message, 'Dangerous file was renamed.');
$this->assertSession()->pageTextContains('File name is php-2.php.txt.');
@ -261,7 +261,7 @@ 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(),

View File

@ -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);

View File

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

View File

@ -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'), '<front>'),
@ -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 = [

View File

@ -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.

View File

@ -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');
}

View File

@ -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");

View File

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

View File

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

View File

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

View File

@ -80,7 +80,7 @@ class ImageDimensionsTest extends BrowserTestBase {
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="120" height="60" alt="" class="image-style-test" />');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200);
$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), '<img src="' . $url . '" width="60" height="120" alt="" class="image-style-test" />');
$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), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />');
$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), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />');
$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), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />');
$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), '<img src="' . $url . '" alt="" class="image-style-test" />');
$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), '<img src="' . $url . '" width="30" height="30" alt="" class="image-style-test" />');
$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), '<img src="' . $url . '" width="41" height="41" alt="" class="image-style-test" />');
$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), '<img src="' . $url . '" width="100" height="100" alt="" class="image-style-test-uri" />');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200);
$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), '<img src="' . $url . '" width="50" height="50" alt="" class="image-style-test-uri" />');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200);
$this->assertSession()->statusCodeEquals(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 50);

View File

@ -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.

View File

@ -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']));

View File

@ -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.

View File

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

View File

@ -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.

View File

@ -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');
}

View File

@ -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);

View File

@ -97,7 +97,7 @@ class LanguageUrlRewritingTest extends BrowserTestBase {
$prefix = $stored_prefix;
$this->drupalGet("$prefix/$path");
$this->assertResponse(404);
$this->assertSession()->statusCodeEquals(404);
}
/**

View File

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

View File

@ -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.

View File

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

View File

@ -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' => '<front>'], $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');
}

View File

@ -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'));
}

View File

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

View File

@ -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);

View File

@ -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');

View File

@ -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);

Some files were not shown because too many files have changed in this diff Show More