Mercurial > hg > isophonics-drupal-site
diff 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 |
line wrap: on
line diff
--- a/core/profiles/standard/tests/src/Functional/StandardTest.php Tue Jul 10 15:07:59 2018 +0100 +++ b/core/profiles/standard/tests/src/Functional/StandardTest.php Thu Feb 28 13:21:36 2019 +0000 @@ -2,6 +2,8 @@ namespace Drupal\Tests\standard\Functional; +use Drupal\Component\Utility\Html; +use Drupal\media\Entity\MediaType; use Drupal\Tests\SchemaCheckTestTrait; use Drupal\contact\Entity\ContactForm; use Drupal\Core\Url; @@ -197,6 +199,63 @@ $this->drupalGet($url); $this->drupalGet($url); $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'User profile page is cached by Dynamic Page Cache.'); + + // Make sure the editorial workflow is installed after enabling the + // content_moderation module. + \Drupal::service('module_installer')->install(['content_moderation']); + $role = Role::create([ + 'id' => 'admin_workflows', + 'label' => 'Admin workflow', + ]); + $role->grantPermission('administer workflows'); + $role->save(); + $this->adminUser->addRole($role->id()); + $this->adminUser->save(); + $this->rebuildContainer(); + $this->drupalGet('admin/config/workflow/workflows/manage/editorial'); + $this->assertText('Draft'); + $this->assertText('Published'); + $this->assertText('Archived'); + $this->assertText('Create New Draft'); + $this->assertText('Publish'); + $this->assertText('Archive'); + $this->assertText('Restore to Draft'); + $this->assertText('Restore'); + + \Drupal::service('module_installer')->install(['media']); + $role = Role::create([ + 'id' => 'admin_media', + 'label' => 'Admin media', + ]); + $role->grantPermission('administer media'); + $role->save(); + $this->adminUser->addRole($role->id()); + $this->adminUser->save(); + $assert_session = $this->assertSession(); + $page = $this->getSession()->getPage(); + /** @var \Drupal\media\Entity\MediaType $media_type */ + foreach (MediaType::loadMultiple() as $media_type) { + $media_type_machine_name = $media_type->id(); + $this->drupalGet('media/add/' . $media_type_machine_name); + // Get the form element, and its HTML representation. + $form_selector = '#media-' . Html::cleanCssIdentifier($media_type_machine_name) . '-add-form'; + $form = $assert_session->elementExists('css', $form_selector); + $form_html = $form->getOuterHtml(); + + // The name field (if it exists) should come before the source field, + // which should itself come before the vertical tabs. + $test_source_field = $assert_session->fieldExists($media_type->getSource()->getSourceFieldDefinition($media_type)->getLabel(), $form)->getOuterHtml(); + $vertical_tabs = $assert_session->elementExists('css', '.form-type-vertical-tabs', $form)->getOuterHtml(); + $date_field = $assert_session->fieldExists('Date', $form)->getOuterHtml(); + $published_checkbox = $assert_session->fieldExists('Published', $form)->getOuterHtml(); + if ($page->findField('Name')) { + $name_field = $assert_session->fieldExists('Name', $form)->getOuterHtml(); + $this->assertTrue(strpos($form_html, $test_source_field) > strpos($form_html, $name_field)); + } + $this->assertTrue(strpos($form_html, $vertical_tabs) > strpos($form_html, $test_source_field)); + // The "Published" checkbox should be the last element. + $this->assertTrue(strpos($form_html, $published_checkbox) > strpos($form_html, $date_field)); + } } }