You are here

public function MicrositeLogoBrandingBlockTest::testBrandingBlock in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 modules/entity_hierarchy_microsite/tests/src/Functional/MicrositeLogoBrandingBlockTest.php \Drupal\Tests\entity_hierarchy_microsite\Functional\MicrositeLogoBrandingBlockTest::testBrandingBlock()

Tests branding block.

File

modules/entity_hierarchy_microsite/tests/src/Functional/MicrositeLogoBrandingBlockTest.php, line 42

Class

MicrositeLogoBrandingBlockTest
Defines a class for testing microsite logo plugin.

Namespace

Drupal\Tests\entity_hierarchy_microsite\Functional

Code

public function testBrandingBlock() {
  $assert = $this
    ->assertSession();
  $logo = $this
    ->createImageMedia();
  $root = $this
    ->createTestEntity(NULL, 'Root');
  $children = $this
    ->createChildEntities($root
    ->id(), 1);
  $child = reset($children);
  $microsite = Microsite::create([
    'name' => $child
      ->label(),
    'home' => $child,
    'logo' => $logo,
  ]);
  $microsite
    ->save();
  $this
    ->drupalGet($child
    ->toUrl());
  $element = $assert
    ->elementExists('css', 'a[rel=home]');
  $this
    ->assertStringContainsString($child
    ->label(), $element
    ->getAttribute('title'));
  $this
    ->drupalGet($root
    ->toUrl());
  $assert
    ->elementNotExists('css', 'a[rel=home]');
}