You are here

public function ResponsivePreviewContentFormTest::testBundleSettings in Responsive Theme Preview 8

Assure that the toolbar integration works on content forms.

File

tests/src/Functional/ResponsivePreviewContentFormTest.php, line 50

Class

ResponsivePreviewContentFormTest
Tests the toolbar integration.

Namespace

Drupal\Tests\responsive_preview\Functional

Code

public function testBundleSettings() {
  $tab_xpath = '//nav[@id="toolbar-bar"]//div[contains(@class, "toolbar-tab-responsive-preview")]';
  $this
    ->drupalLogin($this->testUser);
  $this
    ->drupalGet('node/add/article');
  $this
    ->assertSession()
    ->elementExists('xpath', $tab_xpath);
  $node = Node::create([
    'type' => 'article',
    'uid' => $this->testUser
      ->id(),
    'title' => $this
      ->randomString(),
  ]);
  $node
    ->save();
  $this
    ->drupalGet('node/' . $node
    ->id() . '/edit');
  $this
    ->assertSession()
    ->elementExists('xpath', $tab_xpath);
  $node_type = NodeType::load('article');
  $node_type
    ->setPreviewMode(DRUPAL_DISABLED);
  $node_type
    ->save();
  $this
    ->drupalGet('node/add/article');
  $this
    ->assertSession()
    ->elementNotExists('xpath', $tab_xpath);
  $this
    ->drupalGet('node/' . $node
    ->id() . '/edit');
  $this
    ->assertSession()
    ->elementNotExists('xpath', $tab_xpath);
}