You are here

protected function ViewsModerationStateFilterTest::setUp in Drupal 8

Same name in this branch
  1. 8 core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php \Drupal\Tests\content_moderation\Functional\ViewsModerationStateFilterTest::setUp()
  2. 8 core/modules/content_moderation/tests/src/Kernel/ViewsModerationStateFilterTest.php \Drupal\Tests\content_moderation\Kernel\ViewsModerationStateFilterTest::setUp()
Same name and namespace in other branches
  1. 9 core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php \Drupal\Tests\content_moderation\Functional\ViewsModerationStateFilterTest::setUp()

Overrides ViewTestBase::setUp

File

core/modules/content_moderation/tests/src/Functional/ViewsModerationStateFilterTest.php, line 45

Class

ViewsModerationStateFilterTest
Tests the views 'moderation_state_filter' filter plugin.

Namespace

Drupal\Tests\content_moderation\Functional

Code

protected function setUp($import_test_views = TRUE) {
  parent::setUp(FALSE);
  NodeType::create([
    'type' => 'example_a',
  ])
    ->save();
  NodeType::create([
    'type' => 'example_b',
  ])
    ->save();
  NodeType::create([
    'type' => 'example_c',
  ])
    ->save();
  $this
    ->createEditorialWorkflow();
  $new_workflow = Workflow::create([
    'type' => 'content_moderation',
    'id' => 'new_workflow',
    'label' => 'New workflow',
  ]);
  $new_workflow
    ->getTypePlugin()
    ->addState('bar', 'Bar');
  $new_workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('node', 'example_c');
  $new_workflow
    ->save();
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer workflows',
    'administer views',
  ]));
  $this->container
    ->get('module_installer')
    ->install([
    'content_moderation_test_views',
  ]);
  $new_workflow
    ->getTypePlugin()
    ->removeEntityTypeAndBundle('node', 'example_c');
  $new_workflow
    ->save();
}