1 | <?php |
||
22 | class AdminVoterTest extends AbstractVoterTest |
||
23 | { |
||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public function provideData() |
||
28 | { |
||
29 | return [ |
||
30 | 'no data' => [null, null, null, null], |
||
31 | 'no route and granted' => [$this->getAdmin('_sonata_admin'), '_sonata_admin', null, null], |
||
32 | 'no granted' => [$this->getAdmin('_sonata_admin', true, false), '_sonata_admin', null, null], |
||
33 | 'no code' => [$this->getAdmin('_sonata_admin_code', true, true), '_sonata_admin', null, null], |
||
34 | 'no code request' => [$this->getAdmin('_sonata_admin', true, true), '_sonata_admin_unexpected', null, null], |
||
35 | 'no route' => [$this->getAdmin('_sonata_admin', false, true), '_sonata_admin', null, null], |
||
36 | 'has admin' => [$this->getAdmin('_sonata_admin', true, true), '_sonata_admin', null, true], |
||
37 | 'has child admin' => [$this->getChildAdmin('_sonata_admin', '_sonata_child_admin', true, true), '_sonata_admin|_sonata_child_admin', null, true], |
||
38 | 'has bad child admin' => [$this->getChildAdmin('_sonata_admin', '_sonata_child_admin', true, true), '_sonata_admin|_sonata_child_admin_unexpected', null, null], |
||
39 | 'direct link' => ['admin_post', null, 'admin_post', true], |
||
40 | 'no direct link' => ['admin_post', null, 'admin_blog', null], |
||
41 | ]; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @group legacy |
||
46 | */ |
||
47 | public function testDeprecatedRequestSetter(): void |
||
48 | { |
||
49 | $request = new Request(); |
||
50 | |||
51 | $requestStack = new RequestStack(); |
||
52 | $requestStack->push($request); |
||
53 | |||
54 | $voter = new AdminVoter(); |
||
55 | $voter->setRequest($request); |
||
|
|||
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | protected function createVoter($dataVoter, $route) |
||
62 | { |
||
63 | $request = new Request(); |
||
64 | $request->request->set('_sonata_admin', $dataVoter); |
||
65 | $request->request->set('_route', $route); |
||
66 | |||
67 | $requestStack = new RequestStack(); |
||
68 | $requestStack->push($request); |
||
69 | |||
70 | $voter = new AdminVoter($requestStack); |
||
71 | |||
72 | return $voter; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | protected function createItem($data) |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | private function getAdmin($code, $list = false, $granted = false) |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | private function getChildAdmin($parentCode, $childCode, $list = false, $granted = false) |
||
164 | } |
||
165 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.