1 | <?php |
||
40 | class AbstractArticlePageAdminListConfiguratorTest extends PHPUnit_Framework_TestCase |
||
41 | { |
||
42 | /** |
||
43 | * @var AbstractArticlePageAdminListConfigurator |
||
44 | */ |
||
45 | protected $object; |
||
46 | |||
47 | /** |
||
48 | * @var EntityManager |
||
49 | */ |
||
50 | protected $em; |
||
51 | |||
52 | /** |
||
53 | * Sets up the fixture, for example, opens a network connection. |
||
54 | * This method is called before a test is executed. |
||
55 | */ |
||
56 | protected function setUp() |
||
57 | { |
||
58 | $em = $this->createMock(EntityManager::class); |
||
59 | $em->expects($this->any()) |
||
60 | ->method($this->anything()) |
||
61 | ->willReturn($em); |
||
62 | |||
63 | $acl = $this->createMock(AclHelper::class); |
||
64 | |||
65 | $repo = $this->createMock(EntityRepository::class); |
||
66 | $repo->expects($this->any()) |
||
67 | ->method($this->anything()) |
||
68 | ->willReturn([['fake' => 'array']]); |
||
69 | |||
70 | $this->em = $em; |
||
71 | |||
72 | /* @var EntityManager $em */ |
||
73 | /* @var AclHelper $acl */ |
||
74 | $this->object = new Configurator($em, $acl, 'nl', 'admin', $repo); |
||
75 | } |
||
76 | |||
77 | public function testGetters() |
||
78 | { |
||
79 | $this->assertEquals('KunstmaanArticleBundle', $this->object->getBundleName()); |
||
80 | $this->assertEquals('AbstractArticlePage', $this->object->getEntityName()); |
||
81 | $this->assertEquals('KunstmaanArticleBundle:AbstractArticlePageAdminList:list.html.twig', $this->object->getListTemplate()); |
||
82 | $this->assertEquals('KunstmaanArticleBundle:AbstractArticlePage', $this->object->getRepositoryName()); |
||
83 | } |
||
84 | |||
85 | public function testBuildFields() |
||
86 | { |
||
87 | $this->object->buildFields(); |
||
88 | $this->object->buildFilters(); |
||
89 | $fields = $this->object->getFields(); |
||
90 | $this->assertCount(4, $fields); |
||
91 | } |
||
92 | |||
93 | public function testGetUrls() |
||
94 | { |
||
95 | $node = new Node(); |
||
96 | $node->setId(1314); |
||
97 | $nodeTranslation = new NodeTranslation(); |
||
98 | /** @var NodeMenu $menu */ |
||
99 | $menu = $this->createMock(NodeMenu::class); |
||
100 | $item = new NodeMenuItem($node, $nodeTranslation, false, $menu); |
||
101 | |||
102 | $url = $this->object->getEditUrlFor($item); |
||
103 | |||
104 | $this->assertCount(2, $url); |
||
105 | $this->assertArrayHasKey('path', $url); |
||
106 | $this->assertArrayHasKey('params', $url); |
||
107 | $this->assertEquals('KunstmaanNodeBundle_nodes_edit', $url['path']); |
||
108 | $this->assertCount(1, $url['params']); |
||
109 | $this->assertEquals(1314, $url['params']['id']); |
||
110 | $url = $this->object->getEditUrlFor($item); |
||
111 | |||
112 | $url = $this->object->getDeleteUrlFor($item); |
||
113 | |||
114 | $this->assertCount(2, $url); |
||
115 | $this->assertArrayHasKey('path', $url); |
||
116 | $this->assertArrayHasKey('params', $url); |
||
117 | $this->assertEquals('KunstmaanNodeBundle_nodes_delete', $url['path']); |
||
118 | $this->assertCount(1, $url['params']); |
||
119 | $this->assertEquals(1314, $url['params']['id']); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * @throws \ReflectionException |
||
124 | */ |
||
125 | public function testGetQueryBuilder() |
||
153 | |||
154 | /** |
||
155 | * @throws \ReflectionException |
||
156 | */ |
||
157 | public function testEntityClassName() |
||
182 | |||
183 | /** |
||
184 | * @throws \ReflectionException |
||
185 | */ |
||
186 | public function testGetOverViewPages() |
||
204 | } |
||
205 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.