You are here

protected function NodeViewTest::createViewModeAndDisplay in Node Option Premium 8

Creates a view mode and display.

Parameters

string $view_mode: The view mode to create.

3 calls to NodeViewTest::createViewModeAndDisplay()
NodeViewTest::testViewModesSetting in tests/src/Kernel/NodeViewTest.php
Tests view modes setting.
NodeViewTest::testViewNonPremiumNodeWithCustomViewMode in tests/src/Kernel/NodeViewTest.php
Tests displaying a non-premium node on custom view mode.
NodeViewTest::testWithCustomViewMode in tests/src/Kernel/NodeViewTest.php
Tests if premium message is shown on custom view mode by default.

File

tests/src/Kernel/NodeViewTest.php, line 80

Class

NodeViewTest
Tests displaying nodes.

Namespace

Drupal\Tests\nopremium\Kernel

Code

protected function createViewModeAndDisplay($view_mode) {
  EntityViewMode::create([
    'id' => 'node.' . $view_mode,
    'targetEntityType' => 'node',
  ])
    ->save();
  EntityViewDisplay::create([
    'targetEntityType' => 'node',
    'bundle' => 'article',
    'mode' => $view_mode,
    'status' => TRUE,
  ])
    ->setComponent('body')
    ->save();
}