You are here

protected function BricksTest::setUp in Bricks​ 2.x

Same name in this branch
  1. 2.x tests/src/Functional/BricksTest.php \Drupal\Tests\bricks\Functional\BricksTest::setUp()
  2. 2.x tests/src/Kernel/BricksTest.php \Drupal\Tests\bricks\Kernel\BricksTest::setUp()
Same name and namespace in other branches
  1. 8 tests/src/Functional/BricksTest.php \Drupal\Tests\bricks\Functional\BricksTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/Functional/BricksTest.php, line 37

Class

BricksTest
Class BricksTest

Namespace

Drupal\Tests\bricks\Functional

Code

protected function setUp() {
  parent::setUp();
  $this
    ->drupalLogin($this->rootUser);
  $this->vocabulary = $this
    ->createVocabulary();

  // Place the actions and title block.
  $this
    ->drupalPlaceBlock('page_title_block', [
    'region' => 'content',
    'weight' => -5,
  ]);
  $this
    ->drupalPlaceBlock('local_tasks_block', [
    'region' => 'content',
    'weight' => -10,
  ]);
  $this
    ->drupalPlaceBlock('local_actions_block', [
    'region' => 'content',
    'weight' => -12,
  ]);

  // Create an article content type that we will use for testing.
  $type = \Drupal::service('entity_type.manager')
    ->getStorage('node_type')
    ->create([
    'type' => 'article',
    'name' => 'Article',
  ]);
  $type
    ->save();
  $this
    ->drupalGet('admin/structure/types/manage/article/fields');
  $this
    ->clickLink('Add field');
  $edit = [
    'new_storage_type' => 'field_ui:entity_reference:taxonomy_term',
    'label' => 'Brick field',
    'field_name' => 'brick',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save and continue');
  $edit = [
    'cardinality' => -1,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save field settings');
  $edit = [
    'settings[handler_settings][auto_create]' => TRUE,
    'settings[handler_settings][target_bundles][' . $this->vocabulary
      ->id() . ']' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save settings');
}