1 | <?php |
||||||
2 | |||||||
3 | /** |
||||||
4 | * Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
||||||
5 | * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
||||||
6 | */ |
||||||
7 | |||||||
8 | namespace SprykerTest\Zed\ZedNavigation\Business\Model\Collector\Decorator; |
||||||
9 | |||||||
10 | use Spryker\Zed\ZedNavigation\Business\Model\Collector\Decorator\ZedNavigationCollectorCacheDecorator; |
||||||
11 | use SprykerTest\Zed\ZedNavigation\Business\ZedNavigationBusinessTester; |
||||||
12 | |||||||
13 | /** |
||||||
14 | * Auto-generated group annotations |
||||||
15 | * |
||||||
16 | * @group SprykerTest |
||||||
17 | * @group Zed |
||||||
18 | * @group ZedNavigation |
||||||
19 | * @group Business |
||||||
20 | * @group Model |
||||||
21 | * @group Collector |
||||||
22 | * @group Decorator |
||||||
23 | * @group ZedNavigationCollectorCacheDecoratorTest |
||||||
24 | * Add your own group annotations below this line |
||||||
25 | */ |
||||||
26 | class ZedNavigationCollectorCacheDecoratorTest extends ZedNavigationBusinessTester |
||||||
27 | { |
||||||
28 | /** |
||||||
29 | * @var string |
||||||
30 | */ |
||||||
31 | protected const NAVIGATION_TYPE_MAIN = 'main'; |
||||||
32 | |||||||
33 | /** |
||||||
34 | * @return void |
||||||
35 | */ |
||||||
36 | public function testIfCacheIsNotEnabledGetNavigationMustReturnNavigationFromCollector(): void |
||||||
37 | { |
||||||
38 | //prepare |
||||||
39 | $expectedNavigation = [['key' => 'value']]; |
||||||
40 | $navigationCacheMock = $this->getZedNavigationCacheMock(); |
||||||
41 | $navigationCollectorMock = $this->getZedNavigationCollectorMock(); |
||||||
42 | $configMock = $this->getZedNavigationConfigMock(); |
||||||
43 | $navigationCollectorCacheDecorator = new ZedNavigationCollectorCacheDecorator( |
||||||
44 | $navigationCollectorMock, |
||||||
45 | $navigationCacheMock, |
||||||
46 | $configMock, |
||||||
47 | ); |
||||||
48 | |||||||
49 | //assert |
||||||
50 | $navigationCacheMock |
||||||
51 | ->expects($this->never()) |
||||||
0 ignored issues
–
show
|
|||||||
52 | ->method('getNavigation'); |
||||||
53 | $navigationCollectorMock |
||||||
54 | ->expects($this->once()) |
||||||
0 ignored issues
–
show
The method
expects() does not exist on Spryker\Zed\ZedNavigatio...ationCollectorInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
55 | ->method('getNavigation') |
||||||
56 | ->will($this->returnValue($expectedNavigation)); |
||||||
57 | $configMock |
||||||
58 | ->expects($this->once()) |
||||||
0 ignored issues
–
show
The method
expects() does not exist on Spryker\Zed\ZedNavigation\ZedNavigationConfig .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
59 | ->method('isNavigationCacheEnabled') |
||||||
60 | ->will($this->returnValue(false)); |
||||||
61 | |||||||
62 | //act |
||||||
63 | $navigation = $navigationCollectorCacheDecorator->getNavigation(static::NAVIGATION_TYPE_MAIN); |
||||||
64 | |||||||
65 | //assert |
||||||
66 | $this->assertSame( |
||||||
67 | $expectedNavigation, |
||||||
68 | $navigation, |
||||||
69 | ); |
||||||
70 | } |
||||||
71 | |||||||
72 | /** |
||||||
73 | * @return void |
||||||
74 | */ |
||||||
75 | public function testIfCacheIsEnabledGetNavigationMustReturnNavigationFromCache(): void |
||||||
76 | { |
||||||
77 | //prepare |
||||||
78 | $expectedNavigation = [['key' => 'value']]; |
||||||
79 | $navigationCacheMock = $this->getZedNavigationCacheMockWithReturn($expectedNavigation); |
||||||
80 | $navigationCollectorMock = $this->getZedNavigationCollectorMock(); |
||||||
81 | $configMock = $this->getZedNavigationConfigMock(); |
||||||
82 | $navigationCollectorCacheDecorator = new ZedNavigationCollectorCacheDecorator( |
||||||
83 | $navigationCollectorMock, |
||||||
84 | $navigationCacheMock, |
||||||
85 | $configMock, |
||||||
86 | ); |
||||||
87 | |||||||
88 | //assert |
||||||
89 | $navigationCollectorMock |
||||||
90 | ->expects($this->never()) |
||||||
91 | ->method('getNavigation'); |
||||||
92 | $configMock |
||||||
93 | ->expects($this->once()) |
||||||
94 | ->method('isNavigationCacheEnabled') |
||||||
95 | ->will($this->returnValue(true)); |
||||||
96 | |||||||
97 | //act |
||||||
98 | $navigation = $navigationCollectorCacheDecorator->getNavigation(static::NAVIGATION_TYPE_MAIN); |
||||||
99 | |||||||
100 | //assert |
||||||
101 | $this->assertSame( |
||||||
102 | $expectedNavigation, |
||||||
103 | $navigation, |
||||||
104 | ); |
||||||
105 | } |
||||||
106 | |||||||
107 | /** |
||||||
108 | * @return void |
||||||
109 | */ |
||||||
110 | public function testReturnsCollectedNavigationWhenCacheIsEnabledButCacheDoesNotExists(): void |
||||||
111 | { |
||||||
112 | //prepare |
||||||
113 | $expectedNavigation = [['key' => 'value']]; |
||||||
114 | $navigationCacheMock = $this->getZedNavigationCacheMockWithReturn($expectedNavigation, false); |
||||||
115 | $navigationCollectorMock = $this->getZedNavigationCollectorMock(); |
||||||
116 | $configMock = $this->getZedNavigationConfigMock(); |
||||||
117 | $navigationCollectorCacheDecorator = new ZedNavigationCollectorCacheDecorator( |
||||||
118 | $navigationCollectorMock, |
||||||
119 | $navigationCacheMock, |
||||||
120 | $configMock, |
||||||
121 | ); |
||||||
122 | |||||||
123 | //assert |
||||||
124 | $configMock |
||||||
125 | ->expects($this->once()) |
||||||
126 | ->method('isNavigationCacheEnabled') |
||||||
127 | ->willReturn(true); |
||||||
128 | $navigationCacheMock |
||||||
129 | ->expects($this->once()) |
||||||
130 | ->method('setNavigation') |
||||||
131 | ->with($this->equalTo($expectedNavigation)); |
||||||
132 | $navigationCollectorMock |
||||||
133 | ->expects($this->once()) |
||||||
134 | ->method('getNavigation') |
||||||
135 | ->willReturn($expectedNavigation); |
||||||
136 | |||||||
137 | //act |
||||||
138 | $navigation = $navigationCollectorCacheDecorator->getNavigation(static::NAVIGATION_TYPE_MAIN); |
||||||
139 | |||||||
140 | //assert |
||||||
141 | $this->assertSame( |
||||||
142 | $expectedNavigation, |
||||||
143 | $navigation, |
||||||
144 | ); |
||||||
145 | } |
||||||
146 | } |
||||||
147 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.