You are here

public function DisplayHelperTest::testNewComponents in Lightning Core 8.2

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.3 tests/src/Unit/DisplayHelperTest.php \Drupal\Tests\lightning_core\Unit\DisplayHelperTest::testNewComponents()
  4. 8.4 tests/src/Unit/DisplayHelperTest.php \Drupal\Tests\lightning_core\Unit\DisplayHelperTest::testNewComponents()

@covers ::getNewComponents

File

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

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(QueryFactory::class)
    ->reveal(), $this
    ->prophesize(EntityFieldManagerInterface::class)
    ->reveal());
  $components = $helper
    ->getNewComponents($display);
  $this
    ->assertArrayHasKey('bar', $components);
  $this
    ->assertArrayNotHasKey('foo', $components);
}