Chris@0: drupalGet('');
Chris@0: $this->assertLink(t('Contact'));
Chris@0: $this->clickLink(t('Contact'));
Chris@0: $this->assertResponse(200);
Chris@0:
Chris@0: // Test anonymous user can access 'Main navigation' block.
Chris@0: $this->adminUser = $this->drupalCreateUser([
Chris@0: 'administer blocks',
Chris@0: 'post comments',
Chris@0: 'skip comment approval',
Chris@0: 'create article content',
Chris@0: 'create page content',
Chris@0: ]);
Chris@0: $this->drupalLogin($this->adminUser);
Chris@0: // Configure the block.
Chris@0: $this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik');
Chris@0: $this->drupalPostForm(NULL, [
Chris@0: 'region' => 'sidebar_first',
Chris@0: 'id' => 'main_navigation',
Chris@0: ], t('Save block'));
Chris@0: // Verify admin user can see the block.
Chris@0: $this->drupalGet('');
Chris@0: $this->assertText('Main navigation');
Chris@0:
Chris@0: // Verify we have role = aria on system_powered_by and help_block
Chris@0: // blocks.
Chris@0: $this->drupalGet('admin/structure/block');
Chris@0: $elements = $this->xpath('//div[@role=:role and @id=:id]', [
Chris@0: ':role' => 'complementary',
Chris@0: ':id' => 'block-bartik-help',
Chris@0: ]);
Chris@0:
Chris@0: $this->assertEqual(count($elements), 1, 'Found complementary role on help block.');
Chris@0:
Chris@0: $this->drupalGet('');
Chris@0: $elements = $this->xpath('//div[@role=:role and @id=:id]', [
Chris@0: ':role' => 'complementary',
Chris@0: ':id' => 'block-bartik-powered',
Chris@0: ]);
Chris@0: $this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');
Chris@0:
Chris@0: // Verify anonymous user can see the block.
Chris@0: $this->drupalLogout();
Chris@0: $this->assertText('Main navigation');
Chris@0:
Chris@0: // Ensure comments don't show in the front page RSS feed.
Chris@0: // Create an article.
Chris@0: $this->drupalCreateNode([
Chris@0: 'type' => 'article',
Chris@0: 'title' => 'Foobar',
Chris@0: 'promote' => 1,
Chris@0: 'status' => 1,
Chris@0: 'body' => [['value' => 'Then she picked out two somebodies,
Sally and me', 'format' => 'basic_html']],
Chris@0: ]);
Chris@0:
Chris@0: // Add a comment.
Chris@0: $this->drupalLogin($this->adminUser);
Chris@0: $this->drupalGet('node/1');
Chris@0: $this->assertRaw('Then she picked out two somebodies,
Sally and me', 'Found a line break.');
Chris@0: $this->drupalPostForm(NULL, [
Chris@0: 'subject[0][value]' => 'Barfoo',
Chris@0: 'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me',
Chris@0: ], t('Save'));
Chris@0: // Fetch the feed.
Chris@0: $this->drupalGet('rss.xml');
Chris@0: $this->assertText('Foobar');
Chris@0: $this->assertNoText('Then she picked out two somebodies, Sally and me');
Chris@0:
Chris@0: // Ensure block body exists.
Chris@0: $this->drupalGet('block/add');
Chris@0: $this->assertFieldByName('body[0][value]');
Chris@0:
Chris@0: // Now we have all configuration imported, test all of them for schema
Chris@0: // conformance. Ensures all imported default configuration is valid when
Chris@0: // standard profile modules are enabled.
Chris@0: $names = $this->container->get('config.storage')->listAll();
Chris@0: /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
Chris@0: $typed_config = $this->container->get('config.typed');
Chris@0: foreach ($names as $name) {
Chris@0: $config = $this->config($name);
Chris@0: $this->assertConfigSchema($typed_config, $name, $config->get());
Chris@0: }
Chris@0:
Chris@0: // Ensure that configuration from the Standard profile is not reused when
Chris@0: // enabling a module again since it contains configuration that can not be
Chris@0: // installed. For example, editor.editor.basic_html is editor configuration
Chris@0: // that depends on the ckeditor module. The ckeditor module can not be
Chris@0: // installed before the editor module since it depends on the editor module.
Chris@0: // The installer does not have this limitation since it ensures that all of
Chris@0: // the install profiles dependencies are installed before creating the
Chris@0: // editor configuration.
Chris@0: foreach (FilterFormat::loadMultiple() as $filter) {
Chris@0: // Ensure that editor can be uninstalled by removing use in filter
Chris@0: // formats. It is necessary to prime the filter collection before removing
Chris@0: // the filter.
Chris@0: $filter->filters();
Chris@0: $filter->removeFilter('editor_file_reference');
Chris@0: $filter->save();
Chris@0: }
Chris@0: \Drupal::service('module_installer')->uninstall(['editor', 'ckeditor']);
Chris@0: $this->rebuildContainer();
Chris@0: \Drupal::service('module_installer')->install(['editor']);
Chris@0: /** @var \Drupal\contact\ContactFormInterface $contact_form */
Chris@0: $contact_form = ContactForm::load('feedback');
Chris@0: $recipients = $contact_form->getRecipients();
Chris@0: $this->assertEqual(['simpletest@example.com'], $recipients);
Chris@0:
Chris@0: $role = Role::create([
Chris@0: 'id' => 'admin_theme',
Chris@0: 'label' => 'Admin theme',
Chris@0: ]);
Chris@0: $role->grantPermission('view the administration theme');
Chris@0: $role->save();
Chris@0: $this->adminUser->addRole($role->id());
Chris@0: $this->adminUser->save();
Chris@0: $this->drupalGet('node/add');
Chris@0: $this->assertResponse(200);
Chris@0:
Chris@0: // Ensure that there are no pending updates after installation.
Chris@0: $this->drupalLogin($this->rootUser);
Chris@0: $this->drupalGet('update.php/selection');
Chris@18: $this->updateRequirementsProblem();
Chris@18: $this->drupalGet('update.php/selection');
Chris@0: $this->assertText('No pending updates.');
Chris@0:
Chris@0: // Ensure that there are no pending entity updates after installation.
Chris@0: $this->assertFalse($this->container->get('entity.definition_update_manager')->needsUpdates(), 'After installation, entity schema is up to date.');
Chris@0:
Chris@0: // Make sure the optional image styles are not installed.
Chris@0: $this->drupalGet('admin/config/media/image-styles');
Chris@0: $this->assertNoText('Max 325x325');
Chris@0: $this->assertNoText('Max 650x650');
Chris@0: $this->assertNoText('Max 1300x1300');
Chris@0: $this->assertNoText('Max 2600x2600');
Chris@0:
Chris@0: // Make sure the optional image styles are installed after enabling
Chris@0: // the responsive_image module.
Chris@0: \Drupal::service('module_installer')->install(['responsive_image']);
Chris@0: $this->rebuildContainer();
Chris@0: $this->drupalGet('admin/config/media/image-styles');
Chris@0: $this->assertText('Max 325x325');
Chris@0: $this->assertText('Max 650x650');
Chris@0: $this->assertText('Max 1300x1300');
Chris@0: $this->assertText('Max 2600x2600');
Chris@0:
Chris@0: // Verify certain routes' responses are cacheable by Dynamic Page Cache, to
Chris@0: // ensure these responses are very fast for authenticated users.
Chris@0: $this->dumpHeaders = TRUE;
Chris@0: $this->drupalLogin($this->adminUser);
Chris@0: $url = Url::fromRoute('contact.site_page');
Chris@0: $this->drupalGet($url);
Chris@0: $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Site-wide contact page cannot be cached by Dynamic Page Cache.');
Chris@0:
Chris@0: $url = Url::fromRoute('');
Chris@0: $this->drupalGet($url);
Chris@0: $this->drupalGet($url);
Chris@0: $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Frontpage is cached by Dynamic Page Cache.');
Chris@0:
Chris@0: $url = Url::fromRoute('entity.node.canonical', ['node' => 1]);
Chris@0: $this->drupalGet($url);
Chris@0: $this->drupalGet($url);
Chris@0: $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Full node page is cached by Dynamic Page Cache.');
Chris@0:
Chris@0: $url = Url::fromRoute('entity.user.canonical', ['user' => 1]);
Chris@0: $this->drupalGet($url);
Chris@0: $this->drupalGet($url);
Chris@0: $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.');
Chris@17:
Chris@17: // Make sure the editorial workflow is installed after enabling the
Chris@17: // content_moderation module.
Chris@17: \Drupal::service('module_installer')->install(['content_moderation']);
Chris@17: $role = Role::create([
Chris@17: 'id' => 'admin_workflows',
Chris@17: 'label' => 'Admin workflow',
Chris@17: ]);
Chris@17: $role->grantPermission('administer workflows');
Chris@17: $role->save();
Chris@17: $this->adminUser->addRole($role->id());
Chris@17: $this->adminUser->save();
Chris@17: $this->rebuildContainer();
Chris@17: $this->drupalGet('admin/config/workflow/workflows/manage/editorial');
Chris@17: $this->assertText('Draft');
Chris@17: $this->assertText('Published');
Chris@17: $this->assertText('Archived');
Chris@17: $this->assertText('Create New Draft');
Chris@17: $this->assertText('Publish');
Chris@17: $this->assertText('Archive');
Chris@17: $this->assertText('Restore to Draft');
Chris@17: $this->assertText('Restore');
Chris@17:
Chris@17: \Drupal::service('module_installer')->install(['media']);
Chris@17: $role = Role::create([
Chris@17: 'id' => 'admin_media',
Chris@17: 'label' => 'Admin media',
Chris@17: ]);
Chris@17: $role->grantPermission('administer media');
Chris@17: $role->save();
Chris@17: $this->adminUser->addRole($role->id());
Chris@17: $this->adminUser->save();
Chris@17: $assert_session = $this->assertSession();
Chris@17: $page = $this->getSession()->getPage();
Chris@17: /** @var \Drupal\media\Entity\MediaType $media_type */
Chris@17: foreach (MediaType::loadMultiple() as $media_type) {
Chris@17: $media_type_machine_name = $media_type->id();
Chris@17: $this->drupalGet('media/add/' . $media_type_machine_name);
Chris@17: // Get the form element, and its HTML representation.
Chris@17: $form_selector = '#media-' . Html::cleanCssIdentifier($media_type_machine_name) . '-add-form';
Chris@17: $form = $assert_session->elementExists('css', $form_selector);
Chris@17: $form_html = $form->getOuterHtml();
Chris@17:
Chris@18: // The name field should be hidden.
Chris@18: $assert_session->fieldNotExists('Name', $form);
Chris@18: // The source field should be shown before the vertical tabs.
Chris@17: $test_source_field = $assert_session->fieldExists($media_type->getSource()->getSourceFieldDefinition($media_type)->getLabel(), $form)->getOuterHtml();
Chris@17: $vertical_tabs = $assert_session->elementExists('css', '.form-type-vertical-tabs', $form)->getOuterHtml();
Chris@18: $this->assertTrue(strpos($form_html, $vertical_tabs) > strpos($form_html, $test_source_field));
Chris@18: // The "Published" checkbox should be the last element.
Chris@17: $date_field = $assert_session->fieldExists('Date', $form)->getOuterHtml();
Chris@17: $published_checkbox = $assert_session->fieldExists('Published', $form)->getOuterHtml();
Chris@17: $this->assertTrue(strpos($form_html, $published_checkbox) > strpos($form_html, $date_field));
Chris@17: }
Chris@0: }
Chris@0:
Chris@0: }