-
Notifications
You must be signed in to change notification settings - Fork 2
/
PrintableEntityManagerTest.php
74 lines (65 loc) · 1.95 KB
/
PrintableEntityManagerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* @file
* Contains Drupal\Tests\printable\Unit\PrintableEntityManagerTest.
*/
namespace Drupal\Tests\printable\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\printable\PrintableEntityManager;
/**
* Tests the printable entity manager plugin.
*
* @group Printable
*/
class PrintableEntityManagerTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Printable Entity Manager',
'descriptions' => 'Tests the printable entity manager class.',
'group' => 'Printable',
);
}
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
}
/**
* Tests getting the printable entities.
*
* @covers PrintableEntityManager::GetPrintableEntities
*/
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(array(
'node' => $entity_definition,
'comment' => $entity_definition,
))
);
$config = $this->getConfigFactoryStub(array(
'printable.settings' => array(
'printable_entities' => array('node', 'comment', 'bar'),
),
));
$printable_entity_manager = new PrintableEntityManager($entity_manager, $config);
// Verify getting the printable entities.
$expected_entity_definitions = array(
'node' => $entity_definition,
'comment' => $entity_definition,
);
$this->assertEquals($expected_entity_definitions, $printable_entity_manager->getPrintableEntities());
}
}