Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installSchema('system', 'sequences');
     $this->installEntitySchema('user');
     $this->manager = $this->container->get('plugin.manager.condition');
     // Set up the authenticated and anonymous roles.
     Role::create(array('id' => RoleInterface::ANONYMOUS_ID, 'label' => 'Anonymous user'))->save();
     Role::create(array('id' => RoleInterface::AUTHENTICATED_ID, 'label' => 'Authenticated user'))->save();
     // Create new role.
     $rid = strtolower($this->randomMachineName(8));
     $label = $this->randomString(8);
     $role = Role::create(array('id' => $rid, 'label' => $label));
     $role->save();
     $this->role = $role;
     // Setup an anonymous user for our tests.
     $this->anonymous = User::create(array('name' => '', 'uid' => 0));
     $this->anonymous->save();
     // Loading the anonymous user adds the correct role.
     $this->anonymous = User::load($this->anonymous->id());
     // Setup an authenticated user for our tests.
     $this->authenticated = User::create(array('name' => $this->randomMachineName()));
     $this->authenticated->save();
     // Add the custom role.
     $this->authenticated->addRole($this->role->id());
 }
 /**
  * Tests tabs in profile UI.
  */
 public function testProfileTabs()
 {
     $types_data = ['profile_type_0' => ['label' => $this->randomMachineName()], 'profile_type_1' => ['label' => $this->randomMachineName()]];
     /** @var ProfileType[] $types */
     $types = [];
     foreach ($types_data as $id => $values) {
         $types[$id] = ProfileType::create(['id' => $id] + $values);
         $types[$id]->save();
     }
     $this->container->get('router.builder')->rebuild();
     $this->user1 = User::create(['name' => $this->randomMachineName(), 'mail' => $this->randomMachineName() . '@example.com']);
     $this->user1->save();
     $this->user2 = User::create(['name' => $this->randomMachineName(), 'mail' => $this->randomMachineName() . '@example.com']);
     $this->user2->save();
     // Create new profiles.
     $profile1 = Profile::create($expected = ['type' => $types['profile_type_0']->id(), 'uid' => $this->user1->id()]);
     $profile1->save();
     $profile2 = Profile::create($expected = ['type' => $types['profile_type_1']->id(), 'uid' => $this->user2->id()]);
     $profile2->save();
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/config');
     $this->clickLink('User profiles');
     $this->assertResponse(200);
     $this->assertUrl('admin/config/people/profiles');
     $this->assertLink($profile1->label());
     $this->assertLinkByHref($profile2->toUrl('canonical')->toString());
     $tasks = [['entity.profile.collection', []], ['entity.profile_type.collection', []]];
     $this->assertLocalTasks($tasks, 0);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function setUp($import_test_views = TRUE)
 {
     parent::setUp($import_test_views);
     $this->installEntitySchema('user');
     $this->installEntitySchema('comment');
     // Create the anonymous role.
     $this->installConfig(['user']);
     // Create an anonymous user.
     $storage = \Drupal::entityManager()->getStorage('user');
     // Insert a row for the anonymous user.
     $storage->create(array('uid' => 0, 'name' => '', 'status' => 0))->save();
     $admin_role = Role::create(['id' => 'admin', 'permissions' => ['administer comments', 'access user profiles']]);
     $admin_role->save();
     /* @var \Drupal\user\RoleInterface $anonymous_role */
     $anonymous_role = Role::load(Role::ANONYMOUS_ID);
     $anonymous_role->grantPermission('access comments');
     $anonymous_role->save();
     $this->adminUser = User::create(['name' => $this->randomMachineName(), 'roles' => [$admin_role->id()]]);
     $this->adminUser->save();
     // Create some comments.
     $comment = Comment::create(['subject' => 'My comment title', 'uid' => $this->adminUser->id(), 'name' => $this->adminUser->label(), 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', 'status' => 1]);
     $comment->save();
     $comment_anonymous = Comment::create(['subject' => 'Anonymous comment title', 'uid' => 0, 'name' => 'barry', 'mail' => '*****@*****.**', 'homepage' => 'https://example.com', 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', 'created' => 123456, 'status' => 1]);
     $comment_anonymous->save();
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->adminUser = $this->drupalCreateUser(['access user profiles', 'administer profiles', 'administer profile types', 'bypass profile access', 'access administration pages']);
     $this->user1 = User::create(['name' => $this->randomMachineName(), 'mail' => $this->randomMachineName() . '@example.com']);
     $this->user1->save();
     $this->user2 = User::create(['name' => $this->randomMachineName(), 'mail' => $this->randomMachineName() . '@example.com']);
     $this->user2->save();
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('user');
     $this->installSchema('system', 'sequences');
     $devel_role = Role::create(['id' => 'admin', 'permissions' => ['access devel information']]);
     $devel_role->save();
     $this->develUser = User::create(['name' => $this->randomMachineName(), 'roles' => [$devel_role->id()]]);
     $this->develUser->save();
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('user');
     $this->installEntitySchema('file');
     $this->installSchema('file', 'file_usage');
     $this->installSchema('system', 'sequences');
     $this->user = User::create(['name' => 'username', 'status' => 1]);
     $this->user->save();
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Add a field to both entities.
     $this->addField('string', 'field_shared', 'user');
     $this->addField('string', 'field_shared', 'simplenews_subscriber');
     // Create a user.
     $this->user = $this->drupalCreateUser(array('administer simplenews subscriptions', 'administer simplenews settings'));
     $this->user->setEmail('*****@*****.**');
     $this->user->set('field_shared', $this->randomMachineName());
     $this->user->save();
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('user');
     $this->installEntitySchema('entity_test_enhanced');
     $this->installSchema('system', ['key_value_expire', 'sequences']);
     $bundle = EnhancedEntityBundle::create(['id' => 'default', 'label' => 'Default']);
     $bundle->save();
     $this->user = User::create(['name' => 'username', 'status' => 1]);
     $this->user->save();
     \Drupal::service('current_user')->setAccount($this->user);
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('file');
     $this->installEntitySchema('user');
     $this->installSchema('file', array('file_usage'));
     $this->installSchema('system', 'sequences');
     $this->user1 = User::create(['name' => 'user1', 'status' => 1]);
     $this->user1->save();
     $this->user2 = User::create(['name' => 'user2', 'status' => 1]);
     $this->user2->save();
     $this->file = File::create(array('uid' => $this->user1->id(), 'filename' => 'druplicon.txt', 'filemime' => 'text/plain'));
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp($import_test_views = TRUE)
 {
     parent::setUp($import_test_views);
     $this->installEntitySchema('user');
     $role_with_access = Role::create(['id' => 'with_access', 'permissions' => ['view test entity field']]);
     $role_with_access->save();
     $role_without_access = Role::create(['id' => 'without_access', 'permissions' => []]);
     $role_without_access->save();
     $this->userWithAccess = User::create(['name' => $this->randomMachineName(), 'roles' => [$role_with_access->id()]]);
     $this->userWithAccess->save();
     $this->userWithoutAccess = User::create(['name' => $this->randomMachineName(), 'roles' => [$role_without_access->id()]]);
     $this->userWithoutAccess->save();
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->drupalPlaceBlock('system_breadcrumb_block');
     $this->enableViewsTestModule();
     $this->webUser = $this->drupalCreateUser();
     $roles = $this->webUser->getRoles();
     $this->webRole = $roles[0];
     $this->normalRole = $this->drupalCreateRole(array());
     $this->normalUser = $this->drupalCreateUser(array('views_test_data test permission'));
     $this->normalUser->addRole($this->normalRole);
     $this->normalUser->save();
     // @todo when all the plugin information is cached make a reset function and
     // call it here.
 }
 /**
  * Sets up the test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installSchema('system', ['sequences', 'key_value_expire']);
     $this->installEntitySchema('user');
     \Drupal::service('router.builder')->rebuild();
     /** @var \Drupal\user\RoleInterface $role */
     $role = Role::create(array('id' => 'admin', 'label' => 'admin'));
     $role->grantPermission('link to any page');
     $role->save();
     $this->testUser = User::create(array('name' => 'foobar', 'mail' => '*****@*****.**'));
     $this->testUser->addRole($role->id());
     $this->testUser->save();
     \Drupal::service('current_user')->setAccount($this->testUser);
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installSchema('system', ['key_value_expire']);
     \Drupal::service('router.builder')->rebuild();
     $this->testUser = User::create(array('name' => 'foobar1', 'mail' => '*****@*****.**'));
     $this->testUser->save();
     \Drupal::service('current_user')->setAccount($this->testUser);
     $this->testAutocreateUser = User::create(array('name' => 'foobar2', 'mail' => '*****@*****.**'));
     $this->testAutocreateUser->save();
     for ($i = 1; $i < 3; $i++) {
         $entity = EntityTest::create(array('name' => $this->randomMachineName()));
         $entity->save();
         $this->referencedEntities[] = $entity;
     }
 }
Exemplo n.º 14
0
 /**
  * Tests CRUD operations for profile types through the UI.
  */
 public function testCRUDUI()
 {
     $types_data = ['profile_type_0' => ['label' => $this->randomMachineName()], 'profile_type_1' => ['label' => $this->randomMachineName()]];
     /** @var ProfileType[] $types */
     $types = [];
     foreach ($types_data as $id => $values) {
         $types[$id] = $this->createProfileType($id, $values['label']);
     }
     $this->user1 = User::create(['name' => $this->randomMachineName(), 'mail' => $this->randomMachineName() . '@example.com']);
     $this->user1->save();
     $this->user2 = User::create(['name' => $this->randomMachineName(), 'mail' => $this->randomMachineName() . '@example.com']);
     $this->user2->save();
     // Create new profiles.
     $profile1 = Profile::create($expected = ['type' => $types['profile_type_0']->id(), 'uid' => $this->user1->id()]);
     $profile1->save();
     $profile2 = Profile::create($expected = ['type' => $types['profile_type_1']->id(), 'uid' => $this->user2->id()]);
     $profile2->save();
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/config');
     $this->clickLink('User profiles');
     $this->assertResponse(200);
     $this->assertUrl('admin/config/people/profiles');
     $this->assertLink($profile1->label());
     $this->assertLinkByHref($profile2->toUrl('canonical')->toString());
 }
 /**
  * {@inheritdoc}
  */
 protected function setUpFixtures()
 {
     $this->installEntitySchema('user');
     $this->installEntitySchema('entity_test');
     $this->installConfig(['entity_test']);
     EntityViewMode::create(['id' => 'entity_test.foobar', 'targetEntityType' => 'entity_test', 'status' => TRUE, 'enabled' => TRUE, 'label' => 'My view mode'])->save();
     $display = EntityViewDisplay::create(['targetEntityType' => 'entity_test', 'bundle' => 'entity_test', 'mode' => 'foobar', 'label' => 'My view mode', 'status' => TRUE]);
     $display->save();
     $field_storage = FieldStorageConfig::create(['field_name' => 'test_field', 'entity_type' => 'entity_test', 'type' => 'string']);
     $field_storage->save();
     $field_config = FieldConfig::create(['field_name' => 'test_field', 'entity_type' => 'entity_test', 'bundle' => 'entity_test']);
     $field_config->save();
     // Create some test entities.
     for ($i = 1; $i <= 3; $i++) {
         EntityTest::create(['name' => "Article title {$i}", 'test_field' => "Test {$i}"])->save();
     }
     $this->user = User::create(['name' => 'test user']);
     $this->user->save();
     parent::setUpFixtures();
 }
Exemplo n.º 16
0
 /**
  * Sets up the test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('user');
     $this->installSchema('system', ['sequences']);
     $this->installConfig(['filter', 'filter_test']);
     // Filter tips link to the full-page.
     \Drupal::service('router.builder')->rebuild();
     /* @var \Drupal\Core\Render\ElementInfoManager $manager */
     $manager = \Drupal::service('plugin.manager.element_info');
     $manager->clearCachedDefinitions();
     $manager->getDefinitions();
     /* @var \Drupal\filter\FilterFormatInterface $filter_test_format */
     $filter_test_format = FilterFormat::load('filter_test');
     /* @var \Drupal\user\RoleInterface $role */
     $role = Role::create(['id' => 'admin', 'label' => 'admin']);
     $role->grantPermission($filter_test_format->getPermissionName());
     $role->save();
     $this->testUser = User::create(['name' => 'foobar', 'mail' => '*****@*****.**']);
     $this->testUser->addRole($role->id());
     $this->testUser->save();
     \Drupal::service('current_user')->setAccount($this->testUser);
 }
 protected function setUp($import_test_views = TRUE)
 {
     parent::setUp($import_test_views);
     ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
     $this->installEntitySchema('user');
     $this->installEntitySchema('comment');
     $this->installConfig(['user']);
     $entity_manager = $this->container->get('entity.manager');
     $this->commentStorage = $entity_manager->getStorage('comment');
     $this->userStorage = $entity_manager->getStorage('user');
     // Insert a row for the anonymous user.
     $this->userStorage->create(['uid' => 0, 'name' => '', 'status' => 0])->save();
     $admin_role = Role::create(['id' => 'admin']);
     $admin_role->grantPermission('administer comments');
     $admin_role->save();
     /* @var \Drupal\user\RoleInterface $anonymous_role */
     $anonymous_role = Role::load(Role::ANONYMOUS_ID);
     $anonymous_role->grantPermission('access comments');
     $anonymous_role->save();
     $this->adminUser = $this->userStorage->create(['name' => $this->randomMachineName()]);
     $this->adminUser->addRole('admin');
     $this->adminUser->save();
 }
 /**
  * {@inheritdoc
  */
 protected function setUp()
 {
     parent::setUp();
     $this->paymentStorage = \Drupal::entityManager()->getStorage('payment');
     /** @var \Drupal\currency\ConfigImporterInterface $config_importer */
     $config_importer = \Drupal::service('currency.config_importer');
     $config_importer->importCurrency('EUR');
     // Create the field and field instance.
     $field_name = strtolower($this->randomMachineName());
     entity_create('field_storage_config', ['cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED, 'entity_type' => 'user', 'field_name' => $field_name, 'type' => 'payment_form'])->save();
     entity_create('field_config', ['bundle' => 'user', 'entity_type' => 'user', 'field_name' => $field_name, 'settings' => ['currency_code' => 'EUR']])->save();
     entity_get_display('user', 'user', 'default')->setComponent($field_name, ['type' => 'payment_form'])->save();
     // Create an entity.
     $this->user = entity_create('user', ['name' => $this->randomString(), 'status' => TRUE]);
     foreach (Generate::createPaymentLineItems() as $line_item) {
         $this->user->get($field_name)->appendItem(['plugin_id' => $line_item->getPluginId(), 'plugin_configuration' => $line_item->getConfiguration()]);
     }
     $this->user->save();
     // Create a payment method.
     $this->paymentMethod = Generate::createPaymentMethodConfiguration(2, 'payment_basic');
     $this->paymentMethod->setPluginConfiguration(['execute_status_id' => $this->executeStatusPluginId]);
     $this->paymentMethod->save();
 }
Exemplo n.º 19
0
 /**
  * {@inheritdoc}
  */
 public function submit(array $form, FormStateInterface $form_state)
 {
     // Cancel account immediately, if the current user has administrative
     // privileges, no confirmation mail shall be sent, and the user does not
     // attempt to cancel the own account.
     if ($this->currentUser()->hasPermission('administer users') && empty($form_state['values']['user_cancel_confirm']) && $this->entity->id() != $this->currentUser()->id()) {
         user_cancel($form_state['values'], $this->entity->id(), $form_state['values']['user_cancel_method']);
         $form_state->setRedirect('user.admin_account');
     } else {
         // Store cancelling method and whether to notify the user in
         // $this->entity for user_cancel_confirm().
         $this->entity->user_cancel_method = $form_state['values']['user_cancel_method'];
         $this->entity->user_cancel_notify = $form_state['values']['user_cancel_notify'];
         $this->entity->save();
         _user_mail_notify('cancel_confirm', $this->entity);
         drupal_set_message($this->t('A confirmation request to cancel your account has been sent to your email address.'));
         $this->logger('user')->notice('Sent account cancellation request to %name %email.', array('%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>'));
         $form_state->setRedirect('user.view', array('user' => $this->entity->id()));
     }
 }
Exemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Cancel account immediately, if the current user has administrative
     // privileges, no confirmation mail shall be sent, and the user does not
     // attempt to cancel the own account.
     if (!$form_state->isValueEmpty('access') && $form_state->isValueEmpty('user_cancel_confirm') && $this->entity->id() != $this->currentUser()->id()) {
         user_cancel($form_state->getValues(), $this->entity->id(), $form_state->getValue('user_cancel_method'));
         $form_state->setRedirectUrl($this->entity->urlInfo('collection'));
     } else {
         // Store cancelling method and whether to notify the user in
         // $this->entity for
         // \Drupal\user\Controller\UserController::confirmCancel().
         $this->entity->user_cancel_method = $form_state->getValue('user_cancel_method');
         $this->entity->user_cancel_notify = $form_state->getValue('user_cancel_notify');
         $this->entity->save();
         _user_mail_notify('cancel_confirm', $this->entity);
         drupal_set_message($this->t('A confirmation request to cancel your account has been sent to your email address.'));
         $this->logger('user')->notice('Sent account cancellation request to %name %email.', array('%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>'));
         $form_state->setRedirect('entity.user.canonical', array('user' => $this->entity->id()));
     }
 }
Exemplo n.º 21
0
 /**
  * Tests password reset functionality.
  */
 function testUserPasswordReset()
 {
     // Try to reset the password for an invalid account.
     $this->drupalGet('user/password');
     $edit = array('name' => $this->randomMachineName(32));
     $this->drupalPostForm(NULL, $edit, t('Submit'));
     $this->assertText(t('Sorry, @name is not recognized as a username or an email address.', array('@name' => $edit['name'])), 'Validation error message shown when trying to request password for invalid account.');
     $this->assertEqual(count($this->drupalGetMails(array('id' => 'user_password_reset'))), 0, 'No email was sent when requesting a password for an invalid account.');
     // Reset the password by username via the password reset page.
     $edit['name'] = $this->account->getUsername();
     $this->drupalPostForm(NULL, $edit, t('Submit'));
     // Verify that the user was sent an email.
     $this->assertMail('to', $this->account->getEmail(), 'Password email sent to user.');
     $subject = t('Replacement login information for @username at @site', array('@username' => $this->account->getUsername(), '@site' => $this->config('system.site')->get('name')));
     $this->assertMail('subject', $subject, 'Password reset email subject is correct.');
     $resetURL = $this->getResetURL();
     $this->drupalGet($resetURL);
     $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'));
     // Ensure the password reset URL is not cached.
     $this->drupalGet($resetURL);
     $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'));
     // Check the one-time login page.
     $this->assertText($this->account->getUsername(), 'One-time login page contains the correct username.');
     $this->assertText(t('This login can be used only once.'), 'Found warning about one-time login.');
     $this->assertTitle(t('Reset password | Drupal'), 'Page title is "Reset password".');
     // Check successful login.
     $this->drupalPostForm(NULL, NULL, t('Log in'));
     $this->assertLink(t('Log out'));
     $this->assertTitle(t('@name | @site', array('@name' => $this->account->getUsername(), '@site' => $this->config('system.site')->get('name'))), 'Logged in using password reset link.');
     // Make sure the ajax request from uploading a user picture does not
     // invalidate the reset token.
     $image = current($this->drupalGetTestFiles('image'));
     $edit = array('files[user_picture_0]' => drupal_realpath($image->uri));
     $this->drupalPostAjaxForm(NULL, $edit, 'user_picture_0_upload_button');
     // Change the forgotten password.
     $password = user_password();
     $edit = array('pass[pass1]' => $password, 'pass[pass2]' => $password);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     $this->assertText(t('The changes have been saved.'), 'Forgotten password changed.');
     // Verify that the password reset session has been destroyed.
     $this->drupalPostForm(NULL, $edit, t('Save'));
     $this->assertText(t('Your current password is missing or incorrect; it\'s required to change the Password.'), 'Password needed to make profile changes.');
     // Log out, and try to log in again using the same one-time link.
     $this->drupalLogout();
     $this->drupalGet($resetURL);
     $this->assertText(t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'), 'One-time link is no longer valid.');
     // Request a new password again, this time using the email address.
     $this->drupalGet('user/password');
     // Count email messages before to compare with after.
     $before = count($this->drupalGetMails(array('id' => 'user_password_reset')));
     $edit = array('name' => $this->account->getEmail());
     $this->drupalPostForm(NULL, $edit, t('Submit'));
     $this->assertTrue(count($this->drupalGetMails(array('id' => 'user_password_reset'))) === $before + 1, 'Email sent when requesting password reset using email address.');
     // Create a password reset link as if the request time was 60 seconds older than the allowed limit.
     $timeout = $this->config('user.settings')->get('password_reset_timeout');
     $bogus_timestamp = REQUEST_TIME - $timeout - 60;
     $_uid = $this->account->id();
     $this->drupalGet("user/reset/{$_uid}/{$bogus_timestamp}/" . user_pass_rehash($this->account, $bogus_timestamp));
     $this->assertText(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'), 'Expired password reset request rejected.');
     // Create a user, block the account, and verify that a login link is denied.
     $timestamp = REQUEST_TIME - 1;
     $blocked_account = $this->drupalCreateUser()->block();
     $blocked_account->save();
     $this->drupalGet("user/reset/" . $blocked_account->id() . "/{$timestamp}/" . user_pass_rehash($blocked_account, $timestamp));
     $this->assertResponse(403);
     // Verify a blocked user can not request a new password.
     $this->drupalGet('user/password');
     // Count email messages before to compare with after.
     $before = count($this->drupalGetMails(array('id' => 'user_password_reset')));
     $edit = array('name' => $blocked_account->getUsername());
     $this->drupalPostForm(NULL, $edit, t('Submit'));
     $this->assertRaw(t('%name is blocked or has not been activated yet.', array('%name' => $blocked_account->getUsername())), 'Notified user blocked accounts can not request a new password');
     $this->assertTrue(count($this->drupalGetMails(array('id' => 'user_password_reset'))) === $before, 'No email was sent when requesting password reset for a blocked account');
     // Verify a password reset link is invalidated when the user's email address changes.
     $this->drupalGet('user/password');
     $edit = array('name' => $this->account->getUsername());
     $this->drupalPostForm(NULL, $edit, t('Submit'));
     $old_email_reset_link = $this->getResetURL();
     $this->account->setEmail("1" . $this->account->getEmail());
     $this->account->save();
     $this->drupalGet($old_email_reset_link);
     $this->assertText(t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'), 'One-time link is no longer valid.');
 }
Exemplo n.º 22
0
 /**
  * Tests access to the personal contact form.
  */
 function testPersonalContactAccess()
 {
     // Test allowed access to admin user's contact form.
     $this->drupalLogin($this->webUser);
     $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
     $this->assertResponse(200);
     // Check the page title is properly displayed.
     $this->assertRaw(t('Contact @username', array('@username' => $this->adminUser->getDisplayName())));
     // Test denied access to admin user's own contact form.
     $this->drupalLogout();
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
     $this->assertResponse(403);
     // Test allowed access to user with contact form enabled.
     $this->drupalLogin($this->webUser);
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(200);
     // Test that there is no access to personal contact forms for users
     // without an email address configured.
     $original_email = $this->contactUser->getEmail();
     $this->contactUser->setEmail(FALSE)->save();
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(404, 'Not found (404) returned when visiting a personal contact form for a user with no email address');
     // Test that the 'contact tab' does not appear on the user profiles
     // for users without an email address configured.
     $this->drupalGet('user/' . $this->contactUser->id());
     $contact_link = '/user/' . $this->contactUser->id() . '/contact';
     $this->assertResponse(200);
     $this->assertNoLinkByHref($contact_link, 'The "contact" tab is hidden on profiles for users with no email address');
     // Restore original email address.
     $this->contactUser->setEmail($original_email)->save();
     // Test denied access to the user's own contact form.
     $this->drupalGet('user/' . $this->webUser->id() . '/contact');
     $this->assertResponse(403);
     // Test always denied access to the anonymous user contact form.
     $this->drupalGet('user/0/contact');
     $this->assertResponse(403);
     // Test that anonymous users can access the contact form.
     $this->drupalLogout();
     user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user contact forms'));
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(200);
     // Test that anonymous users can access admin user's contact form.
     $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
     $this->assertResponse(200);
     $this->assertCacheContext('user');
     // Revoke the personal contact permission for the anonymous user.
     user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, array('access user contact forms'));
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(403);
     $this->assertCacheContext('user');
     $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
     $this->assertResponse(403);
     // Disable the personal contact form.
     $this->drupalLogin($this->adminUser);
     $edit = array('contact_default_status' => FALSE);
     $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration'));
     $this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.');
     $this->drupalLogout();
     // Re-create our contacted user with personal contact forms disabled by
     // default.
     $this->contactUser = $this->drupalCreateUser();
     // Test denied access to a user with contact form disabled.
     $this->drupalLogin($this->webUser);
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(403);
     // Test allowed access for admin user to a user with contact form disabled.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(200);
     // Re-create our contacted user as a blocked user.
     $this->contactUser = $this->drupalCreateUser();
     $this->contactUser->block();
     $this->contactUser->save();
     // Test that blocked users can still be contacted by admin.
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(200);
     // Test that blocked users cannot be contacted by non-admins.
     $this->drupalLogin($this->webUser);
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(403);
     // Test enabling and disabling the contact page through the user profile
     // form.
     $this->drupalGet('user/' . $this->webUser->id() . '/edit');
     $this->assertNoFieldChecked('edit-contact--2');
     $this->assertFalse(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form disabled');
     $this->drupalPostForm(NULL, array('contact' => TRUE), t('Save'));
     $this->assertFieldChecked('edit-contact--2');
     $this->assertTrue(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form enabled');
     // Test with disabled global default contact form in combination with a user
     // that has the contact form enabled.
     $this->config('contact.settings')->set('user_default_enabled', FALSE)->save();
     $this->contactUser = $this->drupalCreateUser();
     \Drupal::service('user.data')->set('contact', $this->contactUser->id(), 'enabled', 1);
     $this->drupalGet('user/' . $this->contactUser->id() . '/contact');
     $this->assertResponse(200);
 }
Exemplo n.º 23
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test');
     $this->installEntitySchema('user');
     $this->installEntitySchema('entity_test_rev');
     // Bypass any field access.
     $this->adminUser = User::create(['name' => $this->randomString()]);
     $this->adminUser->save();
     $this->container->get('current_user')->setAccount($this->adminUser);
     $this->testUsers = [];
     for ($i = 0; $i < 5; $i++) {
         $this->testUsers[$i] = User::create(['name' => 'test ' . $i, 'timezone' => User::getAllowedTimezones()[$i]]);
         $this->testUsers[$i]->save();
     }
     // Setup a field storage and field, but also change the views data for the
     // entity_test entity type.
     $field_storage = FieldStorageConfig::create(['field_name' => 'field_test', 'type' => 'integer', 'entity_type' => 'entity_test']);
     $field_storage->save();
     $field = FieldConfig::create(['field_name' => 'field_test', 'entity_type' => 'entity_test', 'bundle' => 'entity_test']);
     $field->save();
     $field_storage_multiple = FieldStorageConfig::create(['field_name' => 'field_test_multiple', 'type' => 'integer', 'entity_type' => 'entity_test', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED]);
     $field_storage_multiple->save();
     $field_multiple = FieldConfig::create(['field_name' => 'field_test_multiple', 'entity_type' => 'entity_test', 'bundle' => 'entity_test']);
     $field_multiple->save();
     $random_number = (string) 30856;
     $random_number_multiple = (string) 1370359990;
     for ($i = 0; $i < 5; $i++) {
         $this->entities[$i] = $entity = EntityTest::create(['bundle' => 'entity_test', 'name' => 'test ' . $i, 'field_test' => $random_number[$i], 'field_test_multiple' => [$random_number_multiple[$i * 2], $random_number_multiple[$i * 2 + 1]], 'user_id' => $this->testUsers[$i]->id()]);
         $entity->save();
     }
     // Setup some test data for entities with revisions.
     // We are testing both base field revisions and field config revisions.
     $field_storage = FieldStorageConfig::create(['field_name' => 'field_test', 'type' => 'integer', 'entity_type' => 'entity_test_rev']);
     $field_storage->save();
     $field = FieldConfig::create(['field_name' => 'field_test', 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev']);
     $field->save();
     $field_storage_multiple = FieldStorageConfig::create(['field_name' => 'field_test_multiple', 'type' => 'integer', 'entity_type' => 'entity_test_rev', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED]);
     $field_storage_multiple->save();
     $field_multiple = FieldConfig::create(['field_name' => 'field_test_multiple', 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev']);
     $field_multiple->save();
     $this->entityRevision = [];
     $this->entityRevision[0] = $entity = EntityTestRev::create(['name' => 'base value', 'field_test' => 1, 'field_test_multiple' => [1, 3, 7], 'user_id' => $this->testUsers[0]->id()]);
     $entity->save();
     $original_entity = clone $entity;
     $entity = clone $original_entity;
     $entity->setNewRevision(TRUE);
     $entity->name->value = 'revision value1';
     $entity->field_test->value = 2;
     $entity->field_test_multiple[0]->value = 0;
     $entity->field_test_multiple[1]->value = 3;
     $entity->field_test_multiple[2]->value = 5;
     $entity->user_id->target_id = $this->testUsers[1]->id();
     $entity->save();
     $this->entityRevision[1] = $entity;
     $entity = clone $original_entity;
     $entity->setNewRevision(TRUE);
     $entity->name->value = 'revision value2';
     $entity->field_test->value = 3;
     $entity->field_test_multiple[0]->value = 9;
     $entity->field_test_multiple[1]->value = 9;
     $entity->field_test_multiple[2]->value = 9;
     $entity->user_id->target_id = $this->testUsers[2]->id();
     $entity->save();
     $this->entityRevision[2] = $entity;
     $this->entityRevision[3] = $entity = EntityTestRev::create(['name' => 'next entity value', 'field_test' => 4, 'field_test_multiple' => [2, 9, 9], 'user_id' => $this->testUsers[3]->id()]);
     $entity->save();
     \Drupal::state()->set('entity_test.views_data', ['entity_test' => ['id' => ['field' => ['id' => 'field']]], 'entity_test_rev_revision' => ['id' => ['field' => ['id' => 'field']]]]);
     Views::viewsData()->clear();
 }
Exemplo n.º 24
0
 /**
  * Tests CRUD operations.
  */
 public function testCRUD()
 {
     $types_data = ['profile_type_0' => ['label' => $this->randomMachineName()], 'profile_type_1' => ['label' => $this->randomMachineName()]];
     /** @var ProfileType[] $types */
     $types = [];
     foreach ($types_data as $id => $values) {
         $types[$id] = ProfileType::create(['id' => $id] + $values);
         $types[$id]->save();
     }
     $this->user1 = User::create(['name' => $this->randomMachineName(), 'mail' => $this->randomMachineName() . '@example.com']);
     $this->user1->save();
     $this->user2 = User::create(['name' => $this->randomMachineName(), 'mail' => $this->randomMachineName() . '@example.com']);
     $this->user2->save();
     $this->profileStorage = \Drupal::entityTypeManager()->getStorage('profile');
     // Create a new profile.
     $profile = Profile::create($expected = ['type' => $types['profile_type_0']->id(), 'uid' => $this->user1->id()]);
     $this->assertIdentical($profile->id(), NULL);
     $this->assertTrue($profile->uuid());
     $this->assertIdentical($profile->getType(), $expected['type']);
     $expected_label = t('@type profile of @username (uid: @uid)', ['@type' => $types['profile_type_0']->label(), '@username' => $this->user1->getDisplayName(), '@uid' => $this->user1->id()]);
     $this->assertEqual($profile->label(), $expected_label, new FormattableMarkup('Expected "%expected" but got "%got"', ['%expected' => $expected_label, '%got' => $profile->label()]));
     $this->assertIdentical($profile->getOwnerId(), $this->user1->id());
     $this->assertIdentical($profile->getCreatedTime(), REQUEST_TIME);
     $this->assertIdentical($profile->getChangedTime(), REQUEST_TIME);
     // Save the profile.
     $status = $profile->save();
     $this->assertIdentical($status, SAVED_NEW);
     $this->assertTrue($profile->id());
     $this->assertIdentical($profile->getChangedTime(), REQUEST_TIME);
     // List profiles for the user and verify that the new profile appears.
     $list = $this->profileStorage->loadByProperties(['uid' => $this->user1->id()]);
     $list_ids = array_keys($list);
     $this->assertEqual($list_ids, [(int) $profile->id()]);
     // Reload and update the profile.
     /** @var Profile $profile */
     $profile = Profile::load($profile->id());
     $profile->setChangedTime($profile->getChangedTime() - 1000);
     $original = clone $profile;
     $status = $profile->save();
     $this->assertIdentical($status, SAVED_UPDATED);
     $this->assertIdentical($profile->id(), $original->id());
     $this->assertEqual($profile->getCreatedTime(), REQUEST_TIME);
     $this->assertEqual($original->getChangedTime(), REQUEST_TIME - 1000);
     // Changed time is only updated when saved through the UI form.
     // @see \Drupal\Core\Entity\ContentEntityForm::submitForm().
     $this->assertEqual($profile->getChangedTime(), REQUEST_TIME - 1000);
     // Create a second profile.
     $user1_profile1 = $profile;
     $profile = Profile::create(['type' => $types['profile_type_0']->id(), 'uid' => $this->user1->id()]);
     $status = $profile->save();
     $this->assertIdentical($status, SAVED_NEW);
     $user1_profile = $profile;
     // List profiles for the user and verify that both profiles appear.
     $list = $this->profileStorage->loadByProperties(['uid' => $this->user1->id()]);
     $list_ids = array_keys($list);
     $this->assertEqual($list_ids, [(int) $user1_profile1->id(), (int) $user1_profile->id()]);
     // Delete the second profile and verify that the first still exists.
     $user1_profile->delete();
     $this->assertFalse(Profile::load($user1_profile->id()));
     $list = $this->profileStorage->loadByProperties(['uid' => $this->user1->id()]);
     $list_ids = array_keys($list);
     $this->assertEqual($list_ids, [(int) $user1_profile1->id()]);
     // Create a new second profile.
     $user1_profile = Profile::create(['type' => $types['profile_type_1']->id(), 'uid' => $this->user1->id()]);
     $status = $user1_profile->save();
     $this->assertIdentical($status, SAVED_NEW);
     // Create a profile for the second user.
     $user2_profile1 = Profile::create(['type' => $types['profile_type_0']->id(), 'uid' => $this->user2->id()]);
     $status = $user2_profile1->save();
     $this->assertIdentical($status, SAVED_NEW);
     // Delete the first user and verify that all of its profiles are deleted.
     $this->user1->delete();
     $this->assertFalse(User::load($this->user1->id()));
     $list = $this->profileStorage->loadByProperties(['uid' => $this->user1->id()]);
     $list_ids = array_keys($list);
     $this->assertEqual($list_ids, []);
     // List profiles for the second user and verify that they still exist.
     $list = $this->profileStorage->loadByProperties(['uid' => $this->user2->id()]);
     $list_ids = array_keys($list);
     $this->assertEqual($list_ids, [(int) $user2_profile1->id()]);
     // @todo Rename a profile type; verify that existing profiles are updated.
 }
Exemplo n.º 25
0
 /**
  * Tests Standard installation profile.
  */
 function testStandard()
 {
     $this->drupalGet('');
     $this->assertLink(t('Contact'));
     $this->clickLink(t('Contact'));
     $this->assertResponse(200);
     // Test anonymous user can access 'Main navigation' block.
     $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'post comments', 'skip comment approval', 'create article content', 'create page content'));
     $this->drupalLogin($this->adminUser);
     // Configure the block.
     $this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik');
     $this->drupalPostForm(NULL, array('region' => 'sidebar_first', 'id' => 'main_navigation'), t('Save block'));
     // Verify admin user can see the block.
     $this->drupalGet('');
     $this->assertText('Main navigation');
     // Verify we have role = aria on system_powered_by and help_block
     // blocks.
     $this->drupalGet('admin/structure/block');
     $elements = $this->xpath('//div[@role=:role and @id=:id]', array(':role' => 'complementary', ':id' => 'block-bartik-help'));
     $this->assertEqual(count($elements), 1, 'Found complementary role on help block.');
     $this->drupalGet('');
     $elements = $this->xpath('//div[@role=:role and @id=:id]', array(':role' => 'complementary', ':id' => 'block-bartik-powered'));
     $this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');
     // Verify anonymous user can see the block.
     $this->drupalLogout();
     $this->assertText('Main navigation');
     // Ensure comments don't show in the front page RSS feed.
     // Create an article.
     $this->drupalCreateNode(array('type' => 'article', 'title' => 'Foobar', 'promote' => 1, 'status' => 1, 'body' => array(array('value' => 'Then she picked out two somebodies,<br />Sally and me', 'format' => 'basic_html'))));
     // Add a comment.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/1');
     $this->assertRaw('Then she picked out two somebodies,<br />Sally and me', 'Found a line break.');
     $this->drupalPostForm(NULL, array('subject[0][value]' => 'Barfoo', 'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me'), t('Save'));
     // Fetch the feed.
     $this->drupalGet('rss.xml');
     $this->assertText('Foobar');
     $this->assertNoText('Then she picked out two somebodies, Sally and me');
     // Ensure block body exists.
     $this->drupalGet('block/add');
     $this->assertFieldByName('body[0][value]');
     // Now we have all configuration imported, test all of them for schema
     // conformance. Ensures all imported default configuration is valid when
     // standard profile modules are enabled.
     $names = $this->container->get('config.storage')->listAll();
     /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
     $typed_config = $this->container->get('config.typed');
     foreach ($names as $name) {
         $config = $this->config($name);
         $this->assertConfigSchema($typed_config, $name, $config->get());
     }
     // Ensure that configuration from the Standard profile is not reused when
     // enabling a module again since it contains configuration that can not be
     // installed. For example, editor.editor.basic_html is editor configuration
     // that depends on the ckeditor module. The ckeditor module can not be
     // installed before the editor module since it depends on the editor module.
     // The installer does not have this limitation since it ensures that all of
     // the install profiles dependencies are installed before creating the
     // editor configuration.
     \Drupal::service('module_installer')->uninstall(array('editor', 'ckeditor'));
     $this->rebuildContainer();
     \Drupal::service('module_installer')->install(array('editor'));
     /** @var \Drupal\contact\ContactFormInterface $contact_form */
     $contact_form = ContactForm::load('feedback');
     $recipients = $contact_form->getRecipients();
     $this->assertEqual(['*****@*****.**'], $recipients);
     $role = Role::create(['id' => 'admin_theme', 'label' => 'Admin theme']);
     $role->grantPermission('view the administration theme');
     $role->save();
     $this->adminUser->addRole($role->id());
     $this->adminUser->save();
     $this->drupalGet('node/add');
     $this->assertResponse(200);
 }
Exemplo n.º 26
0
 /**
  * {@inheritdoc}
  */
 public function save()
 {
     return $this->subject->save();
 }
Exemplo n.º 27
0
 /**
  * Tests Standard installation profile.
  */
 function testStandard()
 {
     $this->drupalGet('');
     $this->assertLink(t('Contact'));
     $this->clickLink(t('Contact'));
     $this->assertResponse(200);
     // Test anonymous user can access 'Main navigation' block.
     $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'post comments', 'skip comment approval', 'create article content', 'create page content'));
     $this->drupalLogin($this->adminUser);
     // Configure the block.
     $this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik');
     $this->drupalPostForm(NULL, array('region' => 'sidebar_first', 'id' => 'main_navigation'), t('Save block'));
     // Verify admin user can see the block.
     $this->drupalGet('');
     $this->assertText('Main navigation');
     // Verify we have role = aria on system_powered_by and help_block
     // blocks.
     $this->drupalGet('admin/structure/block');
     $elements = $this->xpath('//div[@role=:role and @id=:id]', array(':role' => 'complementary', ':id' => 'block-bartik-help'));
     $this->assertEqual(count($elements), 1, 'Found complementary role on help block.');
     $this->drupalGet('');
     $elements = $this->xpath('//div[@role=:role and @id=:id]', array(':role' => 'complementary', ':id' => 'block-bartik-powered'));
     $this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');
     // Verify anonymous user can see the block.
     $this->drupalLogout();
     $this->assertText('Main navigation');
     // Ensure comments don't show in the front page RSS feed.
     // Create an article.
     $this->drupalCreateNode(array('type' => 'article', 'title' => 'Foobar', 'promote' => 1, 'status' => 1, 'body' => array(array('value' => 'Then she picked out two somebodies,<br />Sally and me', 'format' => 'basic_html'))));
     // Add a comment.
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('node/1');
     $this->assertRaw('Then she picked out two somebodies,<br />Sally and me', 'Found a line break.');
     $this->drupalPostForm(NULL, array('subject[0][value]' => 'Barfoo', 'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me'), t('Save'));
     // Fetch the feed.
     $this->drupalGet('rss.xml');
     $this->assertText('Foobar');
     $this->assertNoText('Then she picked out two somebodies, Sally and me');
     // Ensure block body exists.
     $this->drupalGet('block/add');
     $this->assertFieldByName('body[0][value]');
     // Now we have all configuration imported, test all of them for schema
     // conformance. Ensures all imported default configuration is valid when
     // standard profile modules are enabled.
     $names = $this->container->get('config.storage')->listAll();
     /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
     $typed_config = $this->container->get('config.typed');
     foreach ($names as $name) {
         $config = $this->config($name);
         $this->assertConfigSchema($typed_config, $name, $config->get());
     }
     // Ensure that configuration from the Standard profile is not reused when
     // enabling a module again since it contains configuration that can not be
     // installed. For example, editor.editor.basic_html is editor configuration
     // that depends on the ckeditor module. The ckeditor module can not be
     // installed before the editor module since it depends on the editor module.
     // The installer does not have this limitation since it ensures that all of
     // the install profiles dependencies are installed before creating the
     // editor configuration.
     foreach (FilterFormat::loadMultiple() as $filter) {
         // Ensure that editor can be uninstalled by removing use in filter
         // formats. It is necessary to prime the filter collection before removing
         // the filter.
         $filter->filters();
         $filter->removeFilter('editor_file_reference');
         $filter->save();
     }
     \Drupal::service('module_installer')->uninstall(array('editor', 'ckeditor'));
     $this->rebuildContainer();
     \Drupal::service('module_installer')->install(array('editor'));
     /** @var \Drupal\contact\ContactFormInterface $contact_form */
     $contact_form = ContactForm::load('feedback');
     $recipients = $contact_form->getRecipients();
     $this->assertEqual(['*****@*****.**'], $recipients);
     $role = Role::create(['id' => 'admin_theme', 'label' => 'Admin theme']);
     $role->grantPermission('view the administration theme');
     $role->save();
     $this->adminUser->addRole($role->id());
     $this->adminUser->save();
     $this->drupalGet('node/add');
     $this->assertResponse(200);
     // Ensure that there are no pending updates after installation.
     $this->drupalLogin($this->rootUser);
     $this->drupalGet('update.php/selection');
     $this->assertText('No pending updates.');
     // Ensure that there are no pending entity updates after installation.
     $this->assertFalse($this->container->get('entity.definition_update_manager')->needsUpdates(), 'After installation, entity schema is up to date.');
     // Make sure the optional image styles are not installed.
     $this->drupalGet('admin/config/media/image-styles');
     $this->assertNoText('Max 325x325');
     $this->assertNoText('Max 650x650');
     $this->assertNoText('Max 1300x1300');
     $this->assertNoText('Max 2600x2600');
     // Make sure the optional image styles are installed after enabling
     // the responsive_image module.
     \Drupal::service('module_installer')->install(array('responsive_image'));
     $this->rebuildContainer();
     $this->drupalGet('admin/config/media/image-styles');
     $this->assertText('Max 325x325');
     $this->assertText('Max 650x650');
     $this->assertText('Max 1300x1300');
     $this->assertText('Max 2600x2600');
     // Verify certain routes' responses are cacheable by Dynamic Page Cache, to
     // ensure these responses are very fast for authenticated users.
     $this->dumpHeaders = TRUE;
     $this->drupalLogin($this->adminUser);
     $url = Url::fromRoute('contact.site_page');
     $this->drupalGet($url);
     $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Site-wide contact page cannot be cached by Dynamic Page Cache.');
     $url = Url::fromRoute('<front>');
     $this->drupalGet($url);
     $this->drupalGet($url);
     $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Frontpage is cached by Dynamic Page Cache.');
     // @todo uncomment after https://www.drupal.org/node/2543334 has landed.
     //url = Url::fromRoute('entity.node.canonical', ['node' => 1]);
     //$this->drupalGet($url);
     //$this->drupalGet($url);
     //$this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Full node page is cached by Dynamic Page Cache.');
     $url = Url::fromRoute('entity.user.canonical', ['user' => 1]);
     $this->drupalGet($url);
     $this->drupalGet($url);
     $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.');
 }