You are here

public function PrintableLinksBlockTest::testGetDerivativeDefinitions in Printer and PDF versions for Drupal 8+ 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/Plugin/Derivative/PrintableLinksBlockTest.php \Drupal\Tests\printable\Unit\Plugin\Derivative\PrintableLinksBlockTest::testGetDerivativeDefinitions()

Tests getting the plugin label from the plugin.

@covers PrintableLinksBlock::GetDerivativeDefinitions

File

tests/src/Unit/Plugin/Derivative/PrintableLinksBlockTest.php, line 31

Class

PrintableLinksBlockTest
Tests the printable links block plugin derivative..

Namespace

Drupal\Tests\printable\Unit\Plugin\Derivative

Code

public function testGetDerivativeDefinitions() {
  $entity_definition = $this
    ->getMockBuilder('Drupal\\Core\\Entity\\EntityType')
    ->disableOriginalConstructor()
    ->getMock();
  $printable_format_manager = $this
    ->getMockBuilder('Drupal\\printable\\PrintableEntityManager')
    ->disableOriginalConstructor()
    ->getMock();
  $printable_format_manager
    ->expects($this
    ->once())
    ->method('getPrintableEntities')
    ->will($this
    ->returnValue([
    'foo' => $entity_definition,
    'bar' => $entity_definition,
  ]));
  $entity_definition
    ->expects($this
    ->at(0))
    ->method('getLabel')
    ->will($this
    ->returnValue('Foo'));
  $entity_definition
    ->expects($this
    ->at(1))
    ->method('getLabel')
    ->will($this
    ->returnValue('Bar'));
  $derivative = new PrintableLinksBlock($printable_format_manager);
  $base_plugin_definition = [
    'admin_label' => 'Printable Links Block',
  ];
  $expected = [
    'foo' => [
      'admin_label' => 'Printable Links Block (Foo)',
    ],
    'bar' => [
      'admin_label' => 'Printable Links Block (Bar)',
    ],
  ];
  $this
    ->assertEquals($expected, $derivative
    ->getDerivativeDefinitions($base_plugin_definition));
}