912ed28d3712b3eaeb68948a508894284c604381
[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 * Copyright notice
6 *
7 * (c) 2010-2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Extensionmanager\Report;
28
29 /**
30 * Test case
31 *
32 * @author Christian Kuhn <lolli@schwarzbu.ch>
33 */
34 class ExtensionStatusTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
35
36 /**
37 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
38 */
39 protected $mockObjectManager;
40
41 /**
42 * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
43 */
44 protected $mockRepositoryRepository;
45
46 public function setUp() {
47 $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
48 /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository|\PHPUnit_Framework_MockObject_MockObject */
49 $this->mockRepositoryRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\RepositoryRepository', array(), array($this->mockObjectManager));
50 }
51
52 /**
53 * @test
54 */
55 public function extensionStatusImplementsStatusProviderInterface() {
56 $reportMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array(), array(), '', FALSE);
57 $this->assertInstanceOf('TYPO3\\CMS\\Reports\\StatusProviderInterface', $reportMock);
58 }
59
60 /**
61 * @test
62 */
63 public function getStatusReturnsArray() {
64 $report = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('getSecurityStatusOfExtensions', 'getMainRepositoryStatus'), array(), '', FALSE);
65 $this->assertInternalType('array', $report->getStatus());
66 }
67
68 /**
69 * @test
70 */
71 public function getStatusReturnArrayContainsFiveEntries() {
72 $report = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('getSecurityStatusOfExtensions', 'getMainRepositoryStatus'), array(), '', FALSE);
73 $this->assertSame(5, count($report->getStatus()));
74 }
75
76 /**
77 * @test
78 */
79 public function getStatusReturnArrayContainsInstancesOfReportsStatusStatus() {
80 $statusObject = $this->objectManager->get('TYPO3\\CMS\\Reports\\Status', 'title', 'value');
81 /** @var \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus $report */
82 $report = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('getSecurityStatusOfExtensions', 'getMainRepositoryStatus'), array(), '', FALSE);
83 $report->expects($this->any())->method('getMainRepositoryStatus')->will($this->returnValue($statusObject));
84 $resultStatuses = $report->getStatus();
85 foreach($resultStatuses as $status) {
86 if ($status) {
87 $this->assertInstanceOf('TYPO3\\CMS\\Reports\\Status', $status);
88 }
89 }
90 }
91
92 /**
93 * @test
94 */
95 public function getStatusCallsGetMainRepositoryStatusForMainRepositoryStatusResult() {
96 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
97 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
98 $mockTerObject
99 ->expects($this->any())
100 ->method('getVersion')
101 ->will($this->returnValue('1.0.6'));
102 $mockTerObject
103 ->expects($this->atLeastOnce())
104 ->method('getReviewState')
105 ->will($this->returnValue(0));
106 $mockExtensionList = array(
107 'enetcache' => array(
108 'installed' => TRUE,
109 'terObject' => $mockTerObject
110 ),
111 );
112 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
113 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
114 $mockListUtility
115 ->expects($this->once())
116 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
117 ->will($this->returnValue($mockExtensionList));
118 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject */
119 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('getMainRepositoryStatus'), array(), '', FALSE);
120 $mockReport->_set('objectManager', $this->mockObjectManager);
121 $mockReport->_set('listUtility', $mockListUtility);
122 $mockReport
123 ->expects($this->once())
124 ->method('getMainRepositoryStatus')
125 ->will($this->returnValue('foo'));
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->objectManager);
142 $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
143
144 /** @var $result \TYPO3\CMS\Reports\Status */
145 $result = $mockReport->_call('getMainRepositoryStatus');
146 $this->assertSame(\TYPO3\CMS\Reports\Status::ERROR, $result->getSeverity());
147 }
148
149 /**
150 * @test
151 */
152 public function getMainRepositoryStatusReturnsNoticeIfRepositoryUpdateIsLongerThanSevenDaysAgo() {
153 /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository|\PHPUnit_Framework_MockObject_MockObject */
154 $mockRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
155 $mockRepository
156 ->expects($this->once())
157 ->method('getLastUpdate')
158 ->will($this->returnValue(new \DateTime('-8 days')));
159
160 $this->mockRepositoryRepository
161 ->expects($this->once())
162 ->method('findOneTypo3OrgRepository')
163 ->will($this->returnValue($mockRepository));
164
165 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
166 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
167 $mockReport->_set('objectManager', $this->objectManager);
168 $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
169
170 /** @var $result \TYPO3\CMS\Reports\Status */
171 $result = $mockReport->_call('getMainRepositoryStatus');
172 $this->assertSame(\TYPO3\CMS\Reports\Status::NOTICE, $result->getSeverity());
173 }
174
175 /**
176 * @test
177 */
178 public function getMainRepositoryStatusReturnsOkIfUpdatedLessThanSevenDaysAgo() {
179 /** @var $mockRepositoryRepository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository|\PHPUnit_Framework_MockObject_MockObject */
180 $mockRepository = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
181 $mockRepository
182 ->expects($this->once())
183 ->method('getLastUpdate')
184 ->will($this->returnValue(new \DateTime('-6 days')));
185
186 $this->mockRepositoryRepository
187 ->expects($this->once())
188 ->method('findOneTypo3OrgRepository')
189 ->will($this->returnValue($mockRepository));
190
191 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
192 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
193 $mockReport->_set('objectManager', $this->objectManager);
194 $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
195
196 /** @var $result \TYPO3\CMS\Reports\Status */
197 $result = $mockReport->_call('getMainRepositoryStatus');
198 $this->assertSame(\TYPO3\CMS\Reports\Status::OK, $result->getSeverity());
199 }
200
201 /**
202 * @test
203 */
204 public function getSecurityStatusOfExtensionsReturnsOkForLoadedExtensionIfNoInsecureExtensionIsLoaded() {
205 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
206 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
207 $mockTerObject
208 ->expects($this->any())
209 ->method('getVersion')
210 ->will($this->returnValue('1.0.6'));
211 $mockTerObject
212 ->expects($this->atLeastOnce())
213 ->method('getReviewState')
214 ->will($this->returnValue(0));
215 $mockExtensionList = array(
216 'enetcache' => array(
217 'installed' => TRUE,
218 'terObject' => $mockTerObject
219 ),
220 );
221 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
222 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
223 $mockListUtility
224 ->expects($this->once())
225 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
226 ->will($this->returnValue($mockExtensionList));
227
228 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
229 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
230 $mockReport->_set('objectManager', $this->objectManager);
231 $mockReport->_set('listUtility', $mockListUtility);
232
233 $result = $mockReport->_call('getSecurityStatusOfExtensions');
234 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
235 $loadedResult = $result->loaded;
236 $this->assertSame(\TYPO3\CMS\Reports\Status::OK, $loadedResult->getSeverity());
237 }
238
239 /**
240 * @test
241 */
242 public function getSecurityStatusOfExtensionsReturnsErrorForLoadedExtensionIfInsecureExtensionIsLoaded() {
243 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
244 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
245 $mockTerObject
246 ->expects($this->any())
247 ->method('getVersion')
248 ->will($this->returnValue('1.0.6'));
249 $mockTerObject
250 ->expects($this->atLeastOnce())
251 ->method('getReviewState')
252 ->will($this->returnValue(-1));
253 $mockExtensionList = array(
254 'enetcache' => array(
255 'installed' => TRUE,
256 'terObject' => $mockTerObject
257 ),
258 );
259 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
260 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
261 $mockListUtility
262 ->expects($this->once())
263 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
264 ->will($this->returnValue($mockExtensionList));
265
266 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
267 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
268 $mockReport->_set('objectManager', $this->objectManager);
269 $mockReport->_set('listUtility', $mockListUtility);
270
271 $result = $mockReport->_call('getSecurityStatusOfExtensions');
272 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
273 $loadedResult = $result->loaded;
274 $this->assertSame(\TYPO3\CMS\Reports\Status::ERROR, $loadedResult->getSeverity());
275 }
276
277 /**
278 * @test
279 */
280 public function getSecurityStatusOfExtensionsReturnsOkForExistingExtensionIfNoInsecureExtensionExists() {
281 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
282 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
283 $mockTerObject
284 ->expects($this->any())
285 ->method('getVersion')
286 ->will($this->returnValue('1.0.6'));
287 $mockTerObject
288 ->expects($this->atLeastOnce())
289 ->method('getReviewState')
290 ->will($this->returnValue(0));
291 $mockExtensionList = array(
292 'enetcache' => array(
293 'terObject' => $mockTerObject
294 ),
295 );
296 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
297 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
298 $mockListUtility
299 ->expects($this->once())
300 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
301 ->will($this->returnValue($mockExtensionList));
302
303 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
304 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
305 $mockReport->_set('objectManager', $this->objectManager);
306 $mockReport->_set('listUtility', $mockListUtility);
307
308 $result = $mockReport->_call('getSecurityStatusOfExtensions');
309 /** @var $existingResult \TYPO3\CMS\Reports\Status */
310 $existingResult = $result->existing;
311 $this->assertSame(\TYPO3\CMS\Reports\Status::OK, $existingResult->getSeverity());
312 }
313
314 /**
315 * @test
316 */
317 public function getSecurityStatusOfExtensionsReturnsErrorForExistingExtensionIfInsecureExtensionExists() {
318 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
319 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
320 $mockTerObject
321 ->expects($this->any())
322 ->method('getVersion')
323 ->will($this->returnValue('1.0.6'));
324 $mockTerObject
325 ->expects($this->atLeastOnce())
326 ->method('getReviewState')
327 ->will($this->returnValue(-1));
328 $mockExtensionList = array(
329 'enetcache' => array(
330 'terObject' => $mockTerObject
331 ),
332 );
333 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
334 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
335 $mockListUtility
336 ->expects($this->once())
337 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
338 ->will($this->returnValue($mockExtensionList));
339
340 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
341 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
342 $mockReport->_set('objectManager', $this->objectManager);
343 $mockReport->_set('listUtility', $mockListUtility);
344
345 $result = $mockReport->_call('getSecurityStatusOfExtensions');
346 /** @var $existingResult \TYPO3\CMS\Reports\Status */
347 $existingResult = $result->existing;
348 $this->assertSame(\TYPO3\CMS\Reports\Status::WARNING, $existingResult->getSeverity());
349 }
350
351 /**
352 * @test
353 */
354 public function getSecurityStatusOfExtensionsReturnsOkForLoadedExtensionIfNoOutdatedExtensionIsLoaded() {
355 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
356 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
357 $mockTerObject
358 ->expects($this->any())
359 ->method('getVersion')
360 ->will($this->returnValue('1.0.6'));
361 $mockTerObject
362 ->expects($this->atLeastOnce())
363 ->method('getReviewState')
364 ->will($this->returnValue(0));
365 $mockExtensionList = array(
366 'enetcache' => array(
367 'installed' => TRUE,
368 'terObject' => $mockTerObject
369 ),
370 );
371 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
372 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
373 $mockListUtility
374 ->expects($this->once())
375 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
376 ->will($this->returnValue($mockExtensionList));
377
378 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
379 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
380 $mockReport->_set('objectManager', $this->objectManager);
381 $mockReport->_set('listUtility', $mockListUtility);
382
383 $result = $mockReport->_call('getSecurityStatusOfExtensions');
384 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
385 $loadedResult = $result->loadedoutdated;
386 $this->assertSame(\TYPO3\CMS\Reports\Status::OK, $loadedResult->getSeverity());
387 }
388
389 /**
390 * @test
391 */
392 public function getSecurityStatusOfExtensionsReturnsErrorForLoadedExtensionIfOutdatedExtensionIsLoaded() {
393 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
394 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
395 $mockTerObject
396 ->expects($this->any())
397 ->method('getVersion')
398 ->will($this->returnValue('1.0.6'));
399 $mockTerObject
400 ->expects($this->atLeastOnce())
401 ->method('getReviewState')
402 ->will($this->returnValue(-2));
403 $mockExtensionList = array(
404 'enetcache' => array(
405 'installed' => TRUE,
406 'terObject' => $mockTerObject
407 ),
408 );
409 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
410 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
411 $mockListUtility
412 ->expects($this->once())
413 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
414 ->will($this->returnValue($mockExtensionList));
415
416 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
417 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
418 $mockReport->_set('objectManager', $this->objectManager);
419 $mockReport->_set('listUtility', $mockListUtility);
420
421 $result = $mockReport->_call('getSecurityStatusOfExtensions');
422 /** @var $loadedResult \TYPO3\CMS\Reports\Status */
423 $loadedResult = $result->loadedoutdated;
424 $this->assertSame(\TYPO3\CMS\Reports\Status::WARNING, $loadedResult->getSeverity());
425 }
426
427 /**
428 * @test
429 */
430 public function getSecurityStatusOfExtensionsReturnsOkForExistingExtensionIfNoOutdatedExtensionExists() {
431 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
432 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
433 $mockTerObject
434 ->expects($this->any())
435 ->method('getVersion')
436 ->will($this->returnValue('1.0.6'));
437 $mockTerObject
438 ->expects($this->atLeastOnce())
439 ->method('getReviewState')
440 ->will($this->returnValue(0));
441 $mockExtensionList = array(
442 'enetcache' => array(
443 'terObject' => $mockTerObject
444 ),
445 );
446 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
447 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
448 $mockListUtility
449 ->expects($this->once())
450 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
451 ->will($this->returnValue($mockExtensionList));
452
453 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
454 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
455 $mockReport->_set('objectManager', $this->objectManager);
456 $mockReport->_set('listUtility', $mockListUtility);
457
458 $result = $mockReport->_call('getSecurityStatusOfExtensions');
459 /** @var $existingResult \TYPO3\CMS\Reports\Status */
460 $existingResult = $result->existingoutdated;
461 $this->assertSame(\TYPO3\CMS\Reports\Status::OK, $existingResult->getSeverity());
462 }
463
464 /**
465 * @test
466 */
467 public function getSecurityStatusOfExtensionsReturnsErrorForExistingExtensionIfOutdatedExtensionExists() {
468 /** @var $mockTerObject \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|\PHPUnit_Framework_MockObject_MockObject */
469 $mockTerObject = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
470 $mockTerObject
471 ->expects($this->any())
472 ->method('getVersion')
473 ->will($this->returnValue('1.0.6'));
474 $mockTerObject
475 ->expects($this->atLeastOnce())
476 ->method('getReviewState')
477 ->will($this->returnValue(-2));
478 $mockExtensionList = array(
479 'enetcache' => array(
480 'terObject' => $mockTerObject
481 ),
482 );
483 /** @var $mockListUtility \TYPO3\CMS\Extensionmanager\Utility\ListUtility|\PHPUnit_Framework_MockObject_MockObject */
484 $mockListUtility = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
485 $mockListUtility
486 ->expects($this->once())
487 ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
488 ->will($this->returnValue($mockExtensionList));
489
490 /** @var $mockReport \TYPO3\CMS\Extensionmanager\Report\ExtensionStatus|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
491 $mockReport = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array('dummy'), array(), '', FALSE);
492 $mockReport->_set('objectManager', $this->objectManager);
493 $mockReport->_set('listUtility', $mockListUtility);
494
495 $result = $mockReport->_call('getSecurityStatusOfExtensions');
496 /** @var $existingResult \TYPO3\CMS\Reports\Status */
497 $existingResult = $result->existingoutdated;
498 $this->assertSame(\TYPO3\CMS\Reports\Status::WARNING, $existingResult->getSeverity());
499 }
500 }