public function PrintableEntityManagerTest::testGetPrintableEntities in Printer and PDF versions for Drupal 8+ 8
Same name and namespace in other branches
- 2.x tests/src/Unit/PrintableEntityManagerTest.php \Drupal\Tests\printable\Unit\PrintableEntityManagerTest::testGetPrintableEntities()
Tests getting the printable entities.
@covers PrintableEntityManager::GetPrintableEntities
File
- tests/
src/ Unit/ PrintableEntityManagerTest.php, line 31
Class
- PrintableEntityManagerTest
- Tests the printable entity manager plugin.
Namespace
Drupal\Tests\printable\UnitCode
public function testGetPrintableEntities() {
// Construct a printable entity manager and it's dependencies.
$entity_definition = $this
->getMockBuilder('Drupal\\Core\\Entity\\EntityType')
->disableOriginalConstructor()
->getMock();
$entity_definition
->expects($this
->any())
->method('hasHandlerClass')
->will($this
->returnValue(TRUE));
$entity_manager = $this
->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
$entity_manager
->expects($this
->once())
->method('getDefinitions')
->will($this
->returnValue([
'node' => $entity_definition,
'comment' => $entity_definition,
]));
$config = $this
->getConfigFactoryStub([
'printable.settings' => [
'printable_entities' => [
'node',
'comment',
'bar',
],
],
]);
$printable_entity_manager = new PrintableEntityManager($entity_manager, $config);
// Verify getting the printable entities.
$expected_entity_definitions = [
'node' => $entity_definition,
'comment' => $entity_definition,
];
$this
->assertEquals($expected_entity_definitions, $printable_entity_manager
->getPrintableEntities());
}