Issue #3132964 by jungle, longwave, sja112, dww, xjm, daffie: assertResponse() does not actually support a $message parameter, so stop passing one

merge-requests/2419/head
xjm 2020-05-22 12:37:50 -05:00
parent 6e78799528
commit f09c890298
77 changed files with 335 additions and 292 deletions

View File

@ -35,7 +35,7 @@ class AddFeedTest extends AggregatorTestBase {
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200, 'Feed source exists.');
$this->assertResponse(200);
$this->assertText($feed->label(), 'Page title');
$this->assertRaw($feed->getWebsiteUrl());
@ -91,7 +91,7 @@ class AddFeedTest extends AggregatorTestBase {
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200, 'Long URL feed source exists.');
$this->assertResponse(200);
$this->assertText($feed->label(), 'Page title');
// Delete feeds.

View File

@ -181,7 +181,7 @@ abstract class AggregatorTestBase extends BrowserTestBase {
public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
// First, let's ensure we can get to the rss xml.
$this->drupalGet($feed->getUrl());
$this->assertResponse(200, new FormattableMarkup(':url is reachable.', [':url' => $feed->getUrl()]));
$this->assertResponse(200);
// Attempt to access the update link directly without an access token.
$this->drupalGet('admin/config/services/aggregator/update/' . $feed->id());

View File

@ -45,7 +45,7 @@ class DeleteFeedTest extends AggregatorTestBase {
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed1->id());
$this->assertResponse(404, 'Deleted feed source does not exist.');
$this->assertResponse(404);
// Check database for feed.
$result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed1->label())->condition('url', $feed1->getUrl())->count()->execute();

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, 'Aggregator feed overview page exists.');
$this->assertResponse(200);
// The scheduled feed shows that it has not been updated yet and is
// scheduled.

View File

@ -2,7 +2,6 @@
namespace Drupal\Tests\aggregator\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\aggregator\FeedStorageInterface;
use Drupal\Core\Url;
use Drupal\aggregator\Entity\Feed;
@ -38,7 +37,7 @@ class FeedParserTest extends AggregatorTestBase {
$feed = $this->createFeed($this->getRSS091Sample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200, new FormattableMarkup('Feed %name exists.', ['%name' => $feed->label()]));
$this->assertResponse(200);
$this->assertText('First example feed item title');
$this->assertLinkByHref('http://example.com/example-turns-one');
$this->assertText('First example feed item description.');
@ -61,7 +60,7 @@ class FeedParserTest extends AggregatorTestBase {
$feed = $this->createFeed($this->getAtomSample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200, new FormattableMarkup('Feed %name exists.', ['%name' => $feed->label()]));
$this->assertResponse(200);
$this->assertText('Atom-Powered Robots Run Amok');
$this->assertLinkByHref('http://example.org/2003/12/13/atom03');
$this->assertText('Some text.');
@ -85,7 +84,7 @@ class FeedParserTest extends AggregatorTestBase {
$feed = $this->createFeed($this->getHtmlEntitiesSample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200, new FormattableMarkup('Feed %name exists.', ['%name' => $feed->label()]));
$this->assertResponse(200);
$this->assertRaw("Quote" Amp&");
}

View File

@ -44,7 +44,7 @@ class UpdateFeedTest extends AggregatorTestBase {
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200, 'Feed source exists.');
$this->assertResponse(200);
$this->assertText($edit['title[0][value]'], 'Page title');
// Set correct title so deleteFeed() will work.

View File

@ -47,31 +47,37 @@ class BasicAuthTest extends BrowserTestBase {
$account = $this->drupalCreateUser();
$url = Url::fromRoute('router_test.11');
// Ensure we can log in with valid authentication details.
$this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw);
$this->assertText($account->getAccountName(), 'Account name is displayed.');
$this->assertResponse('200', 'HTTP response is OK');
$this->assertResponse(200);
$this->mink->resetSessions();
$this->assertNull($this->drupalGetHeader('X-Drupal-Cache'));
// Check that Cache-Control is not set to public.
$this->assertSession()->responseHeaderNotContains('Cache-Control', 'public');
// Ensure that invalid authentication details give access denied.
$this->basicAuthGet($url, $account->getAccountName(), $this->randomMachineName());
$this->assertNoText($account->getAccountName(), 'Bad basic auth credentials do not authenticate the user.');
$this->assertResponse('403', 'Access is not granted.');
$this->assertResponse(403);
$this->mink->resetSessions();
// Ensure that the user is prompted to authenticate if they are not yet
// authenticated and the route only allows basic auth.
$this->drupalGet($url);
$this->assertEqual($this->drupalGetHeader('WWW-Authenticate'), new FormattableMarkup('Basic realm="@realm"', ['@realm' => \Drupal::config('system.site')->get('name')]));
$this->assertResponse('401', 'Not authenticated on the route that allows only basic_auth. Prompt to authenticate received.');
$this->assertResponse(401);
// Ensure that a route without basic auth defined doesn't prompt for auth.
$this->drupalGet('admin');
$this->assertResponse('403', 'No authentication prompt for routes not explicitly defining authentication providers.');
$this->assertResponse(403);
$account = $this->drupalCreateUser(['access administration pages']);
// Ensure that a route without basic auth defined doesn't allow login.
$this->basicAuthGet(Url::fromRoute('system.admin'), $account->getAccountName(), $account->pass_raw);
$this->assertNoLink('Log out', 'User is not logged in');
$this->assertResponse('403', 'No basic authentication for routes not explicitly defining authentication providers.');
$this->assertResponse(403);
$this->mink->resetSessions();
// Ensure that pages already in the page cache aren't returned from page
@ -107,7 +113,7 @@ class BasicAuthTest extends BrowserTestBase {
// IP limit has reached to its limit. Even valid user credentials will fail.
$this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw);
$this->assertResponse('403', 'Access is blocked because of IP based flood prevention.');
$this->assertResponse(403);
}
/**
@ -131,7 +137,7 @@ class BasicAuthTest extends BrowserTestBase {
// A successful login will reset the per-user flood control count.
$this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw);
$this->assertResponse('200', 'Per user flood prevention gets reset on a successful login.');
$this->assertResponse(200);
// Try 2 failed logins for a user. They will trigger flood control.
for ($i = 0; $i < 2; $i++) {
@ -140,12 +146,12 @@ class BasicAuthTest extends BrowserTestBase {
// Now the user account is blocked.
$this->basicAuthGet($url, $user->getAccountName(), $user->pass_raw);
$this->assertResponse('403', 'The user account is blocked due to per user flood prevention.');
$this->assertResponse(403);
// Try one successful attempt for a different user, it should not trigger
// any flood control.
$this->basicAuthGet($url, $user2->getAccountName(), $user2->pass_raw);
$this->assertResponse('200', 'Per user flood prevention does not block access for other users.');
$this->assertResponse(200);
}
/**
@ -160,7 +166,7 @@ class BasicAuthTest extends BrowserTestBase {
$this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw);
$this->assertText($account->getAccountName(), 'Account name is displayed.');
$this->assertResponse('200', 'HTTP response is OK');
$this->assertResponse(200);
}
/**
@ -172,24 +178,24 @@ class BasicAuthTest extends BrowserTestBase {
// Case when no credentials are passed.
$this->drupalGet($url);
$this->assertResponse('401', 'The user is blocked when no credentials are passed.');
$this->assertResponse(401);
$this->assertNoText('Exception', "No raw exception is displayed on the page.");
$this->assertText('Please log in to access this page.', "A user friendly access unauthorized message is displayed.");
// Case when empty credentials are passed.
$this->basicAuthGet($url, NULL, NULL);
$this->assertResponse('403', 'The user is blocked when empty credentials are passed.');
$this->assertResponse(403);
$this->assertText('Access denied', "A user friendly access denied message is displayed");
// Case when wrong credentials are passed.
$this->basicAuthGet($url, $account->getAccountName(), $this->randomMachineName());
$this->assertResponse('403', 'The user is blocked when wrong credentials are passed.');
$this->assertResponse(403);
$this->assertText('Access denied', "A user friendly access denied message is displayed");
// Case when correct credentials but hasn't access to the route.
$url = Url::fromRoute('router_test.15');
$this->basicAuthGet($url, $account->getAccountName(), $account->pass_raw);
$this->assertResponse('403', 'The used authentication method is not allowed on this route.');
$this->assertResponse(403);
$this->assertText('Access denied', "A user friendly access denied message is displayed");
}

View File

@ -94,13 +94,15 @@ class BlockUiTest extends BrowserTestBase {
$elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', [':title' => 'Highlighted']);
$this->assertTrue(!empty($elements), 'Block demo regions are shown.');
// Ensure that other themes can use the block demo page.
\Drupal::service('theme_installer')->install(['test_theme']);
$this->drupalGet('admin/structure/block/demo/test_theme');
$this->assertEscaped('<strong>Test theme</strong>');
// Ensure that a hidden theme cannot use the block demo page.
\Drupal::service('theme_installer')->install(['stable']);
$this->drupalGet('admin/structure/block/demo/stable');
$this->assertResponse(404, 'Hidden themes that are not the default theme are not supported by the block demo screen');
$this->assertResponse(404);
}
/**
@ -159,16 +161,19 @@ class BlockUiTest extends BrowserTestBase {
$this->assertLink($theme_handler->getName('stark'));
$this->assertNoLink($theme_handler->getName('stable'));
// Ensure that a hidden theme cannot use the block demo page.
$this->drupalGet('admin/structure/block/list/stable');
$this->assertResponse(404, 'Placing blocks through UI is not possible for a hidden base theme.');
$this->assertResponse(404);
// Ensure that a hidden theme set as the admin theme can use the block demo
// page.
\Drupal::configFactory()->getEditable('system.theme')->set('admin', 'stable')->save();
\Drupal::service('router.builder')->rebuildIfNeeded();
$this->drupalPlaceBlock('local_tasks_block', ['region' => 'header', 'theme' => 'stable']);
$this->drupalGet('admin/structure/block');
$this->assertLink($theme_handler->getName('stable'));
$this->drupalGet('admin/structure/block/list/stable');
$this->assertResponse(200, 'Placing blocks through UI is possible for a hidden base theme that is the admin theme.');
$this->assertResponse(200);
}
/**

View File

@ -31,8 +31,8 @@ class BlockContentPageViewTest extends BlockContentTestBase {
// Attempt to view the block.
$this->drupalGet('block-content/' . $block->id());
// Assert response was '200' and not '403 Access denied'.
$this->assertResponse('200', 'User was able the view the block');
// Ensure user was able to view the block.
$this->assertResponse(200);
$this->drupalGet('<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

@ -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', 'Unsupported export format returned "not found".');
$this->assertResponse(404);
// Make sure we get a 404 on a not existing book node.
$this->drupalGet('book/export/html/123');
$this->assertResponse('404', 'Not existing book node returned "not found".');
$this->assertResponse(404);
// Make sure an anonymous user cannot view printer-friendly version.
$this->drupalLogout();
@ -229,14 +229,14 @@ class BookTest extends BrowserTestBase {
// Try getting the URL directly, and verify it fails.
$this->drupalGet('book/export/html/' . $this->book->id());
$this->assertResponse('403', 'Anonymous user properly forbidden.');
$this->assertResponse(403);
// Now grant anonymous users permission to view the printer-friendly
// version and verify that node access restrictions still prevent them from
// seeing it.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access printer-friendly version']);
$this->drupalGet('book/export/html/' . $this->book->id());
$this->assertResponse('403', 'Anonymous user properly forbidden from seeing the printer-friendly version when denied by node access.');
$this->assertResponse(403);
}
/**
@ -356,9 +356,11 @@ class BookTest extends BrowserTestBase {
$this->drupalLogin($this->adminUser);
$edit = [];
// Test access to delete top-level and child book nodes.
// Ensure that the top-level book node cannot be deleted.
$this->drupalGet('node/' . $this->book->id() . '/outline/remove');
$this->assertResponse('403', 'Deleting top-level book node properly forbidden.');
$this->assertResponse(403);
// Ensure that a child book node can be deleted.
$this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove'));
$node_storage->resetCache([$nodes[4]->id()]);
$node4 = $node_storage->load($nodes[4]->id());

View File

@ -156,12 +156,14 @@ class CommentAdminTest extends CommentTestBase {
$this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.');
// Approve comment.
// Ensure comments cannot be approved without a valid token.
$this->drupalLogin($this->adminUser);
$this->drupalGet('comment/1/approve');
$this->assertResponse(403, 'Forged comment approval was denied.');
$this->assertResponse(403);
$this->drupalGet('comment/1/approve', ['query' => ['token' => 'forged']]);
$this->assertResponse(403, 'Forged comment approval was denied.');
$this->assertResponse(403);
// Approve comment.
$this->drupalGet('comment/1/edit');
$this->assertFieldChecked('edit-status-0');
$this->drupalGet('node/' . $this->node->id());

View File

@ -64,8 +64,9 @@ class CommentTypeTest extends CommentTestBase {
// Log in a test user.
$this->drupalLogin($this->adminUser);
// Ensure that the new comment type admin page can be accessed.
$this->drupalGet('admin/structure/comment/manage/' . $type->id());
$this->assertResponse(200, 'The new comment type can be accessed at the edit form.');
$this->assertResponse(200);
// Create a comment type via the user interface.
$edit = [

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, 'User can access the download callback.');
$this->assertResponse(200);
// Test if header contains file name with hostname and timestamp.
$request = \Drupal::request();

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, 'The page exists');
$this->assertResponse(200);
$this->assertNoField('edit-langcode-0-value');
// Enable language select from content language settings page.
@ -62,7 +62,7 @@ class ContactLanguageTest extends BrowserTestBase {
// Ensure that contact form now shows the language select.
$this->drupalGet('contact');
$this->assertResponse(200, 'The page exists');
$this->assertResponse(200);
$this->assertField('edit-langcode-0-value');
}

View File

@ -137,7 +137,7 @@ class ContactPersonalTest extends BrowserTestBase {
$original_email = $this->contactUser->getEmail();
$this->contactUser->setEmail(FALSE)->save();
$this->drupalGet('user/' . $this->contactUser->id() . '/contact');
$this->assertResponse(404, 'Not found (404) returned when visiting a personal contact form for a user with no email address');
$this->assertResponse(404);
// Test that the 'contact tab' does not appear on the user profiles
// for users without an email address configured.

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, 'Entity URL is valid.');
$this->assertResponse(200);
// Ensure that the content language cache context is not yet added to the
// page.

View File

@ -163,26 +163,25 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
protected function doTestWorkflows(UserInterface $user, $expected_status) {
$default_langcode = $this->langcodes[0];
$languages = $this->container->get('language_manager')->getLanguages();
$args = ['@user_label' => $user->getAccountName()];
$options = ['language' => $languages[$default_langcode], 'absolute' => TRUE];
$this->drupalLogin($user);
// Check whether the user is allowed to access the entity form in edit mode.
$edit_url = $this->entity->toUrl('edit-form', $options);
$this->drupalGet($edit_url, $options);
$this->assertResponse($expected_status['edit'], new FormattableMarkup('The @user_label has the expected edit access.', $args));
$this->assertResponse($expected_status['edit']);
// Check whether the user is allowed to access the entity delete form.
$delete_url = $this->entity->toUrl('delete-form', $options);
$this->drupalGet($delete_url, $options);
$this->assertResponse($expected_status['delete'], new FormattableMarkup('The @user_label has the expected delete access.', $args));
$this->assertResponse($expected_status['delete']);
// Check whether the user is allowed to access the translation overview.
$langcode = $this->langcodes[1];
$options['language'] = $languages[$langcode];
$translations_url = $this->entity->toUrl('drupal:content-translation-overview', $options)->toString();
$this->drupalGet($translations_url);
$this->assertResponse($expected_status['overview'], new FormattableMarkup('The @user_label has the expected translation overview access.', $args));
$this->assertResponse($expected_status['overview']);
// Check whether the user is allowed to create a translation.
$add_translation_url = Url::fromRoute("entity.$this->entityTypeId.content_translation_add", [$this->entityTypeId => $this->entity->id(), 'source' => $default_langcode, 'target' => $langcode], $options);
@ -198,7 +197,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
else {
$this->drupalGet($add_translation_url);
}
$this->assertResponse($expected_status['add_translation'], new FormattableMarkup('The @user_label has the expected translation creation access.', $args));
$this->assertResponse($expected_status['add_translation']);
// Check whether the user is allowed to edit a translation.
$langcode = $this->langcodes[2];
@ -226,7 +225,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
else {
$this->drupalGet($edit_translation_url);
}
$this->assertResponse($expected_status['edit_translation'], new FormattableMarkup('The @user_label has the expected translation edit access.', $args));
$this->assertResponse($expected_status['edit_translation']);
// Check whether the user is allowed to delete a translation.
$langcode = $this->langcodes[2];
@ -254,7 +253,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
else {
$this->drupalGet($delete_translation_url);
}
$this->assertResponse($expected_status['delete_translation'], new FormattableMarkup('The @user_label has the expected translation deletion access.', $args));
$this->assertResponse($expected_status['delete_translation']);
}
/**

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, 'Correctly allowed access to a file when file_test provides headers.');
$this->assertResponse(200);
// Ensure hook_file_download is fired correctly.
$this->assertEquals($file->getFileUri(), \Drupal::state()->get('file_test.results')['download'][0][0]);

View File

@ -40,7 +40,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
// Load the node form.
$this->drupalLogout();
$this->drupalGet('node/add/article');
$this->assertResponse(200, 'Loaded the article node form.');
$this->assertResponse(200);
$this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label])));
$edit = [
@ -71,7 +71,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
// Load the node form.
$this->drupalLogout();
$this->drupalGet('node/add/article');
$this->assertResponse(200, 'Loaded the article node form.');
$this->assertResponse(200);
$this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label])));
// Generate an image file.
@ -128,7 +128,7 @@ class FileFieldAnonymousSubmissionTest extends FileFieldTestBase {
// Load the node form.
$this->drupalGet('node/add/article');
$this->assertResponse(200, 'Loaded the article node form.');
$this->assertResponse(200);
$this->assertText(strip_tags(t('Create @name', ['@name' => $bundle_label])));
// Generate an image file.

View File

@ -93,7 +93,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Ensure the file can be downloaded.
$this->drupalGet($node_file->createFileUrl());
$this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.');
$this->assertResponse(200);
// Ensure the edit page has a remove button instead of an upload button.
$this->drupalGet("node/$nid/edit");
@ -267,7 +267,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Ensure the private file is available to the user who uploaded it.
$this->drupalGet($node_file->createFileUrl());
$this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.');
$this->assertResponse(200);
// Ensure we can't change 'uri_scheme' field settings while there are some
// entities with uploaded files.
@ -335,12 +335,12 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$url = $comment_file->createFileUrl();
$this->assertNotEqual($url, NULL, 'Confirmed that the URL is valid');
$this->drupalGet($comment_file->createFileUrl());
$this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.');
$this->assertResponse(200);
// Test anonymous file download.
// Ensure that the anonymous user cannot download the file.
$this->drupalLogout();
$this->drupalGet($comment_file->createFileUrl());
$this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.');
$this->assertResponse(403);
// Unpublishes node.
$this->drupalLogin($this->adminUser);
@ -350,7 +350,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Ensures normal user can no longer download the file.
$this->drupalLogin($user);
$this->drupalGet($comment_file->createFileUrl());
$this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.');
$this->assertResponse(403);
}
/**
@ -512,7 +512,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Ensure the file can be downloaded.
$this->drupalGet($node_file->createFileUrl());
$this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.');
$this->assertResponse(200);
// "Click" the remove button (emulating either a nojs or js submission).
// In this POST request, the attacker "guesses" the fid of the victim's

View File

@ -60,10 +60,11 @@ class FilePrivateTest extends FileFieldTestBase {
$this->assertRaw($node_file->getFilename(), 'File reference is displayed after attaching it');
// Ensure the file can be downloaded.
$this->drupalGet(file_create_url($node_file->getFileUri()));
$this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.');
$this->assertResponse(200);
$this->drupalLogOut();
// Ensure the file cannot be downloaded after logging out.
$this->drupalGet(file_create_url($node_file->getFileUri()));
$this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.');
$this->assertResponse(403);
// Create a field with no view access. See
// field_test_entity_field_access().
@ -79,7 +80,7 @@ class FilePrivateTest extends FileFieldTestBase {
// Ensure the file cannot be downloaded.
$file_url = file_create_url($node_file->getFileUri());
$this->drupalGet($file_url);
$this->assertResponse(403, 'Confirmed that access is denied for the file without view field access permission.');
$this->assertResponse(403);
// Attempt to reuse the file when editing a node.
$edit = [];
@ -114,20 +115,20 @@ class FilePrivateTest extends FileFieldTestBase {
\Drupal::state()->set('file_test.allow_all', TRUE);
// Delete the node.
$node->delete();
// Ensure the file can still be downloaded by the owner.
// Ensure the temporary file can still be downloaded by the owner.
$this->drupalGet($file_url);
$this->assertResponse(200, 'Confirmed that the owner still has access to the temporary file.');
$this->assertResponse(200);
// Ensure the file cannot be downloaded by an anonymous user.
// Ensure the temporary file cannot be downloaded by an anonymous user.
$this->drupalLogout();
$this->drupalGet($file_url);
$this->assertResponse(403, 'Confirmed that access is denied for an anonymous user to the temporary file.');
$this->assertResponse(403);
// Ensure the file cannot be downloaded by another user.
// Ensure the temporary file cannot be downloaded by another user.
$account = $this->drupalCreateUser();
$this->drupalLogin($account);
$this->drupalGet($file_url);
$this->assertResponse(403, 'Confirmed that access is denied for another user to the temporary file.');
$this->assertResponse(403);
// As an anonymous user, create a temporary file with no references and
// confirm that only the session that uploaded it may view it.
@ -152,12 +153,14 @@ class FilePrivateTest extends FileFieldTestBase {
$usage = $this->container->get('file.usage')->listUsage($file);
$this->assertEmpty($usage, 'No file usage found.');
$file_url = file_create_url($file->getFileUri());
// Ensure the anonymous uploader has access to the temporary file.
$this->drupalGet($file_url);
$this->assertResponse(200, 'Confirmed that the anonymous uploader has access to the temporary file.');
$this->assertResponse(200);
// Close the prior connection and remove the session cookie.
$this->getSession()->reset();
// Ensure that a different anonymous user cannot access the temporary file.
$this->drupalGet($file_url);
$this->assertResponse(403, 'Confirmed that another anonymous user cannot access the temporary file.');
$this->assertResponse(403);
// As an anonymous user, create a permanent file, then remove all
// references to the file (so that it becomes temporary again) and confirm
@ -180,12 +183,14 @@ class FilePrivateTest extends FileFieldTestBase {
$usage = $this->container->get('file.usage')->listUsage($file);
$this->assertEmpty($usage, 'No file usage found.');
$file_url = file_create_url($file->getFileUri());
// Ensure the anonymous uploader has access to the temporary file.
$this->drupalGet($file_url);
$this->assertResponse(200, 'Confirmed that the anonymous uploader has access to the file whose references were removed.');
$this->assertResponse(200);
// Close the prior connection and remove the session cookie.
$this->getSession()->reset();
// Ensure that a different anonymous user cannot access the temporary file.
$this->drupalGet($file_url);
$this->assertResponse(403, 'Confirmed that another anonymous user cannot access the file whose references were removed.');
$this->assertResponse(403);
// As an anonymous user, create a permanent file that is referenced by a
// published node and confirm that all anonymous users may view it.
@ -201,12 +206,14 @@ class FilePrivateTest extends FileFieldTestBase {
$usage = $this->container->get('file.usage')->listUsage($file);
$this->assertCount(1, $usage, 'File usage found.');
$file_url = file_create_url($file->getFileUri());
// Ensure the anonymous uploader has access to the file.
$this->drupalGet($file_url);
$this->assertResponse(200, 'Confirmed that the anonymous uploader has access to the permanent file that is referenced by a published node.');
$this->assertResponse(200);
// Close the prior connection and remove the session cookie.
$this->getSession()->reset();
// Ensure that a different anonymous user can access the file.
$this->drupalGet($file_url);
$this->assertResponse(200, 'Confirmed that another anonymous user also has access to the permanent file that is referenced by a published node.');
$this->assertResponse(200);
// As an anonymous user, create a permanent file that is referenced by an
// unpublished node and confirm that no anonymous users may view it (even
@ -226,12 +233,14 @@ class FilePrivateTest extends FileFieldTestBase {
$usage = $this->container->get('file.usage')->listUsage($file);
$this->assertCount(1, $usage, 'File usage found.');
$file_url = file_create_url($file->getFileUri());
// Ensure the anonymous uploader cannot access to the file.
$this->drupalGet($file_url);
$this->assertResponse(403, 'Confirmed that the anonymous uploader cannot access the permanent file when it is referenced by an unpublished node.');
$this->assertResponse(403);
// Close the prior connection and remove the session cookie.
$this->getSession()->reset();
// Ensure that a different anonymous user cannot access the temporary file.
$this->drupalGet($file_url);
$this->assertResponse(403, 'Confirmed that another anonymous user cannot access the permanent file when it is referenced by an unpublished node.');
$this->assertResponse(403);
}
}

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, 'Confirmed that the file attached to the English node can be downloaded.');
$this->assertResponse(200);
// Translate the node into French.
$this->drupalGet('node/' . $default_language_node->id() . '/translations');
@ -123,7 +123,7 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase {
$french_node = $default_language_node->getTranslation('fr');
$node_file = File::load($french_node->{$this->fieldName}->target_id);
$this->drupalGet(file_create_url($node_file->getFileUri()));
$this->assertResponse(200, 'Confirmed that the file attached to the French node can be downloaded.');
$this->assertResponse(200);
}
}

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, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called then clean out the hook
@ -115,7 +115,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$file_system = \Drupal::service('file_system');
$edit = ['files[file_test_upload][]' => $file_system->realpath($image2->uri)];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'));
$max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max'];
@ -141,7 +141,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'file_subdir' => $dir,
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'));
$this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath)));
}
@ -164,7 +164,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$message = t('Only files with the following extensions are allowed:') . ' <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, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload an allowed extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -201,7 +201,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'allow_all_extensions' => TRUE,
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload any extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -226,7 +226,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$message = t('For security reasons, your upload has been renamed to') . ' <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, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
$this->assertRaw(t('File name is @filename', ['@filename' => $this->phpfile->filename]), 'Dangerous file was not renamed when insecure uploads is TRUE.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -278,7 +278,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$munged_filename .= '_.' . $this->imageExtension;
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
$this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -296,7 +296,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
$this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -316,7 +316,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
@ -334,7 +334,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called.
@ -352,7 +352,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
// Check that the no hooks were called while failing.
@ -385,7 +385,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
\Drupal::state()->set('file_test.disable_error_collection', TRUE);
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('File upload error. Could not move uploaded file.'), 'Found the failure message.');
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
@ -411,7 +411,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'error_message' => $error,
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Ensure the expected error message is present and the counts before and
@ -427,7 +427,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'extensions' => 'foo',
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
// Ensure the expected error message is present and the counts before and
@ -441,7 +441,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'files[file_test_upload][]' => $file_system->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Ensure the error message is not present and the counts before and after
@ -475,8 +475,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
$files['files']['file_test_upload'][0] = $file_system->realpath($this->phpfile->uri);
$files['files']['file_test_upload'][1] = $file_system->realpath($textfile->uri);
$client->request($form->getMethod(), $form->getUri(), $edit, $files);
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
// Search for combined error message followed by a formatted list of messages.
@ -496,7 +495,7 @@ class SaveUploadFormTest extends FileManagedTestBase {
'extensions' => 'foo',
];
$this->drupalPostForm('file-test/save_upload_from_form_test', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
$this->assertCount(1, $this->cssSelect('input[name="files[file_test_upload][]"].error'), 'File upload field has error.');
}

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, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
// Check that the correct hooks were called then clean out the hook
@ -108,7 +108,7 @@ class SaveUploadTest extends FileManagedTestBase {
$image2 = current($this->drupalGetTestFiles('image'));
$edit = ['files[file_test_upload]' => \Drupal::service('file_system')->realpath($image2->uri)];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'));
$max_fid_after = (int) \Drupal::entityQueryAggregate('file')->aggregate('fid', 'max')->execute()[0]['fid_max'];
@ -134,7 +134,7 @@ class SaveUploadTest extends FileManagedTestBase {
'file_subdir' => $dir,
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'));
$this->assertFileExists('temporary://' . $dir . '/' . trim(\Drupal::service('file_system')->basename($image3_realpath)));
}
@ -184,7 +184,7 @@ class SaveUploadTest extends FileManagedTestBase {
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$message = t('Only files with the following extensions are allowed:') . ' <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, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload an allowed extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -221,7 +221,7 @@ class SaveUploadTest extends FileManagedTestBase {
'allow_all_extensions' => TRUE,
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertNoRaw(t('Only files with the following extensions are allowed:'), 'Can upload any extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -244,7 +244,7 @@ class SaveUploadTest extends FileManagedTestBase {
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$message = t('For security reasons, your upload has been renamed to') . ' <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, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
$this->assertSession()->pageTextContains('File name is php-2.php.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -295,7 +295,7 @@ class SaveUploadTest extends FileManagedTestBase {
$munged_filename .= '_.' . $this->imageExtension;
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('For security reasons, your upload has been renamed'), 'Found security message.');
$this->assertRaw(t('File name is @filename', ['@filename' => $munged_filename]), 'File was successfully munged.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -313,7 +313,7 @@ class SaveUploadTest extends FileManagedTestBase {
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertNoRaw(t('For security reasons, your upload has been renamed'), 'Found no security message.');
$this->assertRaw(t('File name is @filename', ['@filename' => $this->image->getFilename()]), 'File was not munged when allowing any extension.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
@ -331,7 +331,7 @@ class SaveUploadTest extends FileManagedTestBase {
'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
$this->assertSession()->pageTextContains('File name is image-test_0.png.');
@ -348,7 +348,7 @@ class SaveUploadTest extends FileManagedTestBase {
'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
$this->assertSession()->pageTextContains('File name is image-test.png.');
@ -365,7 +365,7 @@ class SaveUploadTest extends FileManagedTestBase {
'files[file_test_upload]' => \Drupal::service('file_system')->realpath($this->image->getFileUri()),
];
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');
// Check that the no hooks were called while failing.
@ -398,7 +398,7 @@ class SaveUploadTest extends FileManagedTestBase {
\Drupal::state()->set('file_test.disable_error_collection', TRUE);
$this->drupalPostForm('file-test/upload', $edit, t('Submit'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('File upload error. Could not move uploaded file.'), 'Found the failure message.');
$this->assertRaw(t('Epic upload FAIL!'), 'Found the failure message.');

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, 'Disabled text format no longer exists.');
$this->assertResponse(404);
// Attempt to create a format of the same machine name as the disabled
// format but with a different human readable name.
@ -203,7 +203,7 @@ class FilterAdminTest extends BrowserTestBase {
$this->drupalGet('admin/config/content/formats');
$this->assertNoRaw('admin/config/content/formats/manage/' . $plain . '/disable', 'Disable link for the fallback format not found.');
$this->drupalGet('admin/config/content/formats/manage/' . $plain . '/disable');
$this->assertResponse(403, 'The fallback format cannot be disabled.');
$this->assertResponse(403);
// Verify access permissions to Full HTML format.
$full_format = FilterFormat::load($full);

View File

@ -491,7 +491,7 @@ class ForumTest extends BrowserTestBase {
// Assert that the forum no longer exists.
$this->drupalGet('forum/' . $tid);
$this->assertResponse(404, 'The forum was not found');
$this->assertResponse(404);
}
/**

View File

@ -47,8 +47,10 @@ class NoHelpTest extends BrowserTestBase {
$this->assertFalse(\Drupal::moduleHandler()->implementsHook('menu_test', 'help'), 'The menu_test module does not implement hook_help');
$this->assertNoText(\Drupal::moduleHandler()->getName('menu_test'), 'Making sure the test module menu_test does not display a help link on admin/help.');
// Ensure that the module overview help page for a module that does not
// implement hook_help() results in a 404.
$this->drupalGet('admin/help/menu_test');
$this->assertResponse(404, 'Getting a module overview help page for a module that does not implement hook_help() results in a 404.');
$this->assertResponse(404);
}
}

View File

@ -217,7 +217,6 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Check that the URL was updated.
$this->drupalGet($style_path);
$this->assertTitle(t('Edit style @name | Drupal', ['@name' => $style_label]));
$this->assertResponse(200, new FormattableMarkup('Image style %original renamed to %new', ['%original' => $style->id(), '%new' => $style_name]));
// Check that the available image effects are properly sorted.
$option = $this->xpath('//select[@id=:id]//option', [':id' => 'edit-new--2']);

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, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 120);
@ -101,7 +101,7 @@ class ImageDimensionsTest extends BrowserTestBase {
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="60" height="120" alt="" class="image-style-test" />');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 60);
@ -123,7 +123,7 @@ 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, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 45);
@ -145,7 +145,7 @@ class ImageDimensionsTest extends BrowserTestBase {
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="45" height="90" alt="" class="image-style-test" />');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 45);
@ -163,7 +163,7 @@ 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, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 45);
@ -184,7 +184,7 @@ class ImageDimensionsTest extends BrowserTestBase {
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" alt="" class="image-style-test" />');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
// Add a crop effect.
@ -203,7 +203,7 @@ 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, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 30);
@ -226,7 +226,7 @@ class ImageDimensionsTest extends BrowserTestBase {
// $this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="41" height="41" alt="" class="image-style-test" />');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
// @todo Uncomment this once
@ -270,7 +270,7 @@ 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, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 100);
@ -284,7 +284,7 @@ class ImageDimensionsTest extends BrowserTestBase {
$this->assertEqual($this->getImageTag($variables), '<img src="' . $url . '" width="50" height="50" alt="" class="image-style-test-uri" />');
$this->assertFileNotExists($generated_uri);
$this->drupalGet($this->getAbsoluteUrl($url));
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
$image_file = $image_factory->get($generated_uri);
$this->assertEqual($image_file->getWidth(), 50);

View File

@ -152,10 +152,10 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', 'Content-Type header was sent.');
$this->assertTrue(strstr($this->drupalGetHeader('Cache-Control'), 'private') !== FALSE, 'Cache-Control header was sent.');
// Log out and try to access the file.
// Log out and ensure the file cannot be accessed.
$this->drupalLogout();
$this->drupalGet(file_create_url($image_uri));
$this->assertResponse('403', 'Access denied to original image as anonymous user.');
$this->assertResponse(403);
// Log in again.
$this->drupalLogin($this->adminUser);
@ -211,10 +211,10 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertRaw($default_output, 'Image style thumbnail formatter displaying correctly on full node view.');
if ($scheme == 'private') {
// Log out and try to access the file.
// Log out and ensure the file cannot be accessed.
$this->drupalLogout();
$this->drupalGet(ImageStyle::load('thumbnail')->buildUrl($image_uri));
$this->assertResponse('403', 'Access denied to image style thumbnail as anonymous user.');
$this->assertResponse(403);
}
// Test the image URL formatter without an image style.

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, 'Accessing an image style URL with a source image that does not exist provides a 404 error response.');
$this->assertResponse(404);
}
/**
@ -185,10 +185,10 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
}
// Add some extra chars to the token.
$this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url));
$this->assertResponse(404, 'Image was inaccessible at the URL with an invalid token.');
$this->assertResponse(404);
// Change the parameter name so the token is missing.
$this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', 'wrongparam=', $generate_url));
$this->assertResponse(404, 'Image was inaccessible at the URL with a missing token.');
$this->assertResponse(404);
// Check that the generated URL is the same when we pass in a relative path
// rather than a URI. We need to temporarily switch the default scheme to
@ -202,7 +202,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
// Fetch the URL that generates the file.
$this->drupalGet($generate_url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertResponse(200);
$this->assertFileExists($generated_uri);
// assertRaw can't be used with string containing non UTF-8 chars.
$this->assertNotEmpty(file_get_contents($generated_uri), 'URL returns expected file.');
@ -224,7 +224,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
// Make sure that a second request to the already existing derivative
// works too.
$this->drupalGet($generate_url);
$this->assertResponse(200, 'Image was generated at the URL.');
$this->assertResponse(200);
// Check that the second request also returned the generated image.
$this->assertEqual($this->drupalGetHeader('Content-Length'), $image->getFileSize());
@ -236,7 +236,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
// have access.
\Drupal::state()->delete('image.test_file_download');
$this->drupalGet($generate_url);
$this->assertResponse(403, 'Confirmed that access is denied for the private image style.');
$this->assertResponse(403);
// Repeat this with a different file that we do not have access to and
// make sure that access is denied.
@ -247,7 +247,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
$generate_url_noaccess = $this->style->buildUrl($original_uri_noaccess);
$this->drupalGet($generate_url_noaccess);
$this->assertResponse(403, 'Confirmed that access is denied for the private image style.');
$this->assertResponse(403);
// Verify that images are not appended to the response.
// Currently this test only uses PNG images.
if (strpos($generate_url, '.png') === FALSE) {
@ -268,7 +268,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
if ($clean_url) {
// Add some extra chars to the token.
$this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url));
$this->assertResponse(200, 'Existing image was accessible at the URL with an invalid token.');
$this->assertResponse(200);
}
}
@ -295,7 +295,7 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
$generate_url = $this->style->buildUrl($original_uri, $clean_url);
$this->assertStringNotContainsString(IMAGE_DERIVATIVE_TOKEN . '=', $generate_url, 'The security token does not appear in the image style URL.');
$this->drupalGet($generate_url);
$this->assertResponse(200, 'Image was accessible at the URL with a missing token.');
$this->assertResponse(200);
// Stop suppressing the security token in the URL.
$this->config('image.settings')->set('suppress_itok_output', FALSE)->save();
@ -309,16 +309,16 @@ class ImageStylesPathAndUrlTest extends BrowserTestBase {
$this->assertTrue($matches_expected_url_format, "URL for a derivative of an image style matches expected format.");
$nested_url_with_wrong_token = str_replace(IMAGE_DERIVATIVE_TOKEN . '=', 'wrongparam=', $nested_url);
$this->drupalGet($nested_url_with_wrong_token);
$this->assertResponse(404, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token.');
$this->assertResponse(404);
// Check that this restriction cannot be bypassed by adding extra slashes
// to the URL.
$this->drupalGet(substr_replace($nested_url_with_wrong_token, '//styles/', strrpos($nested_url_with_wrong_token, '/styles/'), strlen('/styles/')));
$this->assertResponse(404, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token, even with an extra forward slash in the URL.');
$this->assertResponse(404);
$this->drupalGet(substr_replace($nested_url_with_wrong_token, '////styles/', strrpos($nested_url_with_wrong_token, '/styles/'), strlen('/styles/')));
$this->assertResponse(404, 'Image generated from an earlier derivative was inaccessible at the URL with a missing token, even with multiple forward slashes in the URL.');
$this->assertResponse(404);
// Make sure the image can still be generated if a correct token is used.
$this->drupalGet($nested_url);
$this->assertResponse(200, 'Image was accessible when a correct token was provided in the URL.');
$this->assertResponse(200);
// Check that requesting a nonexistent image does not create any new
// directories in the file system.

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->assertResponse(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, 'Failed to delete the default language.');
$this->assertResponse(403);
// Ensure 'Edit' link works.
$this->drupalGet('admin/config/regional/language');
@ -128,7 +128,7 @@ class LanguageListTest extends BrowserTestBase {
$this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $english])->toString());
// Verify that language is no longer found.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
$this->assertResponse(404, 'Language no longer found.');
$this->assertResponse(404);
// Delete French.
$this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete'));
@ -140,7 +140,7 @@ class LanguageListTest extends BrowserTestBase {
$this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE])->toString());
// Verify that language is no longer found.
$this->drupalGet('admin/config/regional/language/delete/fr');
$this->assertResponse(404, 'Language no longer found.');
$this->assertResponse(404);
// Make sure the "language_count" state has not changed.
// Ensure we can delete the English language. Right now English is the only
@ -179,7 +179,7 @@ class LanguageListTest extends BrowserTestBase {
// Ensure we can't delete a locked language.
$this->drupalGet('admin/config/regional/language/delete/und');
$this->assertResponse(403, 'Can not delete locked language');
$this->assertResponse(403);
// Ensure that NL cannot be set default when it's not available.
// First create the NL language.

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, 'Clicked link results in a valid page');
$this->assertResponse(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, "Unknown language path prefix should return 404");
$this->assertResponse(404);
// Set preferred langcode for user to NULL.
$account = $this->loggedInUser;

View File

@ -62,7 +62,7 @@ class LanguageUrlRewritingTest extends BrowserTestBase {
public function testUrlRewritingEdgeCases() {
// Check URL rewriting with a non-installed language.
$non_existing = new Language(['id' => $this->randomMachineName()]);
$this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages');
$this->checkUrl($non_existing, 'Path language is ignored if language is not installed.');
// Check that URL rewriting is not applied to subrequests.
$this->drupalGet('language_test/subrequest');
@ -78,12 +78,10 @@ class LanguageUrlRewritingTest extends BrowserTestBase {
*
* @param \Drupal\Core\Language\LanguageInterface $language
* The language object.
* @param string $message1
* @param string $message
* Message to display in assertion that language prefixes are not added.
* @param string $message2
* The message to display confirming prefixed URL is not working.
*/
private function checkUrl(LanguageInterface $language, $message1, $message2) {
private function checkUrl(LanguageInterface $language, $message) {
$options = ['language' => $language, 'script' => ''];
$base_path = trim(base_path(), '/');
$rewritten_path = trim(str_replace($base_path, '', Url::fromRoute('<front>', [], $options)->toString()), '/');
@ -95,11 +93,11 @@ class LanguageUrlRewritingTest extends BrowserTestBase {
// we can always check the prefixed URL.
$prefixes = $this->config('language.negotiation')->get('url.prefixes');
$stored_prefix = isset($prefixes[$language->getId()]) ? $prefixes[$language->getId()] : $this->randomMachineName();
$this->assertNotEqual($stored_prefix, $prefix, $message1);
$this->assertNotEqual($stored_prefix, $prefix, $message);
$prefix = $stored_prefix;
$this->drupalGet("$prefix/$path");
$this->assertResponse(404, $message2);
$this->assertResponse(404);
}
/**

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, 'Language no longer found.');
$this->assertResponse(404);
$this->drupalLogout();
// Delete the string.

View File

@ -64,7 +64,7 @@ class NodeTypeTest extends NodeTestBase {
$this->drupalLogin($web_user);
$this->drupalGet('node/add/' . $type->id());
$this->assertResponse(200, 'The new content type can be accessed at node/add.');
$this->assertResponse(200);
// Create a content type via the user interface.
$web_user = $this->drupalCreateUser(['bypass node access', 'administer content types']);

View File

@ -48,7 +48,7 @@ class RevisionLinkTest extends NodeTestBase {
$second_revision = $nodes[1]->getRevisionId();
$this->drupalGet('test-node-revision-links');
$this->assertResponse(200, 'Test view can be accessed in the path expected');
$this->assertResponse(200);
// The first node revision should link to the node directly as you get an
// access denied if you link to the revision.
$url = $nodes[0]->toUrl()->toString();

View File

@ -201,38 +201,47 @@ class PageCacheTest extends BrowserTestBase {
$etag = $this->drupalGetHeader('ETag');
$last_modified = $this->drupalGetHeader('Last-Modified');
// Ensure a conditional request returns 304 Not Modified.
$this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => $etag]);
$this->assertResponse(304, 'Conditional request returned 304 Not Modified.');
$this->assertResponse(304);
// Ensure a conditional request with obsolete If-Modified-Since date
// returns 304 Not Modified.
$this->drupalGet('', [], [
'If-Modified-Since' => gmdate(DATE_RFC822, strtotime($last_modified)),
'If-None-Match' => $etag,
]);
$this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.');
$this->assertResponse(304);
// Ensure a conditional request with obsolete If-Modified-Since date
// returns 304 Not Modified.
$this->drupalGet('', [], [
'If-Modified-Since' => gmdate(DATE_RFC850, strtotime($last_modified)),
'If-None-Match' => $etag,
]);
$this->assertResponse(304, 'Conditional request with obsolete If-Modified-Since date returned 304 Not Modified.');
$this->assertResponse(304);
// Ensure a conditional request without If-None-Match returns 200 OK.
$this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => NULL]);
// Verify the page is not printed twice when the cache is warm.
$this->assertSession()->responseNotMatches('#<html.*<html#');
$this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.');
$this->assertResponse(200);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
// Ensure a conditional request with If-Modified-Since newer than
// Last-Modified returns 200 OK.
$this->drupalGet('', [], [
'If-Modified-Since' => gmdate(DateTimePlus::RFC7231, strtotime($last_modified) + 1),
'If-None-Match' => $etag,
]);
$this->assertResponse(200, 'Conditional request with new a If-Modified-Since date newer than Last-Modified returned 200 OK.');
$this->assertResponse(200);
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
// Ensure a conditional request by an authenticated user returns 200 OK.
$user = $this->drupalCreateUser();
$this->drupalLogin($user);
$this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => $etag]);
$this->assertResponse(200, 'Conditional request returned 200 OK for authenticated user.');
$this->assertResponse(200);
$this->assertNull($this->drupalGetHeader('X-Drupal-Cache'), 'Absence of Page was not cached.');
}

View File

@ -173,7 +173,7 @@ class PathLanguageTest extends PathTestBase {
// situation only aliases in the default language and language neutral ones
// should keep working.
$this->drupalGet($french_alias);
$this->assertResponse(404, 'Alias for French translation is unavailable when URL language negotiation is disabled.');
$this->assertResponse(404);
// The alias manager has an internal path lookup cache. Check to see that
// it has the appropriate contents at this point.

View File

@ -76,7 +76,7 @@ class PathTaxonomyTermTest extends PathTestBase {
// Confirm that the old alias no longer works.
$this->drupalGet(trim($edit['path[0][alias]'], '/'));
$this->assertNoText($description, 'Old URL alias has been removed after altering.');
$this->assertResponse(404, 'Old URL alias returns 404.');
$this->assertResponse(404);
// Remove the term's URL alias.
$edit3 = [];
@ -86,7 +86,7 @@ class PathTaxonomyTermTest extends PathTestBase {
// Confirm that the alias no longer works.
$this->drupalGet(trim($edit2['path[0][alias]'], '/'));
$this->assertNoText($description, 'Old URL alias has been removed after altering.');
$this->assertResponse(404, 'Old URL alias returns 404.');
$this->assertResponse(404);
}
}

View File

@ -47,7 +47,7 @@ class UrlAlterFunctionalTest extends BrowserTestBase {
// Test a single altered path.
$this->drupalGet("user/$name");
$this->assertResponse('200', 'The user/username path gets resolved correctly');
$this->assertResponse(200);
$this->assertUrlOutboundAlter("/user/$uid", "/user/$name");
// Test that a path always uses its alias.
@ -61,7 +61,7 @@ class UrlAlterFunctionalTest extends BrowserTestBase {
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$this->assertText(t('The alias has been saved.'));
$this->drupalGet('alias/test2');
$this->assertResponse('200', 'The path alias gets resolved correctly');
$this->assertResponse(200);
$this->assertUrlOutboundAlter("/user/$uid/edit", '/alias/test2');
// Test a non-existent user is not altered.

View File

@ -268,10 +268,10 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', 'Content-Type header was sent.');
$this->assertTrue(strstr($this->drupalGetHeader('Cache-Control'), 'private') !== FALSE, 'Cache-Control header was sent.');
// Log out and try to access the file.
// Log out and ensure the file cannot be accessed.
$this->drupalLogout();
$this->drupalGet(file_create_url($image_uri));
$this->assertResponse('403', 'Access denied to original image as anonymous user.');
$this->assertResponse(403);
// Log in again.
$this->drupalLogin($this->adminUser);
@ -334,10 +334,10 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
$this->assertRaw($default_output, 'Image style large formatter displaying correctly on full node view.');
if ($scheme == 'private') {
// Log out and try to access the file.
// Log out and ensure the file cannot be accessed.
$this->drupalLogout();
$this->drupalGet($large_style->buildUrl($image_uri));
$this->assertResponse('403', 'Access denied to image style large as anonymous user.');
$this->assertResponse(403);
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');
}

View File

@ -83,7 +83,7 @@ class ResourceTest extends BrowserTestBase {
// means there's always a match and hence when there is no matching REST
// route, the non-REST route is used, but can't render into
// application/hal+json, so it returns a 406.
$this->assertResponse('406', 'HTTP response code is 406 when the resource does not define formats, because it falls back to the canonical, non-REST route.');
$this->assertResponse(406);
}
/**
@ -109,7 +109,7 @@ class ResourceTest extends BrowserTestBase {
// means there's always a match and hence when there is no matching REST
// route, the non-REST route is used, but can't render into
// application/hal+json, so it returns a 406.
$this->assertResponse('406', 'HTTP response code is 406 when the resource does not define formats, because it falls back to the canonical, non-REST route.');
$this->assertResponse(406);
}
/**

View File

@ -383,23 +383,23 @@ class StyleSerializerTest extends ViewTestBase {
$style_options = 'admin/structure/views/nojs/display/test_serializer_display_field/rest_export_1/style_options';
// Test with no format.
// Ensure a request with no format returns 406 Not Acceptable.
$this->drupalGet('test/serialize/field');
$this->assertHeader('content-type', 'text/html; charset=UTF-8');
$this->assertResponse(406, 'A 406 response was returned when no format was requested.');
$this->assertResponse(406);
// Select only 'xml' as an accepted format.
$this->drupalPostForm($style_options, ['style_options[formats][xml]' => 'xml'], t('Apply'));
$this->drupalPostForm(NULL, [], t('Save'));
// Should return a 406.
// Ensure a request for JSON returns 406 Not Acceptable.
$this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]);
$this->assertHeader('content-type', 'application/json');
$this->assertResponse(406, 'A 406 response was returned when JSON was requested.');
// Should return a 200.
$this->assertResponse(406);
// Ensure a request for XML returns 200 OK.
$this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]);
$this->assertHeader('content-type', 'text/xml; charset=UTF-8');
$this->assertResponse(200, 'A 200 response was returned when XML was requested.');
$this->assertResponse(200);
// Add 'json' as an accepted format, so we have multiple.
$this->drupalPostForm($style_options, ['style_options[formats][json]' => 'json'], t('Apply'));
@ -408,39 +408,40 @@ class StyleSerializerTest extends ViewTestBase {
// Should return a 406. Emulates a sample Firefox header.
$this->drupalGet('test/serialize/field', [], ['Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8']);
$this->assertHeader('content-type', 'text/html; charset=UTF-8');
$this->assertResponse(406, 'A 406 response was returned when a browser accept header was requested.');
$this->assertResponse(406);
// Should return a 406.
// Ensure a request for HTML returns 406 Not Acceptable.
$this->drupalGet('test/serialize/field', ['query' => ['_format' => 'html']]);
$this->assertHeader('content-type', 'text/html; charset=UTF-8');
$this->assertResponse(406, 'A 406 response was returned when HTML was requested.');
$this->assertResponse(406);
// Should return a 200.
// Ensure a request for JSON returns 200 OK.
$this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]);
$this->assertHeader('content-type', 'application/json');
$this->assertResponse(200, 'A 200 response was returned when JSON was requested.');
$this->assertResponse(200);
// Should return a 200.
// Ensure a request XML returns 200 OK.
$this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]);
$this->assertHeader('content-type', 'text/xml; charset=UTF-8');
$this->assertResponse(200, 'A 200 response was returned when XML was requested');
$this->assertResponse(200);
// Now configure no format, so both serialization formats should be allowed.
$this->drupalPostForm($style_options, ['style_options[formats][json]' => '0', 'style_options[formats][xml]' => '0'], t('Apply'));
// Should return a 200.
// Ensure a request for JSON returns 200 OK.
$this->drupalGet('test/serialize/field', ['query' => ['_format' => 'json']]);
$this->assertHeader('content-type', 'application/json');
$this->assertResponse(200, 'A 200 response was returned when JSON was requested.');
// Should return a 200.
$this->assertResponse(200);
// Ensure a request for XML returns 200 OK.
$this->drupalGet('test/serialize/field', ['query' => ['_format' => 'xml']]);
$this->assertHeader('content-type', 'text/xml; charset=UTF-8');
$this->assertResponse(200, 'A 200 response was returned when XML was requested');
$this->assertResponse(200);
// Should return a 406 for HTML still.
$this->drupalGet('test/serialize/field', ['query' => ['_format' => 'html']]);
$this->assertHeader('content-type', 'text/html; charset=UTF-8');
$this->assertResponse(406, 'A 406 response was returned when HTML was requested.');
$this->assertResponse(406);
}
/**

View File

@ -157,13 +157,13 @@ class SearchPageTextTest extends BrowserTestBase {
// Test that if you search for a URL with .. in it, you still end up at
// the search page. See issue https://www.drupal.org/node/890058.
$this->drupalPostForm('search/node', ['keys' => '../../admin'], t('Search'));
$this->assertResponse(200, 'Searching for ../../admin with non-admin user does not lead to a 403 error');
$this->assertResponse(200);
$this->assertText('no results', 'Searching for ../../admin with non-admin user gives you a no search results page');
// Test that if you search for a URL starting with "./", you still end up
// at the search page. See issue https://www.drupal.org/node/1421560.
$this->drupalPostForm('search/node', ['keys' => '.something'], t('Search'));
$this->assertResponse(200, 'Searching for .something does not lead to a 403 error');
$this->assertResponse(200);
$this->assertText('no results', 'Searching for .something gives you a no search results page');
}

View File

@ -406,17 +406,12 @@ class ShortcutLinksTest extends ShortcutTestBase {
// Verify that set administration pages are inaccessible without the
// 'access shortcuts' permission.
$edit_paths = [
'admin/config/user-interface/shortcut/manage/default/customize',
'admin/config/user-interface/shortcut/manage/default',
'user/' . $noaccess_user->id() . '/shortcuts',
];
foreach ($edit_paths as $path) {
$this->drupalGet($path);
$message = new FormattableMarkup('Access is denied on %s', ['%s' => $path]);
$this->assertResponse(403, $message);
}
$this->drupalGet('admin/config/user-interface/shortcut/manage/default/customize');
$this->assertResponse(403);
$this->drupalGet('admin/config/user-interface/shortcut/manage/default');
$this->assertResponse(403);
$this->drupalGet('user/' . $noaccess_user->id() . '/shortcuts');
$this->assertResponse(403);
}
/**

View File

@ -56,7 +56,7 @@ class StateValuesCleanAdvancedTest extends BrowserTestBase {
$this->drupalPostForm('form_test/form-state-values-clean-advanced', $edit, t('Submit'));
// Expecting a 200 HTTP code.
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertResponse(200);
$this->assertRaw(t('You WIN!'), 'Found the success message.');
}

View File

@ -354,7 +354,7 @@ class InstallUninstallTest extends ModuleTestBase {
*/
protected function assertHelp($module, $name) {
$this->drupalGet('admin/help/' . $module);
$this->assertResponse(200, "Help for $module displayed successfully");
$this->assertResponse(200);
$this->assertText($name . ' module', "'$name module' is on the help page for $module");
$this->assertLink('online documentation for the ' . $name . ' module', 0, "Correct online documentation link is in the help page for $module");
}

View File

@ -151,9 +151,9 @@ class PrepareUninstallTest extends BrowserTestBase {
$this->assertText('The selected modules have been uninstalled.');
$this->assertNoText('Allows content to be submitted to the site and displayed on pages.');
// Ensure the proper response when accessing a non-existent entity type.
// Ensure a 404 is returned when accessing a non-existent entity type.
$this->drupalGet('admin/modules/uninstall/entity/node');
$this->assertResponse(404, 'Entity types that do not exist result in a 404.');
$this->assertResponse(404);
// Test an entity type which does not have any existing entities.
$this->drupalGet('admin/modules/uninstall/entity/entity_test_no_label');

View File

@ -27,12 +27,13 @@ class RouterPermissionTest extends BrowserTestBase {
* Tests permission requirements on routes.
*/
public function testPermissionAccess() {
$path = 'router_test/test7';
$this->drupalGet($path);
$this->assertResponse(403, "Access denied for a route where we don't have a permission");
// Ensure 403 Access Denied for a route without permission.
$this->drupalGet('router_test/test7');
$this->assertResponse(403);
// Ensure 403 Access Denied by default if no access specified.
$this->drupalGet('router_test/test8');
$this->assertResponse(403, 'Access denied by default if no access specified');
$this->assertResponse(403);
$user = $this->drupalCreateUser(['access test7']);
$this->drupalLogin($user);

View File

@ -58,11 +58,11 @@ class SessionAuthenticationTest extends BrowserTestBase {
// Test that the route is not accessible as an anonymous user.
$this->drupalGet($protected_url);
$session = $this->getSession();
$this->assertResponse(401, 'An anonymous user cannot access a route protected with basic authentication.');
$this->assertResponse(401);
// We should be able to access the route with basic authentication.
$this->basicAuthGet($protected_url, $this->user->getAccountName(), $this->user->passRaw);
$this->assertResponse(200, 'A route protected with basic authentication can be accessed by an authenticated user.');
$this->assertResponse(200);
// Check that the correct user is logged in.
$this->assertEqual($this->user->id(), json_decode($session->getPage()->getContent())->user, 'The correct user is authenticated on a route with basic authentication.');
@ -71,13 +71,13 @@ class SessionAuthenticationTest extends BrowserTestBase {
// If we now try to access a page without basic authentication then we
// should no longer be logged in.
$this->drupalGet($unprotected_url);
$this->assertResponse(200, 'An unprotected route can be accessed without basic authentication.');
$this->assertResponse(200);
$this->assertEquals(0, json_decode($session->getPage()->getContent())->user, 'The user is no longer authenticated after visiting a page without basic authentication.');
// If we access the protected page again without basic authentication we
// should get 401 Unauthorized.
$this->drupalGet($protected_url);
$this->assertResponse(401, 'A subsequent request to the same route without basic authentication is not authorized.');
$this->assertResponse(401);
}
/**
@ -88,12 +88,12 @@ class SessionAuthenticationTest extends BrowserTestBase {
$test_value = 'alpaca';
$response = $this->basicAuthGet('session-test/set-session/' . $test_value, $this->user->getAccountName(), $this->user->pass_raw);
$this->assertSessionData($response, $test_value);
$this->assertResponse(200, 'The request to set a session value was successful.');
$this->assertResponse(200);
// Test that on a subsequent request the session value is still present.
$response = $this->basicAuthGet('session-test/get-session', $this->user->getAccountName(), $this->user->pass_raw);
$this->assertSessionData($response, $test_value);
$this->assertResponse(200, 'The request to get a session value was successful.');
$this->assertResponse(200);
}
/**
@ -126,7 +126,7 @@ class SessionAuthenticationTest extends BrowserTestBase {
// session cookie should be set, the third party system is responsible for
// sustaining the session.
$this->basicAuthGet($no_cookie_url, $this->user->getAccountName(), $this->user->passRaw);
$this->assertResponse(200, 'The user is successfully authenticated using basic authentication.');
$this->assertResponse(200);
$this->assertEmpty($this->getSessionCookies());
// Mink stores some information in the session that breaks the next check if
// not reset.

View File

@ -279,7 +279,7 @@ class SessionTest extends BrowserTestBase {
$user = $this->drupalCreateUser([]);
$this->drupalLogin($user);
$this->drupalGet('session-test/is-logged-in');
$this->assertResponse(200, 'User is logged in.');
$this->assertResponse(200);
// Reset the sid in {sessions} to a blank string. This may exist in the
// wild in some cases, although we normally prevent it from happening.
@ -292,37 +292,42 @@ class SessionTest extends BrowserTestBase {
$this->assertRaw("session_id:\n", 'Session ID is blank as sent from cookie header.');
// Assert that we have an anonymous session now.
$this->drupalGet('session-test/is-logged-in');
$this->assertResponse(403, 'An empty session ID is not allowed.');
$this->assertResponse(403);
}
/**
* Test session bag.
*/
public function testSessionBag() {
// Ensure the flag is absent to start with.
$this->drupalGet('/session-test/has-bag-flag');
$this->assertSessionCookie(FALSE);
$this->assertSessionEmpty(TRUE);
$this->assertResponse(200, 'Flag is absent from session bag');
$this->assertResponse(200);
// Set the flag.
$this->drupalGet('/session-test/set-bag-flag');
$this->assertSessionCookie(TRUE);
$this->assertSessionEmpty(TRUE);
$this->assertResponse(200);
// Ensure the flag is set.
$this->drupalGet('/session-test/has-bag-flag');
$this->assertSessionCookie(TRUE);
$this->assertSessionEmpty(FALSE);
$this->assertResponse(200, 'Flag is present in session bag');
$this->assertResponse(200);
// Clear the flag.
$this->drupalGet('/session-test/clear-bag-flag');
$this->assertSessionCookie(FALSE);
$this->assertSessionEmpty(FALSE);
$this->assertResponse(200);
// Ensure the flag is absent again.
$this->drupalGet('/session-test/has-bag-flag');
$this->assertSessionCookie(FALSE);
$this->assertSessionEmpty(TRUE);
$this->assertResponse(200, 'Flag is absent from session bag');
$this->assertResponse(200);
}
/**
@ -335,7 +340,7 @@ class SessionTest extends BrowserTestBase {
// Change cookie file for user.
$this->drupalGet('session-test/get');
$this->assertResponse(200, 'Session test module is correctly enabled.', 'Session');
$this->assertResponse(200);
}
/**

View File

@ -157,7 +157,7 @@ class AdminTest extends BrowserTestBase {
$frontpage_url = 'user/' . $this->adminUser->id();
$this->drupalGet('admin/compact/on');
$this->assertResponse(200, 'A valid page is returned after turning on compact mode.');
$this->assertResponse(200);
$this->assertUrl($frontpage_url, [], 'The user is redirected to the front page after turning on compact mode.');
$this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode turns on.');
$this->drupalGet('admin/compact/on');
@ -166,7 +166,7 @@ class AdminTest extends BrowserTestBase {
$this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode persists on new requests.');
$this->drupalGet('admin/compact/off');
$this->assertResponse(200, 'A valid page is returned after turning off compact mode.');
$this->assertResponse(200);
$this->assertUrl($frontpage_url, [], 'The user is redirected to the front page after turning off compact mode.');
$this->assertNull($session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode turns off.');
$this->drupalGet('admin/compact/off');

View File

@ -185,7 +185,7 @@ class DateTimeTest extends BrowserTestBase {
$this->drupalCreateContentType(['type' => 'page_with_date', 'name' => 'Page with date']);
$this->drupalGet('admin/structure/types/manage/page_with_date');
$this->assertResponse(200, 'Content type created.');
$this->assertResponse(200);
$this->drupalGet('admin/structure/types/manage/page_with_date/fields/add-field');
$edit = [

View File

@ -51,7 +51,7 @@ class ErrorHandlerTest extends BrowserTestBase {
// Set error reporting to display verbose notices.
$this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
$this->drupalGet('error-test/generate-warnings');
$this->assertResponse(200, 'Received expected HTTP status code.');
$this->assertResponse(200);
$this->assertErrorMessage($error_notice);
$this->assertErrorMessage($error_warning);
$this->assertErrorMessage($error_user_notice);
@ -66,7 +66,7 @@ class ErrorHandlerTest extends BrowserTestBase {
// Set error reporting to collect notices.
$config->set('error_level', ERROR_REPORTING_DISPLAY_ALL)->save();
$this->drupalGet('error-test/generate-warnings');
$this->assertResponse(200, 'Received expected HTTP status code.');
$this->assertResponse(200);
$this->assertErrorMessage($error_notice);
$this->assertErrorMessage($error_warning);
$this->assertErrorMessage($error_user_notice);
@ -75,7 +75,7 @@ class ErrorHandlerTest extends BrowserTestBase {
// Set error reporting to not collect notices.
$config->set('error_level', ERROR_REPORTING_DISPLAY_SOME)->save();
$this->drupalGet('error-test/generate-warnings');
$this->assertResponse(200, 'Received expected HTTP status code.');
$this->assertResponse(200);
$this->assertNoErrorMessage($error_notice);
$this->assertErrorMessage($error_warning);
$this->assertErrorMessage($error_user_notice);
@ -84,7 +84,7 @@ class ErrorHandlerTest extends BrowserTestBase {
// Set error reporting to not show any errors.
$config->set('error_level', ERROR_REPORTING_HIDE)->save();
$this->drupalGet('error-test/generate-warnings');
$this->assertResponse(200, 'Received expected HTTP status code.');
$this->assertResponse(200);
$this->assertNoErrorMessage($error_notice);
$this->assertNoErrorMessage($error_warning);
$this->assertNoErrorMessage($error_user_notice);

View File

@ -108,7 +108,7 @@ class HtaccessTest extends BrowserTestBase {
// Test that adding "/1" to a .php URL does not make it accessible.
$this->drupalGet('core/lib/Drupal.php/1');
$this->assertResponse(403, "Access to core/lib/Drupal.php/1 is denied.");
$this->assertResponse(403);
// Test that it is possible to have path aliases containing .php.
$type = $this->drupalCreateContentType();
@ -143,7 +143,7 @@ class HtaccessTest extends BrowserTestBase {
protected function assertFileAccess($path, $response_code) {
$this->assertFileExists(\Drupal::root() . '/' . $path);
$this->drupalGet($path);
$this->assertResponse($response_code, "Response code to $path is $response_code.");
$this->assertEquals($response_code, $this->getSession()->getStatusCode(), "Response code to $path should be $response_code");
}
/**

View File

@ -27,10 +27,10 @@ class IndexPhpTest extends BrowserTestBase {
$index_php = $GLOBALS['base_url'] . '/index.php';
$this->drupalGet($index_php, ['external' => TRUE]);
$this->assertResponse(200, 'Make sure index.php returns a valid page.');
$this->assertResponse(200);
$this->drupalGet($index_php . '/user', ['external' => TRUE]);
$this->assertResponse(200, 'Make sure index.php/user returns a valid page.');
$this->assertResponse(200);
}
}

View File

@ -48,7 +48,7 @@ class StatusTest extends BrowserTestBase {
public function testStatusPage() {
// Go to Administration.
$this->drupalGet('admin/reports/status');
$this->assertResponse(200, 'The status page is reachable.');
$this->assertResponse(200);
$phpversion = phpversion();
$this->assertText($phpversion, 'Php version is shown on the page.');
@ -81,7 +81,7 @@ class StatusTest extends BrowserTestBase {
$this->assertText(t('Out of date'));
$this->drupalGet('admin/reports/status/php');
$this->assertResponse(200, 'The phpinfo page is reachable.');
$this->assertResponse(200);
// Check if cron error is displayed in errors section
$cron_last_run = \Drupal::state()->get('system.cron_last');

View File

@ -53,14 +53,16 @@ class ThemeTest extends BrowserTestBase {
* Test the theme settings form.
*/
public function testThemeSettings() {
// Ensure invalid theme settings form URLs return a proper 404.
// Ensure a disabled theme settings form URL returns 404.
$this->drupalGet('admin/appearance/settings/bartik');
$this->assertResponse(404, 'The theme settings form URL for a uninstalled theme could not be found.');
$this->assertResponse(404);
// Ensure a non existent theme settings form URL returns 404.
$this->drupalGet('admin/appearance/settings/' . $this->randomMachineName());
$this->assertResponse(404, 'The theme settings form URL for a non-existent theme could not be found.');
$this->assertResponse(404);
// Ensure a hidden theme settings form URL returns 404.
$this->assertTrue(\Drupal::service('theme_installer')->install(['stable']));
$this->drupalGet('admin/appearance/settings/stable');
$this->assertResponse(404, 'The theme settings form URL for a hidden theme is unavailable.');
$this->assertResponse(404);
// Specify a filesystem path to be used for the logo.
$file = current($this->drupalGetTestFiles('image'));
@ -211,7 +213,7 @@ class ThemeTest extends BrowserTestBase {
$this->drupalGet('admin/appearance/settings');
$this->assertLink($theme_handler->getName('stable'));
$this->drupalGet('admin/appearance/settings/stable');
$this->assertResponse(200, 'The theme settings form URL for a hidden theme that is the admin theme is available.');
$this->assertResponse(200);
// Ensure default logo and favicons are not triggering custom path
// validation errors if their custom paths are set on the form.

View File

@ -34,7 +34,7 @@ class TrustedHostsTest extends BrowserTestBase {
*/
public function testStatusPageWithoutConfiguration() {
$this->drupalGet('admin/reports/status');
$this->assertResponse(200, 'The status page is reachable.');
$this->assertResponse(200);
$this->assertRaw(t('Trusted Host Settings'));
$this->assertRaw(t('The trusted_host_patterns setting is not configured in settings.php.'));
@ -52,7 +52,7 @@ class TrustedHostsTest extends BrowserTestBase {
$this->writeSettings($settings);
$this->drupalGet('admin/reports/status');
$this->assertResponse(200, 'The status page is reachable.');
$this->assertResponse(200);
$this->assertRaw(t('Trusted Host Settings'));
$this->assertRaw(t('The trusted_host_patterns setting is set to allow'));

View File

@ -190,7 +190,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
$this->drupalGet('admin/config/content/formats');
$this->assertText('Test text format');
$this->drupalGet('admin/config/content/formats/manage/test_text_format');
$this->assertResponse('200');
$this->assertResponse(200);
// Make sure our feed still exists.
$this->drupalGet('admin/config/services/aggregator');
@ -323,7 +323,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
$this->assertText('Test root term');
$this->assertText('Test child term');
$this->drupalGet('taxonomy/term/3');
$this->assertResponse('200');
$this->assertResponse(200);
// Make sure the terms are still translated.
$this->drupalGet('taxonomy/term/2/translations');

View File

@ -98,13 +98,17 @@ class TaxonomyImageTest extends TaxonomyTestBase {
$access_user = $this->drupalCreateUser(['access content']);
$no_access_user = $this->drupalCreateUser();
$image = File::load($term->field_test->target_id);
// Ensure a user that should be able to access the file can access it.
$this->drupalLogin($access_user);
$this->drupalGet(file_create_url($image->getFileUri()));
$this->assertResponse(200, 'Private image on term is accessible with right permission');
$this->assertResponse(200);
// Ensure a user that should not be able to access the file cannot access
// it.
$this->drupalLogin($no_access_user);
$this->drupalGet(file_create_url($image->getFileUri()));
$this->assertResponse(403, 'Private image on term not accessible without right permission');
$this->assertResponse(403);
}
}

View File

@ -359,7 +359,7 @@ class TermTest extends TaxonomyTestBase {
// Check the term link can be clicked through to the term page.
$this->clickLink($edit['name[0][value]']);
$this->assertResponse(200, 'Term page can be accessed via the listing link.');
$this->assertResponse(200);
// View the term and check that it is correct.
$this->drupalGet('taxonomy/term/' . $term->id());
@ -390,7 +390,7 @@ class TermTest extends TaxonomyTestBase {
// Assert that the term no longer exists.
$this->drupalGet('taxonomy/term/' . $term->id());
$this->assertResponse(404, 'The taxonomy term page was not found.');
$this->assertResponse(404);
}
/**

View File

@ -131,7 +131,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
// Verify translation links.
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
$this->assertResponse(200, 'The translatable vocabulary page was found.');
$this->assertResponse(200);
$this->assertLinkByHref('term/' . $translatable_tid . '/translations', 0, 'The translations link exists for a translatable vocabulary.');
$this->assertLinkByHref('term/' . $translatable_tid . '/edit', 0, 'The edit link exists for a translatable vocabulary.');

View File

@ -85,7 +85,7 @@ class VocabularyLanguageTest extends TaxonomyTestBase {
// Check that the vocabulary was actually created.
$this->drupalGet('admin/structure/taxonomy/manage/' . $edit['vid']);
$this->assertResponse(200, 'The vocabulary has been created.');
$this->assertResponse(200);
// Check that the language settings were saved.
$language_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $edit['vid']);

View File

@ -304,9 +304,9 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$user = $this->drupalCreateUser(["edit terms in {$vocabulary->id()}"]);
$this->drupalLogin($user);
// Visit the main taxonomy administration page.
// Ensure the taxonomy term add form is denied.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add');
$this->assertResponse(403, 'Add taxonomy term form open failed.');
$this->assertResponse(403);
// Create a test term.
$term = $this->createTerm($vocabulary);
@ -324,24 +324,24 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']);
$this->assert(isset($view_link), 'The message area contains a link to a term');
// Delete the vocabulary.
// Ensure the term cannot be deleted.
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
$this->assertResponse(403, 'Delete taxonomy term form open failed.');
$this->assertResponse(403);
// Test as user with "delete" permissions.
$user = $this->drupalCreateUser(["delete terms in {$vocabulary->id()}"]);
$this->drupalLogin($user);
// Visit the main taxonomy administration page.
// Ensure the taxonomy term add form is denied.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add');
$this->assertResponse(403, 'Add taxonomy term form open failed.');
$this->assertResponse(403);
// Create a test term.
$term = $this->createTerm($vocabulary);
// Edit the term.
// Ensure that the term cannot be edited.
$this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
$this->assertResponse(403, 'Edit taxonomy term form open failed.');
$this->assertResponse(403);
// Delete the vocabulary.
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
@ -355,20 +355,20 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$user = $this->drupalCreateUser();
$this->drupalLogin($user);
// Visit the main taxonomy administration page.
// Ensure the taxonomy term add form is denied.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add');
$this->assertResponse(403, 'Add taxonomy term form open failed.');
$this->assertResponse(403);
// Create a test term.
$term = $this->createTerm($vocabulary);
// Edit the term.
// Ensure that the term cannot be edited.
$this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
$this->assertResponse(403, 'Edit taxonomy term form open failed.');
$this->assertResponse(403);
// Delete the vocabulary.
// Ensure the term cannot be deleted.
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
$this->assertResponse(403, 'Delete taxonomy term form open failed.');
$this->assertResponse(403);
}
}

View File

@ -98,7 +98,7 @@ class UpdateCoreTest extends UpdateTestBase {
// Ensure that the update check requires a token.
$this->drupalGet('admin/reports/updates/check');
$this->assertResponse(403, 'Accessing admin/reports/updates/check without a CSRF token results in access denied.');
$this->assertResponse(403);
foreach ([0, 1] as $minor_version) {
foreach (['-alpha1', '-beta1', ''] as $extra_version) {

View File

@ -22,8 +22,9 @@ class UserAdminListingTest extends BrowserTestBase {
* Tests the listing.
*/
public function testUserListing() {
// Ensure the anonymous user cannot access the admin listing.
$this->drupalGet('admin/people');
$this->assertResponse(403, 'Anonymous user does not have access to the user admin listing.');
$this->assertResponse(403);
// Create a bunch of users.
$accounts = [];
@ -62,8 +63,9 @@ class UserAdminListingTest extends BrowserTestBase {
$this->drupalLogin($admin_user);
// Ensure the admin user can access the admin listing.
$this->drupalGet('admin/people');
$this->assertResponse(200, 'The admin user has access to the user admin listing.');
$this->assertResponse(200);
$result = $this->xpath('//table[contains(@class, "responsive-enabled")]/tbody/tr');
$result_accounts = [];

View File

@ -61,7 +61,7 @@ class UserCancelTest extends BrowserTestBase {
// Attempt bogus account cancellation request confirmation.
$timestamp = $account->getLastLoginTime();
$this->drupalGet("user/" . $account->id() . "/cancel/confirm/$timestamp/" . user_pass_rehash($account, $timestamp));
$this->assertResponse(403, 'Bogus cancelling request rejected.');
$this->assertResponse(403);
$user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
$this->assertTrue($account->isActive(), 'User account was not canceled.');

View File

@ -34,10 +34,11 @@ class UserRegistrationTest extends BrowserTestBase {
// Require email verification.
$config->set('verify_mail', TRUE)->save();
// Set registration to administrator only.
// Set registration to administrator only and ensure the user registration
// page is inaccessible.
$config->set('register', UserInterface::REGISTER_ADMINISTRATORS_ONLY)->save();
$this->drupalGet('user/register');
$this->assertResponse(403, 'Registration page is inaccessible when only administrators can create accounts.');
$this->assertResponse(403);
// Allow registration by site visitors without administrator approval.
$config->set('register', UserInterface::REGISTER_VISITORS)->save();

View File

@ -93,10 +93,10 @@ class UserRoleAdminTest extends BrowserTestBase {
// Make sure that the system-defined roles can be edited via the user
// interface.
$this->drupalGet('admin/people/roles/manage/' . RoleInterface::ANONYMOUS_ID);
$this->assertResponse(200, 'Access granted when trying to edit the built-in anonymous role.');
$this->assertResponse(200);
$this->assertNoText(t('Delete role'), 'Delete button for the anonymous role is not present.');
$this->drupalGet('admin/people/roles/manage/' . RoleInterface::AUTHENTICATED_ID);
$this->assertResponse(200, 'Access granted when trying to edit the built-in authenticated role.');
$this->assertResponse(200);
$this->assertNoText(t('Delete role'), 'Delete button for the authenticated role is not present.');
}

View File

@ -108,17 +108,19 @@ class UserSearchTest extends BrowserTestBase {
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText(t('Your search yielded no results.'), 'Blocked users are hidden from the user search results.');
// Create a user without search permission, and one without user page view
// permission. Verify that neither one can access the user search page.
// Ensure that a user without access to user profiles cannot access the
// user search page.
$user3 = $this->drupalCreateUser(['search content']);
$this->drupalLogin($user3);
$this->drupalGet('search/user');
$this->assertResponse('403', 'User without user profile access cannot search');
$this->assertResponse(403);
// Ensure that a user without search permission cannot access the user
// search page.
$user4 = $this->drupalCreateUser(['access user profiles']);
$this->drupalLogin($user4);
$this->drupalGet('search/user');
$this->assertResponse('403', 'User without search permission cannot search');
$this->assertResponse(403);
$this->drupalLogout();
}

View File

@ -49,7 +49,7 @@ class BulkFormAccessTest extends UserTestBase {
// Ensure that the account "no_edit" can not be edited.
$this->drupalGet('user/' . $no_edit_user->id() . '/edit');
$this->assertFalse($no_edit_user->access('update', $admin_user));
$this->assertResponse(403, 'The user may not be edited.');
$this->assertResponse(403);
// Test blocking the account "no_edit".
$edit = [
@ -109,10 +109,10 @@ class BulkFormAccessTest extends UserTestBase {
// Ensure that the account "no_delete" can not be deleted.
$this->drupalGet('user/' . $account->id() . '/cancel');
$this->assertResponse(403, 'The user "no_delete" may not be deleted.');
$this->assertResponse(403);
// Ensure that the account "may_delete" *can* be deleted.
$this->drupalGet('user/' . $account2->id() . '/cancel');
$this->assertResponse(200, 'The user "may_delete" may be deleted.');
$this->assertResponse(200);
// Test deleting the accounts "no_delete" and "may_delete".
$edit = [

View File

@ -36,7 +36,7 @@ class ReportTest extends UITestBase {
// Test the report page.
$this->drupalGet('admin/reports/views-plugins');
$this->assertResponse(200, "Views report page exists");
$this->assertResponse(200);
}
}

View File

@ -115,7 +115,7 @@ class UncaughtExceptionTest extends BrowserTestBase {
'%function' => 'Drupal\error_test\Controller\ErrorTestController->Drupal\error_test\Controller\{closure}()',
];
$this->drupalGet('error-test/generate-fatals');
$this->assertResponse(500, 'Received expected HTTP status code.');
$this->assertResponse(500);
$message = new FormattableMarkup('%type: @message in %function (line ', $fatal_error);
$this->assertRaw((string) $message);
$this->assertRaw('<pre class="backtrace">');