Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Tests\standard\Functional;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Tests\SchemaCheckTestTrait;
|
Chris@0
|
6 use Drupal\contact\Entity\ContactForm;
|
Chris@0
|
7 use Drupal\Core\Url;
|
Chris@0
|
8 use Drupal\dynamic_page_cache\EventSubscriber\DynamicPageCacheSubscriber;
|
Chris@0
|
9 use Drupal\filter\Entity\FilterFormat;
|
Chris@0
|
10 use Drupal\Tests\BrowserTestBase;
|
Chris@0
|
11 use Drupal\user\Entity\Role;
|
Chris@0
|
12
|
Chris@0
|
13 /**
|
Chris@0
|
14 * Tests Standard installation profile expectations.
|
Chris@0
|
15 *
|
Chris@0
|
16 * @group standard
|
Chris@0
|
17 */
|
Chris@0
|
18 class StandardTest extends BrowserTestBase {
|
Chris@0
|
19
|
Chris@0
|
20 use SchemaCheckTestTrait;
|
Chris@0
|
21
|
Chris@0
|
22 protected $profile = 'standard';
|
Chris@0
|
23
|
Chris@0
|
24 /**
|
Chris@0
|
25 * The admin user.
|
Chris@0
|
26 *
|
Chris@0
|
27 * @var \Drupal\user\UserInterface
|
Chris@0
|
28 */
|
Chris@0
|
29 protected $adminUser;
|
Chris@0
|
30
|
Chris@0
|
31 /**
|
Chris@0
|
32 * Tests Standard installation profile.
|
Chris@0
|
33 */
|
Chris@0
|
34 public function testStandard() {
|
Chris@0
|
35 $this->drupalGet('');
|
Chris@0
|
36 $this->assertLink(t('Contact'));
|
Chris@0
|
37 $this->clickLink(t('Contact'));
|
Chris@0
|
38 $this->assertResponse(200);
|
Chris@0
|
39
|
Chris@0
|
40 // Test anonymous user can access 'Main navigation' block.
|
Chris@0
|
41 $this->adminUser = $this->drupalCreateUser([
|
Chris@0
|
42 'administer blocks',
|
Chris@0
|
43 'post comments',
|
Chris@0
|
44 'skip comment approval',
|
Chris@0
|
45 'create article content',
|
Chris@0
|
46 'create page content',
|
Chris@0
|
47 ]);
|
Chris@0
|
48 $this->drupalLogin($this->adminUser);
|
Chris@0
|
49 // Configure the block.
|
Chris@0
|
50 $this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik');
|
Chris@0
|
51 $this->drupalPostForm(NULL, [
|
Chris@0
|
52 'region' => 'sidebar_first',
|
Chris@0
|
53 'id' => 'main_navigation',
|
Chris@0
|
54 ], t('Save block'));
|
Chris@0
|
55 // Verify admin user can see the block.
|
Chris@0
|
56 $this->drupalGet('');
|
Chris@0
|
57 $this->assertText('Main navigation');
|
Chris@0
|
58
|
Chris@0
|
59 // Verify we have role = aria on system_powered_by and help_block
|
Chris@0
|
60 // blocks.
|
Chris@0
|
61 $this->drupalGet('admin/structure/block');
|
Chris@0
|
62 $elements = $this->xpath('//div[@role=:role and @id=:id]', [
|
Chris@0
|
63 ':role' => 'complementary',
|
Chris@0
|
64 ':id' => 'block-bartik-help',
|
Chris@0
|
65 ]);
|
Chris@0
|
66
|
Chris@0
|
67 $this->assertEqual(count($elements), 1, 'Found complementary role on help block.');
|
Chris@0
|
68
|
Chris@0
|
69 $this->drupalGet('');
|
Chris@0
|
70 $elements = $this->xpath('//div[@role=:role and @id=:id]', [
|
Chris@0
|
71 ':role' => 'complementary',
|
Chris@0
|
72 ':id' => 'block-bartik-powered',
|
Chris@0
|
73 ]);
|
Chris@0
|
74 $this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.');
|
Chris@0
|
75
|
Chris@0
|
76 // Verify anonymous user can see the block.
|
Chris@0
|
77 $this->drupalLogout();
|
Chris@0
|
78 $this->assertText('Main navigation');
|
Chris@0
|
79
|
Chris@0
|
80 // Ensure comments don't show in the front page RSS feed.
|
Chris@0
|
81 // Create an article.
|
Chris@0
|
82 $this->drupalCreateNode([
|
Chris@0
|
83 'type' => 'article',
|
Chris@0
|
84 'title' => 'Foobar',
|
Chris@0
|
85 'promote' => 1,
|
Chris@0
|
86 'status' => 1,
|
Chris@0
|
87 'body' => [['value' => 'Then she picked out two somebodies,<br />Sally and me', 'format' => 'basic_html']],
|
Chris@0
|
88 ]);
|
Chris@0
|
89
|
Chris@0
|
90 // Add a comment.
|
Chris@0
|
91 $this->drupalLogin($this->adminUser);
|
Chris@0
|
92 $this->drupalGet('node/1');
|
Chris@0
|
93 $this->assertRaw('Then she picked out two somebodies,<br />Sally and me', 'Found a line break.');
|
Chris@0
|
94 $this->drupalPostForm(NULL, [
|
Chris@0
|
95 'subject[0][value]' => 'Barfoo',
|
Chris@0
|
96 'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me',
|
Chris@0
|
97 ], t('Save'));
|
Chris@0
|
98 // Fetch the feed.
|
Chris@0
|
99 $this->drupalGet('rss.xml');
|
Chris@0
|
100 $this->assertText('Foobar');
|
Chris@0
|
101 $this->assertNoText('Then she picked out two somebodies, Sally and me');
|
Chris@0
|
102
|
Chris@0
|
103 // Ensure block body exists.
|
Chris@0
|
104 $this->drupalGet('block/add');
|
Chris@0
|
105 $this->assertFieldByName('body[0][value]');
|
Chris@0
|
106
|
Chris@0
|
107 // Now we have all configuration imported, test all of them for schema
|
Chris@0
|
108 // conformance. Ensures all imported default configuration is valid when
|
Chris@0
|
109 // standard profile modules are enabled.
|
Chris@0
|
110 $names = $this->container->get('config.storage')->listAll();
|
Chris@0
|
111 /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
|
Chris@0
|
112 $typed_config = $this->container->get('config.typed');
|
Chris@0
|
113 foreach ($names as $name) {
|
Chris@0
|
114 $config = $this->config($name);
|
Chris@0
|
115 $this->assertConfigSchema($typed_config, $name, $config->get());
|
Chris@0
|
116 }
|
Chris@0
|
117
|
Chris@0
|
118 // Ensure that configuration from the Standard profile is not reused when
|
Chris@0
|
119 // enabling a module again since it contains configuration that can not be
|
Chris@0
|
120 // installed. For example, editor.editor.basic_html is editor configuration
|
Chris@0
|
121 // that depends on the ckeditor module. The ckeditor module can not be
|
Chris@0
|
122 // installed before the editor module since it depends on the editor module.
|
Chris@0
|
123 // The installer does not have this limitation since it ensures that all of
|
Chris@0
|
124 // the install profiles dependencies are installed before creating the
|
Chris@0
|
125 // editor configuration.
|
Chris@0
|
126 foreach (FilterFormat::loadMultiple() as $filter) {
|
Chris@0
|
127 // Ensure that editor can be uninstalled by removing use in filter
|
Chris@0
|
128 // formats. It is necessary to prime the filter collection before removing
|
Chris@0
|
129 // the filter.
|
Chris@0
|
130 $filter->filters();
|
Chris@0
|
131 $filter->removeFilter('editor_file_reference');
|
Chris@0
|
132 $filter->save();
|
Chris@0
|
133 }
|
Chris@0
|
134 \Drupal::service('module_installer')->uninstall(['editor', 'ckeditor']);
|
Chris@0
|
135 $this->rebuildContainer();
|
Chris@0
|
136 \Drupal::service('module_installer')->install(['editor']);
|
Chris@0
|
137 /** @var \Drupal\contact\ContactFormInterface $contact_form */
|
Chris@0
|
138 $contact_form = ContactForm::load('feedback');
|
Chris@0
|
139 $recipients = $contact_form->getRecipients();
|
Chris@0
|
140 $this->assertEqual(['simpletest@example.com'], $recipients);
|
Chris@0
|
141
|
Chris@0
|
142 $role = Role::create([
|
Chris@0
|
143 'id' => 'admin_theme',
|
Chris@0
|
144 'label' => 'Admin theme',
|
Chris@0
|
145 ]);
|
Chris@0
|
146 $role->grantPermission('view the administration theme');
|
Chris@0
|
147 $role->save();
|
Chris@0
|
148 $this->adminUser->addRole($role->id());
|
Chris@0
|
149 $this->adminUser->save();
|
Chris@0
|
150 $this->drupalGet('node/add');
|
Chris@0
|
151 $this->assertResponse(200);
|
Chris@0
|
152
|
Chris@0
|
153 // Ensure that there are no pending updates after installation.
|
Chris@0
|
154 $this->drupalLogin($this->rootUser);
|
Chris@0
|
155 $this->drupalGet('update.php/selection');
|
Chris@0
|
156 $this->assertText('No pending updates.');
|
Chris@0
|
157
|
Chris@0
|
158 // Ensure that there are no pending entity updates after installation.
|
Chris@0
|
159 $this->assertFalse($this->container->get('entity.definition_update_manager')->needsUpdates(), 'After installation, entity schema is up to date.');
|
Chris@0
|
160
|
Chris@0
|
161 // Make sure the optional image styles are not installed.
|
Chris@0
|
162 $this->drupalGet('admin/config/media/image-styles');
|
Chris@0
|
163 $this->assertNoText('Max 325x325');
|
Chris@0
|
164 $this->assertNoText('Max 650x650');
|
Chris@0
|
165 $this->assertNoText('Max 1300x1300');
|
Chris@0
|
166 $this->assertNoText('Max 2600x2600');
|
Chris@0
|
167
|
Chris@0
|
168 // Make sure the optional image styles are installed after enabling
|
Chris@0
|
169 // the responsive_image module.
|
Chris@0
|
170 \Drupal::service('module_installer')->install(['responsive_image']);
|
Chris@0
|
171 $this->rebuildContainer();
|
Chris@0
|
172 $this->drupalGet('admin/config/media/image-styles');
|
Chris@0
|
173 $this->assertText('Max 325x325');
|
Chris@0
|
174 $this->assertText('Max 650x650');
|
Chris@0
|
175 $this->assertText('Max 1300x1300');
|
Chris@0
|
176 $this->assertText('Max 2600x2600');
|
Chris@0
|
177
|
Chris@0
|
178 // Verify certain routes' responses are cacheable by Dynamic Page Cache, to
|
Chris@0
|
179 // ensure these responses are very fast for authenticated users.
|
Chris@0
|
180 $this->dumpHeaders = TRUE;
|
Chris@0
|
181 $this->drupalLogin($this->adminUser);
|
Chris@0
|
182 $url = Url::fromRoute('contact.site_page');
|
Chris@0
|
183 $this->drupalGet($url);
|
Chris@0
|
184 $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Site-wide contact page cannot be cached by Dynamic Page Cache.');
|
Chris@0
|
185
|
Chris@0
|
186 $url = Url::fromRoute('<front>');
|
Chris@0
|
187 $this->drupalGet($url);
|
Chris@0
|
188 $this->drupalGet($url);
|
Chris@0
|
189 $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Frontpage is cached by Dynamic Page Cache.');
|
Chris@0
|
190
|
Chris@0
|
191 $url = Url::fromRoute('entity.node.canonical', ['node' => 1]);
|
Chris@0
|
192 $this->drupalGet($url);
|
Chris@0
|
193 $this->drupalGet($url);
|
Chris@0
|
194 $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Full node page is cached by Dynamic Page Cache.');
|
Chris@0
|
195
|
Chris@0
|
196 $url = Url::fromRoute('entity.user.canonical', ['user' => 1]);
|
Chris@0
|
197 $this->drupalGet($url);
|
Chris@0
|
198 $this->drupalGet($url);
|
Chris@0
|
199 $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.');
|
Chris@0
|
200 }
|
Chris@0
|
201
|
Chris@0
|
202 }
|