You are here

public function FlippyTest::setUp in Flippy 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/FlippyTest.php, line 29

Class

FlippyTest
Tests that the Flippy pagers are appearing.

Namespace

Drupal\Tests\flippy\Functional

Code

public function setUp() {
  parent::setUp();

  // Create an article content type that we will use for testing.
  $type = $this->container
    ->get('entity_type.manager')
    ->getStorage('node_type')
    ->create([
    'type' => 'article',
    'name' => 'Article',
  ]);
  $type
    ->save();
  $this->container
    ->get('router.builder')
    ->rebuild();

  // Enable flippy for article content type.
  \Drupal::configFactory()
    ->getEditable('flippy.settings')
    ->set('flippy_article', 1)
    ->set('flippy_prev_label_article', 'Previous')
    ->set('flippy_next_label_article', 'Next')
    ->set('flippy_first_label_article', 'First')
    ->set('flippy_last_label_article', 'Last')
    ->set('flippy_random_label_article', 'Random')
    ->save();

  // Create sample nodes in article content type.
  for ($i = 0; $i <= 2; $i++) {
    $node = $this->container
      ->get('entity_type.manager')
      ->getStorage('node')
      ->create([
      'type' => 'article',
      'title' => $i,
    ]);
    $node
      ->save();
  }
}