42 public function setUp() {
43 $this->mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
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);
53 $reportMock = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array(), array(),
'', FALSE);
54 $this->assertInstanceOf(
'TYPO3\\CMS\\Reports\\StatusProviderInterface', $reportMock);
61 $report = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array(
'getSecurityStatusOfExtensions',
'getMainRepositoryStatus'), array(),
'', FALSE);
62 $this->assertInternalType(
'array', $report->getStatus());
69 $report = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Report\\ExtensionStatus', array(
'getSecurityStatusOfExtensions',
'getMainRepositoryStatus'), array(),
'', FALSE);
70 $this->assertSame(5, count($report->getStatus()));
76 public function getStatusReturnArrayContainsInstancesOfReportsStatusStatus() {
77 $statusObject = $this->getMock(
'TYPO3\\CMS\\Reports\\Status', array(), array(
'title',
'value'));
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) {
84 $this->assertInstanceOf(
'TYPO3\\CMS\\Reports\\Status', $status);
92 public function getStatusCallsGetMainRepositoryStatusForMainRepositoryStatusResult() {
94 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
96 ->expects($this->any())
97 ->method(
'getVersion')
98 ->will($this->returnValue(
'1.0.6'));
100 ->expects($this->atLeastOnce())
101 ->method(
'getReviewState')
102 ->will($this->returnValue(0));
103 $mockExtensionList = array(
104 'enetcache' => array(
106 'terObject' => $mockTerObject
110 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
112 ->expects($this->once())
113 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
114 ->will($this->returnValue($mockExtensionList));
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);
122 ->expects($this->once())
123 ->method(
'getMainRepositoryStatus')
124 ->will($this->returnValue(
'foo'));
126 $result = $mockReport->getStatus();
127 $this->assertSame(
'foo',
$result[
'mainRepositoryStatus']);
133 public function getMainRepositoryStatusReturnsErrorStatusIfRepositoryIsNotFound() {
134 $this->mockRepositoryRepository
135 ->expects($this->once())
136 ->method(
'findOneTypo3OrgRepository')
137 ->will($this->returnValue(NULL));
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())
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);
151 $result = $mockReport->_call(
'getMainRepositoryStatus');
152 $this->assertSame($statusMock,
$result);
158 public function getMainRepositoryStatusReturnsNoticeIfRepositoryUpdateIsLongerThanSevenDaysAgo() {
160 $mockRepository = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
162 ->expects($this->once())
163 ->method(
'getLastUpdate')
164 ->will($this->returnValue(
new \DateTime(
'-8 days')));
166 $this->mockRepositoryRepository
167 ->expects($this->once())
168 ->method(
'findOneTypo3OrgRepository')
169 ->will($this->returnValue($mockRepository));
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())
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);
184 $result = $mockReport->_call(
'getMainRepositoryStatus');
185 $this->assertSame($statusMock,
$result);
191 public function getMainRepositoryStatusReturnsOkIfUpdatedLessThanSevenDaysAgo() {
193 $mockRepository = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Repository');
195 ->expects($this->once())
196 ->method(
'getLastUpdate')
197 ->will($this->returnValue(
new \DateTime(
'-6 days')));
199 $this->mockRepositoryRepository
200 ->expects($this->once())
201 ->method(
'findOneTypo3OrgRepository')
202 ->will($this->returnValue($mockRepository));
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())
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);
217 $result = $mockReport->_call(
'getMainRepositoryStatus');
218 $this->assertSame($statusMock,
$result);
224 public function getSecurityStatusOfExtensionsReturnsOkForLoadedExtensionIfNoInsecureExtensionIsLoaded() {
226 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
228 ->expects($this->any())
229 ->method(
'getVersion')
230 ->will($this->returnValue(
'1.0.6'));
232 ->expects($this->atLeastOnce())
233 ->method(
'getReviewState')
234 ->will($this->returnValue(0));
235 $mockExtensionList = array(
236 'enetcache' => array(
238 'terObject' => $mockTerObject
242 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
244 ->expects($this->once())
245 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
246 ->will($this->returnValue($mockExtensionList));
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))
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);
260 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
262 $loadedResult =
$result->loaded;
263 $this->assertSame($statusMock, $loadedResult);
269 public function getSecurityStatusOfExtensionsReturnsErrorForLoadedExtensionIfInsecureExtensionIsLoaded() {
271 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
273 ->expects($this->any())
274 ->method(
'getVersion')
275 ->will($this->returnValue(
'1.0.6'));
277 ->expects($this->atLeastOnce())
278 ->method(
'getReviewState')
279 ->will($this->returnValue(-1));
280 $mockExtensionList = array(
281 'enetcache' => array(
283 'terObject' => $mockTerObject
287 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
289 ->expects($this->once())
290 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
291 ->will($this->returnValue($mockExtensionList));
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))
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);
305 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
307 $loadedResult =
$result->loaded;
308 $this->assertSame($statusMock, $loadedResult);
314 public function getSecurityStatusOfExtensionsReturnsOkForExistingExtensionIfNoInsecureExtensionExists() {
316 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
318 ->expects($this->any())
319 ->method(
'getVersion')
320 ->will($this->returnValue(
'1.0.6'));
322 ->expects($this->atLeastOnce())
323 ->method(
'getReviewState')
324 ->will($this->returnValue(0));
325 $mockExtensionList = array(
326 'enetcache' => array(
327 'terObject' => $mockTerObject
331 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
333 ->expects($this->once())
334 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
335 ->will($this->returnValue($mockExtensionList));
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))
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);
349 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
351 $loadedResult =
$result->existing;
352 $this->assertSame($statusMock, $loadedResult);
358 public function getSecurityStatusOfExtensionsReturnsErrorForExistingExtensionIfInsecureExtensionExists() {
360 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
362 ->expects($this->any())
363 ->method(
'getVersion')
364 ->will($this->returnValue(
'1.0.6'));
366 ->expects($this->atLeastOnce())
367 ->method(
'getReviewState')
368 ->will($this->returnValue(-1));
369 $mockExtensionList = array(
370 'enetcache' => array(
371 'terObject' => $mockTerObject
375 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
377 ->expects($this->once())
378 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
379 ->will($this->returnValue($mockExtensionList));
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))
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);
393 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
395 $loadedResult =
$result->existing;
396 $this->assertSame($statusMock, $loadedResult);
402 public function getSecurityStatusOfExtensionsReturnsOkForLoadedExtensionIfNoOutdatedExtensionIsLoaded() {
404 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
406 ->expects($this->any())
407 ->method(
'getVersion')
408 ->will($this->returnValue(
'1.0.6'));
410 ->expects($this->atLeastOnce())
411 ->method(
'getReviewState')
412 ->will($this->returnValue(0));
413 $mockExtensionList = array(
414 'enetcache' => array(
416 'terObject' => $mockTerObject
420 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
422 ->expects($this->once())
423 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
424 ->will($this->returnValue($mockExtensionList));
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))
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);
438 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
440 $loadedResult =
$result->loadedoutdated;
441 $this->assertSame($statusMock, $loadedResult);
447 public function getSecurityStatusOfExtensionsReturnsErrorForLoadedExtensionIfOutdatedExtensionIsLoaded() {
449 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
451 ->expects($this->any())
452 ->method(
'getVersion')
453 ->will($this->returnValue(
'1.0.6'));
455 ->expects($this->atLeastOnce())
456 ->method(
'getReviewState')
457 ->will($this->returnValue(-2));
458 $mockExtensionList = array(
459 'enetcache' => array(
461 'terObject' => $mockTerObject
465 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
467 ->expects($this->once())
468 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
469 ->will($this->returnValue($mockExtensionList));
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))
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);
483 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
485 $loadedResult =
$result->loadedoutdated;
486 $this->assertSame($statusMock, $loadedResult);
492 public function getSecurityStatusOfExtensionsReturnsOkForExistingExtensionIfNoOutdatedExtensionExists() {
494 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
496 ->expects($this->any())
497 ->method(
'getVersion')
498 ->will($this->returnValue(
'1.0.6'));
500 ->expects($this->atLeastOnce())
501 ->method(
'getReviewState')
502 ->will($this->returnValue(0));
503 $mockExtensionList = array(
504 'enetcache' => array(
505 'terObject' => $mockTerObject
509 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
511 ->expects($this->once())
512 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
513 ->will($this->returnValue($mockExtensionList));
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))
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);
527 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
529 $loadedResult =
$result->existingoutdated;
530 $this->assertSame($statusMock, $loadedResult);
536 public function getSecurityStatusOfExtensionsReturnsErrorForExistingExtensionIfOutdatedExtensionExists() {
538 $mockTerObject = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension');
540 ->expects($this->any())
541 ->method(
'getVersion')
542 ->will($this->returnValue(
'1.0.6'));
544 ->expects($this->atLeastOnce())
545 ->method(
'getReviewState')
546 ->will($this->returnValue(-2));
547 $mockExtensionList = array(
548 'enetcache' => array(
549 'terObject' => $mockTerObject
553 $mockListUtility = $this->getMock(
'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility');
555 ->expects($this->once())
556 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
557 ->will($this->returnValue($mockExtensionList));
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))
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);
571 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
573 $loadedResult =
$result->existingoutdated;
574 $this->assertSame($statusMock, $loadedResult);
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
getStatusReturnArrayContainsFiveEntries()
$mockRepositoryRepository
extensionStatusImplementsStatusProviderInterface()