Skip to content

Commit 4ad33a7

Browse files
committed
Fixed tests
1 parent d035042 commit 4ad33a7

File tree

1 file changed

+48
-11
lines changed

1 file changed

+48
-11
lines changed

test/Unit/OpCache/StatusTest.php

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ protected function setUp()
9494
*/
9595
public function testGetStatusInfo()
9696
{
97-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $this->statusData);
97+
$status = new Status(
98+
$this->getMock('\\OpCacheGUI\\Format\\Byte'),
99+
$this->getMock('\\OpCacheGUI\\I18n\\Translator'),
100+
$this->statusData
101+
);
98102

99103
$data = [];
100104

@@ -118,7 +122,7 @@ public function testGetMemoryInfo()
118122
$formatter = $this->getMock('\\OpCacheGUI\\Format\\Byte');
119123
$formatter->method('format')->will($this->onConsecutiveCalls('1KB', '2KB', '3KB'));
120124

121-
$status = new Status($formatter, $this->statusData);
125+
$status = new Status($formatter, $this->getMock('\\OpCacheGUI\\I18n\\Translator'), $this->statusData);
122126

123127
$data = $this->statusData;
124128

@@ -136,7 +140,14 @@ public function testGetMemoryInfo()
136140
*/
137141
public function testGetGraphMemoryInfo()
138142
{
139-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $this->statusData);
143+
$translator = $this->getMock('\\OpCacheGUI\\I18n\\Translator');
144+
$translator->method('translate')->will($this->onConsecutiveCalls('Used', 'Free', 'Wasted'));
145+
146+
$status = new Status(
147+
$this->getMock('\\OpCacheGUI\\Format\\Byte'),
148+
$translator,
149+
$this->statusData
150+
);
140151

141152
$data = [
142153
[
@@ -168,7 +179,11 @@ public function testGetStatsInfoWithOpCacheDisabled()
168179
$statusData = $this->statusData;
169180
$statusData['opcache_enabled'] = false;
170181

171-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $statusData);
182+
$status = new Status(
183+
$this->getMock('\\OpCacheGUI\\Format\\Byte'),
184+
$this->getMock('\\OpCacheGUI\\I18n\\Translator'),
185+
$statusData
186+
);
172187

173188
$data = [
174189
[
@@ -199,7 +214,11 @@ public function testGetStatsInfoWithOpCacheDisabled()
199214
*/
200215
public function testGetStatsInfoWithOpCacheEnabled()
201216
{
202-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $this->statusData);
217+
$status = new Status(
218+
$this->getMock('\\OpCacheGUI\\Format\\Byte'),
219+
$this->getMock('\\OpCacheGUI\\I18n\\Translator'),
220+
$this->statusData
221+
);
203222

204223
$data = $this->statusData['opcache_statistics'];
205224

@@ -226,7 +245,11 @@ public function testGetStatsInfoWithOpCacheEnabledWithoutRestart()
226245

227246
$statusData['opcache_statistics']['last_restart_time'] = 0;
228247

229-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $statusData);
248+
$status = new Status(
249+
$this->getMock('\\OpCacheGUI\\Format\\Byte'),
250+
$this->getMock('\\OpCacheGUI\\I18n\\Translator'),
251+
$statusData
252+
);
230253

231254
$data = $this->statusData['opcache_statistics'];
232255

@@ -249,7 +272,10 @@ public function testGetStatsInfoWithOpCacheEnabledWithoutRestart()
249272
*/
250273
public function testGetGraphKeyStatsInfo()
251274
{
252-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $this->statusData);
275+
$translator = $this->getMock('\\OpCacheGUI\\I18n\\Translator');
276+
$translator->method('translate')->will($this->onConsecutiveCalls('Used', 'Free', 'Wasted'));
277+
278+
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $translator, $this->statusData);
253279

254280
$data = [
255281
[
@@ -278,7 +304,10 @@ public function testGetGraphKeyStatsInfo()
278304
*/
279305
public function testGetGraphHitStatsInfo()
280306
{
281-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $this->statusData);
307+
$translator = $this->getMock('\\OpCacheGUI\\I18n\\Translator');
308+
$translator->method('translate')->will($this->onConsecutiveCalls('Hits', 'Misses', 'Blacklisted'));
309+
310+
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $translator, $this->statusData);
282311

283312
$data = [
284313
[
@@ -311,7 +340,11 @@ public function testGetCachedScriptsEmpty()
311340

312341
unset($statusData['scripts']);
313342

314-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $statusData);
343+
$status = new Status(
344+
$this->getMock('\\OpCacheGUI\\Format\\Byte'),
345+
$this->getMock('\\OpCacheGUI\\I18n\\Translator'),
346+
$statusData
347+
);
315348

316349
$this->assertSame([], $status->getCachedScripts());
317350
}
@@ -326,7 +359,7 @@ public function testGetCachedScriptsFilled()
326359
$formatter = $this->getMock('\\OpCacheGUI\\Format\\Byte');
327360
$formatter->method('format')->will($this->onConsecutiveCalls('1KB', '2KB', '3KB', '4KB', '5KB', '6KB'));
328361

329-
$status = new Status($formatter, $this->statusData);
362+
$status = new Status($formatter, $this->getMock('\\OpCacheGUI\\I18n\\Translator'), $this->statusData);
330363

331364
$data = [
332365
[
@@ -395,7 +428,11 @@ public function testGetCachedScriptsZeroedTimestamp()
395428
],
396429
];
397430

398-
$status = new Status($this->getMock('\\OpCacheGUI\\Format\\Byte'), $statusData);
431+
$status = new Status(
432+
$this->getMock('\\OpCacheGUI\\Format\\Byte'),
433+
$this->getMock('\\OpCacheGUI\\I18n\\Translator'),
434+
$statusData
435+
);
399436

400437
$this->assertSame([], $status->getCachedScripts());
401438
}

0 commit comments

Comments
 (0)