You are here

public function DisplayHelperTest::testNewComponents in Lightning Core 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Unit/DisplayHelperTest.php \Drupal\Tests\lightning_core\Unit\DisplayHelperTest::testNewComponents()
  2. 8 tests/src/Unit/DisplayHelperTest.php \Drupal\Tests\lightning_core\Unit\DisplayHelperTest::testNewComponents()
  3. 8.2 tests/src/Unit/DisplayHelperTest.php \Drupal\Tests\lightning_core\Unit\DisplayHelperTest::testNewComponents()
  4. 8.3 tests/src/Unit/DisplayHelperTest.php \Drupal\Tests\lightning_core\Unit\DisplayHelperTest::testNewComponents()

@covers ::getNewComponents

File

tests/src/Unit/DisplayHelperTest.php, line 21

Class

DisplayHelperTest
@coversDefaultClass \Drupal\lightning_core\DisplayHelper

Namespace

Drupal\Tests\lightning_core\Unit

Code

public function testNewComponents() {

  /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface|\Prophecy\Prophecy\ProphecyInterface $display */
  $display = $this
    ->prophesize(EntityDisplayInterface::class);
  $display
    ->getComponents()
    ->willReturn([
    'foo' => [
      'type' => 'fubar',
    ],
    'bar' => [
      'type' => 'pastafazoul',
    ],
  ]);

  /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface|\Prophecy\Prophecy\ProphecyInterface $original */
  $original = $this
    ->prophesize(EntityDisplayInterface::class);
  $original
    ->getComponents()
    ->willReturn([
    'foo' => [
      'type' => 'fubar',
    ],
  ]);
  $display = $display
    ->reveal();
  $display->original = $original
    ->reveal();
  $helper = new DisplayHelper($this
    ->prophesize(EntityTypeManagerInterface::class)
    ->reveal(), $this
    ->prophesize(EntityFieldManagerInterface::class)
    ->reveal());
  $components = $helper
    ->getNewComponents($display);
  $this
    ->assertArrayHasKey('bar', $components);
  $this
    ->assertArrayNotHasKey('foo', $components);
}