1 | <?php |
||
14 | class SettingsMenuAdaptorTest extends TestCase |
||
15 | { |
||
16 | /** @var AuthorizationCheckerInterface (mock) */ |
||
17 | private $authorizationCheckerInterface; |
||
18 | |||
19 | /** |
||
20 | * @var bool |
||
21 | */ |
||
22 | private $isEnabledVersionChecker = true; |
||
23 | |||
24 | public function setUp() |
||
28 | |||
29 | /** |
||
30 | * @dataProvider provider |
||
31 | * |
||
32 | * @param TopMenuItem|null $parent |
||
33 | * @param string $requestRoute |
||
34 | * @param int $expectedCount |
||
35 | * @param string|null $expectedLabel |
||
36 | * @param bool $granted |
||
37 | */ |
||
38 | public function testAdaptChildren(?TopMenuItem $parent, string $requestRoute, int $expectedCount, ?string $expectedLabel, bool $granted) |
||
39 | { |
||
40 | $children = []; |
||
41 | /** @var MenuBuilder $menuBuilderMock */ |
||
42 | $menuBuilderMock = $this->createMock(MenuBuilder::class); |
||
43 | /** @var Request $request */ |
||
44 | $request = new Request([], [], ['_route' => $requestRoute]); |
||
45 | $this->authorizationCheckerInterface |
||
46 | ->expects($this->any()) |
||
47 | ->method('isGranted') |
||
48 | ->willReturn($granted); |
||
49 | |||
50 | $settingsMenuAdaptorMock = $this->setUpSettingsMenuAdaptorMock(); |
||
51 | $settingsMenuAdaptorMock->adaptChildren($menuBuilderMock, $children, $parent, $request); |
||
52 | |||
53 | $this->assertCount($expectedCount, $children); |
||
54 | $this->assertContainsOnlyInstancesOf(MenuItem::class, $children); |
||
55 | |||
56 | if (null !== $expectedLabel) { |
||
57 | $this->assertEquals($expectedLabel, $children[0]->getLabel()); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return \PHPUnit\Framework\MockObject\MockObject|SettingsMenuAdaptor |
||
63 | */ |
||
64 | public function setUpSettingsMenuAdaptorMock() |
||
74 | |||
75 | public function testHasInterface() |
||
80 | |||
81 | public function provider() |
||
107 | } |
||
108 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..