PrintableLinksBlockTest.php in Printer and PDF versions for Drupal 8+ 2.x
File
tests/src/Unit/Plugin/Derivative/PrintableLinksBlockTest.php
View source
<?php
namespace Drupal\Tests\printable\Unit\Plugin\Derivative;
use Drupal\Tests\UnitTestCase;
use Drupal\printable\Plugin\Derivative\PrintableLinksBlock;
class PrintableLinksBlockTest extends UnitTestCase {
public static function getInfo() {
return [
'name' => 'Printable Block Derivative',
'descriptions' => 'Tests the printable block plugin derivative class.',
'group' => 'Printable',
];
}
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));
}
}