@@ -45,17 +45,6 @@ protected function setUp()
45
45
$ objectManager ->setBackwardCompatibleProperty ($ this ->object , 'logger ' , $ this ->loggerMock );
46
46
}
47
47
48
- public function testGetValueDeveloperMode ()
49
- {
50
- $ this ->appStateMock
51
- ->expects ($ this ->once ())
52
- ->method ('getMode ' )
53
- ->will ($ this ->returnValue (\Magento \Framework \App \State::MODE_DEVELOPER ));
54
- $ this ->versionStorageMock ->expects ($ this ->never ())->method ($ this ->anything ());
55
- $ this ->assertInternalType ('integer ' , $ this ->object ->getValue ());
56
- $ this ->object ->getValue (); // Ensure computation occurs only once and result is cached in memory
57
- }
58
-
59
48
/**
60
49
* @param string $appMode
61
50
* @dataProvider getValueFromStorageDataProvider
@@ -81,106 +70,45 @@ public function getValueFromStorageDataProvider()
81
70
];
82
71
}
83
72
84
- /**
85
- * $param bool $isUnexpectedValueExceptionThrown
86
- * $param bool $isFileSystemExceptionThrown
87
- * @dataProvider getValueDefaultModeDataProvider
88
- */
89
- public function testGetValueDefaultMode (
90
- $ isUnexpectedValueExceptionThrown ,
91
- $ isFileSystemExceptionThrown = null
92
- ) {
93
- $ versionType = 'integer ' ;
94
- $ this ->appStateMock
95
- ->expects ($ this ->once ())
96
- ->method ('getMode ' )
97
- ->willReturn (\Magento \Framework \App \State::MODE_DEFAULT );
98
- if ($ isUnexpectedValueExceptionThrown ) {
99
- $ storageException = new \UnexpectedValueException ('Does not exist in the storage ' );
100
- $ this ->versionStorageMock
101
- ->expects ($ this ->once ())
102
- ->method ('load ' )
103
- ->will ($ this ->throwException ($ storageException ));
104
- $ this ->versionStorageMock ->expects ($ this ->once ())
105
- ->method ('save ' )
106
- ->with ($ this ->isType ($ versionType ));
107
- if ($ isFileSystemExceptionThrown ) {
108
- $ fileSystemException = new FileSystemException (
109
- new \Magento \Framework \Phrase ('Can not load static content version ' )
110
- );
111
- $ this ->versionStorageMock
112
- ->expects ($ this ->once ())
113
- ->method ('save ' )
114
- ->will ($ this ->throwException ($ fileSystemException ));
115
- $ this ->loggerMock ->expects ($ this ->once ())
116
- ->method ('critical ' )
117
- ->with ('Can not save static content version. ' );
118
- } else {
119
- $ this ->loggerMock ->expects ($ this ->never ())
120
- ->method ('critical ' );
121
- }
122
- } else {
123
- $ this ->versionStorageMock
124
- ->expects ($ this ->once ())
125
- ->method ('load ' )
126
- ->willReturn (1475779229 );
127
- $ this ->loggerMock ->expects ($ this ->never ())
128
- ->method ('critical ' );
129
- }
130
- $ this ->assertInternalType ($ versionType , $ this ->object ->getValue ());
73
+ public function testGetValueInNonProductionMode () {
74
+ $ version = 123123123123 ;
75
+ $ this ->versionStorageMock ->expects ($ this ->once ())
76
+ ->method ('load ' )
77
+ ->willReturn ($ version );
78
+
79
+ $ this ->assertEquals ($ version , $ this ->object ->getValue ());
131
80
$ this ->object ->getValue ();
132
81
}
133
82
134
83
/**
135
- * @return array
84
+ * @expectedException \UnexpectedValueException
136
85
*/
137
- public function getValueDefaultModeDataProvider ()
86
+ public function testGetValueWithProductionModeAndException ()
138
87
{
139
- return [
140
- [false ],
141
- [true , false ],
142
- [true , true ]
143
- ];
144
- }
145
-
146
- /**
147
- * @param bool $isUnexpectedValueExceptionThrown
148
- * @dataProvider getValueProductionModeDataProvider
149
- */
150
- public function testGetValueProductionMode (
151
- $ isUnexpectedValueExceptionThrown
152
- ) {
153
- $ this ->appStateMock
154
- ->expects ($ this ->once ())
88
+ $ this ->versionStorageMock ->expects ($ this ->once ())
89
+ ->method ('load ' )
90
+ ->willReturn (false );
91
+ $ this ->appStateMock ->expects ($ this ->once ())
155
92
->method ('getMode ' )
156
93
->willReturn (\Magento \Framework \App \State::MODE_PRODUCTION );
157
- if ($ isUnexpectedValueExceptionThrown ) {
158
- $ storageException = new \UnexpectedValueException ('Does not exist in the storage ' );
159
- $ this ->versionStorageMock
160
- ->expects ($ this ->once ())
161
- ->method ('load ' )
162
- ->will ($ this ->throwException ($ storageException ));
163
- $ this ->loggerMock ->expects ($ this ->once ())
164
- ->method ('critical ' )
165
- ->with ('Can not load static content version. ' );
166
- } else {
167
- $ this ->versionStorageMock
168
- ->expects ($ this ->once ())
169
- ->method ('load ' )
170
- ->willReturn (1475779229 );
171
- }
172
- $ this ->assertInternalType ('integer ' , $ this ->object ->getValue ());
94
+ $ this ->loggerMock ->expects ($ this ->once ())
95
+ ->method ('critical ' )
96
+ ->with ('Can not load static content version. ' );
97
+
173
98
$ this ->object ->getValue ();
174
99
}
175
100
176
- /**
177
- * @return array
178
- */
179
- public function getValueProductionModeDataProvider ()
101
+ public function testGetValueWithProductionMode ()
180
102
{
181
- return [
182
- [false ],
183
- [true ],
184
- ];
103
+ $ this ->versionStorageMock ->expects ($ this ->once ())
104
+ ->method ('load ' )
105
+ ->willReturn (false );
106
+ $ this ->appStateMock ->expects ($ this ->once ())
107
+ ->method ('getMode ' )
108
+ ->willReturn (\Magento \Framework \App \State::MODE_DEFAULT );
109
+ $ this ->versionStorageMock ->expects ($ this ->once ())
110
+ ->method ('save ' );
111
+
112
+ $ this ->assertNotNull ($ this ->object ->getValue ());
185
113
}
186
114
}
0 commit comments