comparison core/profiles/standard/tests/src/Functional/StandardTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\standard\Functional; 3 namespace Drupal\Tests\standard\Functional;
4 4
5 use Drupal\Component\Utility\Html;
6 use Drupal\media\Entity\MediaType;
5 use Drupal\Tests\SchemaCheckTestTrait; 7 use Drupal\Tests\SchemaCheckTestTrait;
6 use Drupal\contact\Entity\ContactForm; 8 use Drupal\contact\Entity\ContactForm;
7 use Drupal\Core\Url; 9 use Drupal\Core\Url;
8 use Drupal\dynamic_page_cache\EventSubscriber\DynamicPageCacheSubscriber; 10 use Drupal\dynamic_page_cache\EventSubscriber\DynamicPageCacheSubscriber;
9 use Drupal\filter\Entity\FilterFormat; 11 use Drupal\filter\Entity\FilterFormat;
195 197
196 $url = Url::fromRoute('entity.user.canonical', ['user' => 1]); 198 $url = Url::fromRoute('entity.user.canonical', ['user' => 1]);
197 $this->drupalGet($url); 199 $this->drupalGet($url);
198 $this->drupalGet($url); 200 $this->drupalGet($url);
199 $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.'); 201 $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.');
202
203 // Make sure the editorial workflow is installed after enabling the
204 // content_moderation module.
205 \Drupal::service('module_installer')->install(['content_moderation']);
206 $role = Role::create([
207 'id' => 'admin_workflows',
208 'label' => 'Admin workflow',
209 ]);
210 $role->grantPermission('administer workflows');
211 $role->save();
212 $this->adminUser->addRole($role->id());
213 $this->adminUser->save();
214 $this->rebuildContainer();
215 $this->drupalGet('admin/config/workflow/workflows/manage/editorial');
216 $this->assertText('Draft');
217 $this->assertText('Published');
218 $this->assertText('Archived');
219 $this->assertText('Create New Draft');
220 $this->assertText('Publish');
221 $this->assertText('Archive');
222 $this->assertText('Restore to Draft');
223 $this->assertText('Restore');
224
225 \Drupal::service('module_installer')->install(['media']);
226 $role = Role::create([
227 'id' => 'admin_media',
228 'label' => 'Admin media',
229 ]);
230 $role->grantPermission('administer media');
231 $role->save();
232 $this->adminUser->addRole($role->id());
233 $this->adminUser->save();
234 $assert_session = $this->assertSession();
235 $page = $this->getSession()->getPage();
236 /** @var \Drupal\media\Entity\MediaType $media_type */
237 foreach (MediaType::loadMultiple() as $media_type) {
238 $media_type_machine_name = $media_type->id();
239 $this->drupalGet('media/add/' . $media_type_machine_name);
240 // Get the form element, and its HTML representation.
241 $form_selector = '#media-' . Html::cleanCssIdentifier($media_type_machine_name) . '-add-form';
242 $form = $assert_session->elementExists('css', $form_selector);
243 $form_html = $form->getOuterHtml();
244
245 // The name field (if it exists) should come before the source field,
246 // which should itself come before the vertical tabs.
247 $test_source_field = $assert_session->fieldExists($media_type->getSource()->getSourceFieldDefinition($media_type)->getLabel(), $form)->getOuterHtml();
248 $vertical_tabs = $assert_session->elementExists('css', '.form-type-vertical-tabs', $form)->getOuterHtml();
249 $date_field = $assert_session->fieldExists('Date', $form)->getOuterHtml();
250 $published_checkbox = $assert_session->fieldExists('Published', $form)->getOuterHtml();
251 if ($page->findField('Name')) {
252 $name_field = $assert_session->fieldExists('Name', $form)->getOuterHtml();
253 $this->assertTrue(strpos($form_html, $test_source_field) > strpos($form_html, $name_field));
254 }
255 $this->assertTrue(strpos($form_html, $vertical_tabs) > strpos($form_html, $test_source_field));
256 // The "Published" checkbox should be the last element.
257 $this->assertTrue(strpos($form_html, $published_checkbox) > strpos($form_html, $date_field));
258 }
200 } 259 }
201 260
202 } 261 }