[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Report / ExtensionStatusTest.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Report;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Extensionmanager\Report;
18
19 /**
20 * Test case
21 */
22 class ExtensionStatusTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
23
24 /**
25 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
26 */
27 protected $mockObjectManager;
28
29 /**
30 * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
31 */
32 protected $mockRepositoryRepository;
33
34 /**
35 * @var \TYPO3\CMS\Lang\LanguageService
36 */
37 protected $mockLanguageService;
38
39 /**
40 * Set up
41 */
42 public function setUp() {
43 $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
44 /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
45 $this->mockRepositoryRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array(), array($this->mockObjectManager));
46 $this->mockLanguageService = $this->getMock('TYPO3\\CMS\\Lang\\LanguageService', array(), array(), '', FALSE);
47 }
48
49 /**
50 * @test
51 */
52 public function extensionStatusImplementsStatusProviderInterface() {
53 $reportMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array(), array(), '', FALSE);
54 $this->assertInstanceOf('TYPO3\\CMS\\Reports\\StatusProviderInterface', $reportMock);
55 }
56
57 /**
58 * @test
59 */
60 public function getStatusReturnsArray() {
61 $report = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('getSecurityStatusOfExtensions', 'getMainRepositoryStatus'), array(), '', FALSE);
62 $this->assertInternalType('array', $report->getStatus());
63 }
64
65 /**
66 * @test
67 */
68 public function getStatusReturnArrayContainsFiveEntries() {
69 $report = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('getSecurityStatusOfExtensions', 'getMainRepositoryStatus'), array(), '', FALSE);
70 $this->assertSame(5, count($report->getStatus()));
71 }
72
73 /**
74 * @test
75 */
76 public function getStatusReturnArrayContainsInstancesOfReportsStatusStatus() {
77 $statusObject = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array('title', 'value'));
78 /** @var \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus $report */
79 $report = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('getSecurityStatusOfExtensions', 'getMainRepositoryStatus'), array(), '', FALSE);
80 $report->expects($this->any())->method('getMainRepositoryStatus')->will($this->returnValue($statusObject));
81 $resultStatuses = $report->getStatus();
82 foreach($resultStatuses as $status) {
83 if ($status) {
84 $this->assertInstanceOf('TYPO3\\CMS\\Reports\\Status', $status);
85 }
86 }
87 }
88
89 /**
90 * @test
91 */
92 public function getStatusCallsGetMainRepositoryStatusForMainRepositoryStatusResult() {
93 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
94 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
95 $mockTerObject
96 ->expects($this->any())
97 ->method('getVersion')
98 ->will($this->returnValue('1.0.6'));
99 $mockTerObject
100 ->expects($this->atLeastOnce())
101 ->method('getReviewState')
102 ->will($this->returnValue(0));
103 $mockExtensionList = array(
104 'enetcache' => array(
105 'installed' => TRUE,
106 'terObject' => $mockTerObject
107 ),
108 );
109 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
110 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
111 $mockListUtility
112 ->expects($this->once())
113 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
114 ->will($this->returnValue($mockExtensionList));
115
116 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject */
117 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('getMainRepositoryStatus'), array(), '', FALSE);
118 $mockReport->_set('objectManager', $this->mockObjectManager);
119 $mockReport->_set('listUtility', $mockListUtility);
120 $mockReport->_set('languageService', $this->mockLanguageService);
121 $mockReport
122 ->expects($this->once())
123 ->method('getMainRepositoryStatus')
124 ->will($this->returnValue('foo'));
125
126 $result = $mockReport->getStatus();
127 $this->assertSame('foo', $result['mainRepositoryStatus']);
128 }
129
130 /**
131 * @test
132 */
133 public function getMainRepositoryStatusReturnsErrorStatusIfRepositoryIsNotFound() {
134 $this->mockRepositoryRepository
135 ->expects($this->once())
136 ->method('findOneTypo3OrgRepository')
137 ->will($this->returnValue(NULL));
138
139 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
140 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
141 $mockReport->_set('objectManager', $this->mockObjectManager);
142 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
143 $this->mockObjectManager
144 ->expects($this->once())
145 ->method('get')
146 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::ERROR)
147 ->will($this->returnValue($statusMock));
148 $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
149 $mockReport->_set('languageService', $this->mockLanguageService);
150
151 $result = $mockReport->_call('getMainRepositoryStatus');
152 $this->assertSame($statusMock, $result);
153 }
154
155 /**
156 * @test
157 */
158 public function getMainRepositoryStatusReturnsNoticeIfRepositoryUpdateIsLongerThanSevenDaysAgo() {
159 /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository|\PHPUnit_Framework_MockObject_MockObject */
160 $mockRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
161 $mockRepository
162 ->expects($this->once())
163 ->method('getLastUpdate')
164 ->will($this->returnValue(new \DateTime('-8 days')));
165
166 $this->mockRepositoryRepository
167 ->expects($this->once())
168 ->method('findOneTypo3OrgRepository')
169 ->will($this->returnValue($mockRepository));
170
171 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
172 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
173 $mockReport->_set('objectManager', $this->mockObjectManager);
174 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
175 $this->mockObjectManager
176 ->expects($this->once())
177 ->method('get')
178 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::NOTICE)
179 ->will($this->returnValue($statusMock));
180 $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
181 $mockReport->_set('languageService', $this->mockLanguageService);
182
183 /** @var $result \TYPO3\CMS\Reports\Status */
184 $result = $mockReport->_call('getMainRepositoryStatus');
185 $this->assertSame($statusMock, $result);
186 }
187
188 /**
189 * @test
190 */
191 public function getMainRepositoryStatusReturnsOkIfUpdatedLessThanSevenDaysAgo() {
192 /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository|\PHPUnit_Framework_MockObject_MockObject */
193 $mockRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
194 $mockRepository
195 ->expects($this->once())
196 ->method('getLastUpdate')
197 ->will($this->returnValue(new \DateTime('-6 days')));
198
199 $this->mockRepositoryRepository
200 ->expects($this->once())
201 ->method('findOneTypo3OrgRepository')
202 ->will($this->returnValue($mockRepository));
203
204 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
205 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
206 $mockReport->_set('objectManager', $this->mockObjectManager);
207 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
208 $this->mockObjectManager
209 ->expects($this->once())
210 ->method('get')
211 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::OK)
212 ->will($this->returnValue($statusMock));
213 $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
214 $mockReport->_set('languageService', $this->mockLanguageService);
215
216 /** @var $result \TYPO3\CMS\Reports\Status */
217 $result = $mockReport->_call('getMainRepositoryStatus');
218 $this->assertSame($statusMock, $result);
219 }
220
221 /**
222 * @test
223 */
224 public function getSecurityStatusOfExtensionsReturnsOkForLoadedExtensionIfNoInsecureExtensionIsLoaded() {
225 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
226 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
227 $mockTerObject
228 ->expects($this->any())
229 ->method('getVersion')
230 ->will($this->returnValue('1.0.6'));
231 $mockTerObject
232 ->expects($this->atLeastOnce())
233 ->method('getReviewState')
234 ->will($this->returnValue(0));
235 $mockExtensionList = array(
236 'enetcache' => array(
237 'installed' => TRUE,
238 'terObject' => $mockTerObject
239 ),
240 );
241 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
242 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
243 $mockListUtility
244 ->expects($this->once())
245 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
246 ->will($this->returnValue($mockExtensionList));
247
248 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
249 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
250 $mockReport->_set('objectManager', $this->mockObjectManager);
251 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
252 $this->mockObjectManager
253 ->expects($this->at(0))
254 ->method('get')
255 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::OK)
256 ->will($this->returnValue($statusMock));
257 $mockReport->_set('listUtility', $mockListUtility);
258 $mockReport->_set('languageService', $this->mockLanguageService);
259
260 $result = $mockReport->_call('getSecurityStatusOfExtensions');
261 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
262 $loadedResult = $result->loaded;
263 $this->assertSame($statusMock, $loadedResult);
264 }
265
266 /**
267 * @test
268 */
269 public function getSecurityStatusOfExtensionsReturnsErrorForLoadedExtensionIfInsecureExtensionIsLoaded() {
270 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
271 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
272 $mockTerObject
273 ->expects($this->any())
274 ->method('getVersion')
275 ->will($this->returnValue('1.0.6'));
276 $mockTerObject
277 ->expects($this->atLeastOnce())
278 ->method('getReviewState')
279 ->will($this->returnValue(-1));
280 $mockExtensionList = array(
281 'enetcache' => array(
282 'installed' => TRUE,
283 'terObject' => $mockTerObject
284 ),
285 );
286 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
287 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
288 $mockListUtility
289 ->expects($this->once())
290 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
291 ->will($this->returnValue($mockExtensionList));
292
293 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
294 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
295 $mockReport->_set('objectManager', $this->mockObjectManager);
296 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
297 $this->mockObjectManager
298 ->expects($this->at(0))
299 ->method('get')
300 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::ERROR)
301 ->will($this->returnValue($statusMock));
302 $mockReport->_set('listUtility', $mockListUtility);
303 $mockReport->_set('languageService', $this->mockLanguageService);
304
305 $result = $mockReport->_call('getSecurityStatusOfExtensions');
306 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
307 $loadedResult = $result->loaded;
308 $this->assertSame($statusMock, $loadedResult);
309 }
310
311 /**
312 * @test
313 */
314 public function getSecurityStatusOfExtensionsReturnsOkForExistingExtensionIfNoInsecureExtensionExists() {
315 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
316 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
317 $mockTerObject
318 ->expects($this->any())
319 ->method('getVersion')
320 ->will($this->returnValue('1.0.6'));
321 $mockTerObject
322 ->expects($this->atLeastOnce())
323 ->method('getReviewState')
324 ->will($this->returnValue(0));
325 $mockExtensionList = array(
326 'enetcache' => array(
327 'terObject' => $mockTerObject
328 ),
329 );
330 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
331 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
332 $mockListUtility
333 ->expects($this->once())
334 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
335 ->will($this->returnValue($mockExtensionList));
336
337 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
338 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
339 $mockReport->_set('objectManager', $this->mockObjectManager);
340 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
341 $this->mockObjectManager
342 ->expects($this->at(1))
343 ->method('get')
344 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::OK)
345 ->will($this->returnValue($statusMock));
346 $mockReport->_set('listUtility', $mockListUtility);
347 $mockReport->_set('languageService', $this->mockLanguageService);
348
349 $result = $mockReport->_call('getSecurityStatusOfExtensions');
350 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
351 $loadedResult = $result->existing;
352 $this->assertSame($statusMock, $loadedResult);
353 }
354
355 /**
356 * @test
357 */
358 public function getSecurityStatusOfExtensionsReturnsErrorForExistingExtensionIfInsecureExtensionExists() {
359 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
360 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
361 $mockTerObject
362 ->expects($this->any())
363 ->method('getVersion')
364 ->will($this->returnValue('1.0.6'));
365 $mockTerObject
366 ->expects($this->atLeastOnce())
367 ->method('getReviewState')
368 ->will($this->returnValue(-1));
369 $mockExtensionList = array(
370 'enetcache' => array(
371 'terObject' => $mockTerObject
372 ),
373 );
374 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
375 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
376 $mockListUtility
377 ->expects($this->once())
378 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
379 ->will($this->returnValue($mockExtensionList));
380
381 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
382 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
383 $mockReport->_set('objectManager', $this->mockObjectManager);
384 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
385 $this->mockObjectManager
386 ->expects($this->at(1))
387 ->method('get')
388 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::WARNING)
389 ->will($this->returnValue($statusMock));
390 $mockReport->_set('listUtility', $mockListUtility);
391 $mockReport->_set('languageService', $this->mockLanguageService);
392
393 $result = $mockReport->_call('getSecurityStatusOfExtensions');
394 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
395 $loadedResult = $result->existing;
396 $this->assertSame($statusMock, $loadedResult);
397 }
398
399 /**
400 * @test
401 */
402 public function getSecurityStatusOfExtensionsReturnsOkForLoadedExtensionIfNoOutdatedExtensionIsLoaded() {
403 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
404 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
405 $mockTerObject
406 ->expects($this->any())
407 ->method('getVersion')
408 ->will($this->returnValue('1.0.6'));
409 $mockTerObject
410 ->expects($this->atLeastOnce())
411 ->method('getReviewState')
412 ->will($this->returnValue(0));
413 $mockExtensionList = array(
414 'enetcache' => array(
415 'installed' => TRUE,
416 'terObject' => $mockTerObject
417 ),
418 );
419 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
420 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
421 $mockListUtility
422 ->expects($this->once())
423 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
424 ->will($this->returnValue($mockExtensionList));
425
426 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
427 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
428 $mockReport->_set('objectManager', $this->mockObjectManager);
429 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
430 $this->mockObjectManager
431 ->expects($this->at(2))
432 ->method('get')
433 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::OK)
434 ->will($this->returnValue($statusMock));
435 $mockReport->_set('listUtility', $mockListUtility);
436 $mockReport->_set('languageService', $this->mockLanguageService);
437
438 $result = $mockReport->_call('getSecurityStatusOfExtensions');
439 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
440 $loadedResult = $result->loadedoutdated;
441 $this->assertSame($statusMock, $loadedResult);
442 }
443
444 /**
445 * @test
446 */
447 public function getSecurityStatusOfExtensionsReturnsErrorForLoadedExtensionIfOutdatedExtensionIsLoaded() {
448 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
449 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
450 $mockTerObject
451 ->expects($this->any())
452 ->method('getVersion')
453 ->will($this->returnValue('1.0.6'));
454 $mockTerObject
455 ->expects($this->atLeastOnce())
456 ->method('getReviewState')
457 ->will($this->returnValue(-2));
458 $mockExtensionList = array(
459 'enetcache' => array(
460 'installed' => TRUE,
461 'terObject' => $mockTerObject
462 ),
463 );
464 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
465 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
466 $mockListUtility
467 ->expects($this->once())
468 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
469 ->will($this->returnValue($mockExtensionList));
470
471 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
472 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
473 $mockReport->_set('objectManager', $this->mockObjectManager);
474 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
475 $this->mockObjectManager
476 ->expects($this->at(2))
477 ->method('get')
478 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::WARNING)
479 ->will($this->returnValue($statusMock));
480 $mockReport->_set('listUtility', $mockListUtility);
481 $mockReport->_set('languageService', $this->mockLanguageService);
482
483 $result = $mockReport->_call('getSecurityStatusOfExtensions');
484 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
485 $loadedResult = $result->loadedoutdated;
486 $this->assertSame($statusMock, $loadedResult);
487 }
488
489 /**
490 * @test
491 */
492 public function getSecurityStatusOfExtensionsReturnsOkForExistingExtensionIfNoOutdatedExtensionExists() {
493 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
494 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
495 $mockTerObject
496 ->expects($this->any())
497 ->method('getVersion')
498 ->will($this->returnValue('1.0.6'));
499 $mockTerObject
500 ->expects($this->atLeastOnce())
501 ->method('getReviewState')
502 ->will($this->returnValue(0));
503 $mockExtensionList = array(
504 'enetcache' => array(
505 'terObject' => $mockTerObject
506 ),
507 );
508 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
509 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
510 $mockListUtility
511 ->expects($this->once())
512 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
513 ->will($this->returnValue($mockExtensionList));
514
515 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
516 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
517 $mockReport->_set('objectManager', $this->mockObjectManager);
518 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
519 $this->mockObjectManager
520 ->expects($this->at(3))
521 ->method('get')
522 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::OK)
523 ->will($this->returnValue($statusMock));
524 $mockReport->_set('listUtility', $mockListUtility);
525 $mockReport->_set('languageService', $this->mockLanguageService);
526
527 $result = $mockReport->_call('getSecurityStatusOfExtensions');
528 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
529 $loadedResult = $result->existingoutdated;
530 $this->assertSame($statusMock, $loadedResult);
531 }
532
533 /**
534 * @test
535 */
536 public function getSecurityStatusOfExtensionsReturnsErrorForExistingExtensionIfOutdatedExtensionExists() {
537 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
538 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
539 $mockTerObject
540 ->expects($this->any())
541 ->method('getVersion')
542 ->will($this->returnValue('1.0.6'));
543 $mockTerObject
544 ->expects($this->atLeastOnce())
545 ->method('getReviewState')
546 ->will($this->returnValue(-2));
547 $mockExtensionList = array(
548 'enetcache' => array(
549 'terObject' => $mockTerObject
550 ),
551 );
552 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
553 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
554 $mockListUtility
555 ->expects($this->once())
556 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
557 ->will($this->returnValue($mockExtensionList));
558
559 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
560 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
561 $mockReport->_set('objectManager', $this->mockObjectManager);
562 $statusMock = $this->getMock('TYPO3\\CMS\\Reports\\Status', array(), array(), '', FALSE);
563 $this->mockObjectManager
564 ->expects($this->at(3))
565 ->method('get')
566 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), \TYPO3\CMS\Reports\Status::WARNING)
567 ->will($this->returnValue($statusMock));
568 $mockReport->_set('listUtility', $mockListUtility);
569 $mockReport->_set('languageService', $this->mockLanguageService);
570
571 $result = $mockReport->_call('getSecurityStatusOfExtensions');
572 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
573 $loadedResult = $result->existingoutdated;
574 $this->assertSame($statusMock, $loadedResult);
575 }
576 }