2 declare(strict_types = 1);
27 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
52 protected function setUp()
54 $this->mockObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)->getMock();
56 $this->mockRepositoryRepository = $this->getMockBuilder(RepositoryRepository::class)
57 ->setConstructorArgs([$this->mockObjectManager])
59 $this->mockLanguageService = $this->createMock(LanguageService::class);
67 $reportMock = $this->createMock(ExtensionStatus::class);
68 $this->assertInstanceOf(StatusProviderInterface::class, $reportMock);
76 $report = $this->getMockBuilder(ExtensionStatus::class)
77 ->setMethods([
'getSecurityStatusOfExtensions',
'getMainRepositoryStatus'])
78 ->disableOriginalConstructor()
80 $this->assertInternalType(
'array', $report->getStatus());
88 $report = $this->getMockBuilder(ExtensionStatus::class)
89 ->setMethods([
'getSecurityStatusOfExtensions',
'getMainRepositoryStatus'])
90 ->disableOriginalConstructor()
92 $this->assertSame(5, \count($report->getStatus()));
100 $statusObject = $this->getMockBuilder(Status::class)
101 ->setConstructorArgs([
'title',
'value'])
104 $report = $this->getMockBuilder(ExtensionStatus::class)
105 ->setMethods([
'getSecurityStatusOfExtensions',
'getMainRepositoryStatus'])
106 ->disableOriginalConstructor()
108 $report->expects($this->any())->method(
'getMainRepositoryStatus')->will($this->returnValue($statusObject));
109 $resultStatuses = $report->getStatus();
110 foreach ($resultStatuses as $status) {
112 $this->assertInstanceOf(Status::class, $status);
123 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
125 ->expects($this->any())
126 ->method(
'getVersion')
127 ->will($this->returnValue(
'1.0.6'));
129 ->expects($this->atLeastOnce())
130 ->method(
'getReviewState')
131 ->will($this->returnValue(0));
132 $mockExtensionList = [
135 'terObject' => $mockTerObject
139 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
141 ->expects($this->once())
142 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
143 ->will($this->returnValue($mockExtensionList));
146 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'getMainRepositoryStatus'], [],
'',
false);
147 $mockReport->_set(
'objectManager', $this->mockObjectManager);
148 $mockReport->_set(
'listUtility', $mockListUtility);
149 $mockReport->_set(
'languageService', $this->mockLanguageService);
151 ->expects($this->once())
152 ->method(
'getMainRepositoryStatus')
153 ->will($this->returnValue(
'foo'));
155 $result = $mockReport->getStatus();
156 $this->assertSame(
'foo', $result[
'mainRepositoryStatus']);
164 $this->mockRepositoryRepository
165 ->expects($this->once())
166 ->method(
'findOneTypo3OrgRepository')
167 ->will($this->returnValue(
null));
170 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
171 $mockReport->_set(
'objectManager', $this->mockObjectManager);
172 $statusMock = $this->createMock(Status::class);
173 $this->mockObjectManager
174 ->expects($this->once())
176 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::ERROR)
177 ->will($this->returnValue($statusMock));
178 $mockReport->_set(
'repositoryRepository', $this->mockRepositoryRepository);
179 $mockReport->_set(
'languageService', $this->mockLanguageService);
181 $result = $mockReport->_call(
'getMainRepositoryStatus');
182 $this->assertSame($statusMock, $result);
191 $mockRepository = $this->getMockBuilder(Repository::class)->getMock();
193 ->expects($this->once())
194 ->method(
'getLastUpdate')
195 ->will($this->returnValue(
new \DateTime(
'-8 days')));
197 $this->mockRepositoryRepository
198 ->expects($this->once())
199 ->method(
'findOneTypo3OrgRepository')
200 ->will($this->returnValue($mockRepository));
203 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
204 $mockReport->_set(
'objectManager', $this->mockObjectManager);
205 $statusMock = $this->createMock(Status::class);
206 $this->mockObjectManager
207 ->expects($this->once())
209 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::NOTICE)
210 ->will($this->returnValue($statusMock));
211 $mockReport->_set(
'repositoryRepository', $this->mockRepositoryRepository);
212 $mockReport->_set(
'languageService', $this->mockLanguageService);
215 $result = $mockReport->_call(
'getMainRepositoryStatus');
216 $this->assertSame($statusMock, $result);
225 $mockRepository = $this->getMockBuilder(Repository::class)->getMock();
227 ->expects($this->once())
228 ->method(
'getLastUpdate')
229 ->will($this->returnValue(
new \DateTime(
'-6 days')));
231 $this->mockRepositoryRepository
232 ->expects($this->once())
233 ->method(
'findOneTypo3OrgRepository')
234 ->will($this->returnValue($mockRepository));
237 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
238 $mockReport->_set(
'objectManager', $this->mockObjectManager);
239 $statusMock = $this->createMock(Status::class);
240 $this->mockObjectManager
241 ->expects($this->once())
243 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::OK)
244 ->will($this->returnValue($statusMock));
245 $mockReport->_set(
'repositoryRepository', $this->mockRepositoryRepository);
246 $mockReport->_set(
'languageService', $this->mockLanguageService);
249 $result = $mockReport->_call(
'getMainRepositoryStatus');
250 $this->assertSame($statusMock, $result);
259 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
261 ->expects($this->any())
262 ->method(
'getVersion')
263 ->will($this->returnValue(
'1.0.6'));
265 ->expects($this->atLeastOnce())
266 ->method(
'getReviewState')
267 ->will($this->returnValue(0));
268 $mockExtensionList = [
271 'terObject' => $mockTerObject
275 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
277 ->expects($this->once())
278 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
279 ->will($this->returnValue($mockExtensionList));
282 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
283 $mockReport->_set(
'objectManager', $this->mockObjectManager);
284 $statusMock = $this->createMock(Status::class);
285 $this->mockObjectManager
286 ->expects($this->at(0))
288 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::OK)
289 ->will($this->returnValue($statusMock));
290 $mockReport->_set(
'listUtility', $mockListUtility);
291 $mockReport->_set(
'languageService', $this->mockLanguageService);
293 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
295 $loadedResult = $result->loaded;
296 $this->assertSame($statusMock, $loadedResult);
305 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
307 ->expects($this->any())
308 ->method(
'getVersion')
309 ->will($this->returnValue(
'1.0.6'));
311 ->expects($this->atLeastOnce())
312 ->method(
'getReviewState')
313 ->will($this->returnValue(-1));
314 $mockExtensionList = [
317 'terObject' => $mockTerObject
321 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
323 ->expects($this->once())
324 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
325 ->will($this->returnValue($mockExtensionList));
328 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
329 $mockReport->_set(
'objectManager', $this->mockObjectManager);
330 $statusMock = $this->createMock(Status::class);
331 $this->mockObjectManager
332 ->expects($this->at(0))
334 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::ERROR)
335 ->will($this->returnValue($statusMock));
336 $mockReport->_set(
'listUtility', $mockListUtility);
337 $mockReport->_set(
'languageService', $this->mockLanguageService);
339 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
341 $loadedResult = $result->loaded;
342 $this->assertSame($statusMock, $loadedResult);
351 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
353 ->expects($this->any())
354 ->method(
'getVersion')
355 ->will($this->returnValue(
'1.0.6'));
357 ->expects($this->atLeastOnce())
358 ->method(
'getReviewState')
359 ->will($this->returnValue(0));
360 $mockExtensionList = [
362 'terObject' => $mockTerObject
366 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
368 ->expects($this->once())
369 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
370 ->will($this->returnValue($mockExtensionList));
373 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
374 $mockReport->_set(
'objectManager', $this->mockObjectManager);
375 $statusMock = $this->createMock(Status::class);
376 $this->mockObjectManager
377 ->expects($this->at(1))
379 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::OK)
380 ->will($this->returnValue($statusMock));
381 $mockReport->_set(
'listUtility', $mockListUtility);
382 $mockReport->_set(
'languageService', $this->mockLanguageService);
384 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
386 $loadedResult = $result->existing;
387 $this->assertSame($statusMock, $loadedResult);
396 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
398 ->expects($this->any())
399 ->method(
'getVersion')
400 ->will($this->returnValue(
'1.0.6'));
402 ->expects($this->atLeastOnce())
403 ->method(
'getReviewState')
404 ->will($this->returnValue(-1));
405 $mockExtensionList = [
407 'terObject' => $mockTerObject
411 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
413 ->expects($this->once())
414 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
415 ->will($this->returnValue($mockExtensionList));
418 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
419 $mockReport->_set(
'objectManager', $this->mockObjectManager);
420 $statusMock = $this->createMock(Status::class);
421 $this->mockObjectManager
422 ->expects($this->at(1))
424 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::WARNING)
425 ->will($this->returnValue($statusMock));
426 $mockReport->_set(
'listUtility', $mockListUtility);
427 $mockReport->_set(
'languageService', $this->mockLanguageService);
429 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
431 $loadedResult = $result->existing;
432 $this->assertSame($statusMock, $loadedResult);
441 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
443 ->expects($this->any())
444 ->method(
'getVersion')
445 ->will($this->returnValue(
'1.0.6'));
447 ->expects($this->atLeastOnce())
448 ->method(
'getReviewState')
449 ->will($this->returnValue(0));
450 $mockExtensionList = [
453 'terObject' => $mockTerObject
457 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
459 ->expects($this->once())
460 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
461 ->will($this->returnValue($mockExtensionList));
464 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
465 $mockReport->_set(
'objectManager', $this->mockObjectManager);
466 $statusMock = $this->createMock(Status::class);
467 $this->mockObjectManager
468 ->expects($this->at(2))
470 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::OK)
471 ->will($this->returnValue($statusMock));
472 $mockReport->_set(
'listUtility', $mockListUtility);
473 $mockReport->_set(
'languageService', $this->mockLanguageService);
475 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
477 $loadedResult = $result->loadedoutdated;
478 $this->assertSame($statusMock, $loadedResult);
487 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
489 ->expects($this->any())
490 ->method(
'getVersion')
491 ->will($this->returnValue(
'1.0.6'));
493 ->expects($this->atLeastOnce())
494 ->method(
'getReviewState')
495 ->will($this->returnValue(-2));
496 $mockExtensionList = [
499 'terObject' => $mockTerObject
503 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
505 ->expects($this->once())
506 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
507 ->will($this->returnValue($mockExtensionList));
510 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
511 $mockReport->_set(
'objectManager', $this->mockObjectManager);
512 $statusMock = $this->createMock(Status::class);
513 $this->mockObjectManager
514 ->expects($this->at(2))
516 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::WARNING)
517 ->will($this->returnValue($statusMock));
518 $mockReport->_set(
'listUtility', $mockListUtility);
519 $mockReport->_set(
'languageService', $this->mockLanguageService);
521 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
523 $loadedResult = $result->loadedoutdated;
524 $this->assertSame($statusMock, $loadedResult);
533 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
535 ->expects($this->any())
536 ->method(
'getVersion')
537 ->will($this->returnValue(
'1.0.6'));
539 ->expects($this->atLeastOnce())
540 ->method(
'getReviewState')
541 ->will($this->returnValue(0));
542 $mockExtensionList = [
544 'terObject' => $mockTerObject
548 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
550 ->expects($this->once())
551 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
552 ->will($this->returnValue($mockExtensionList));
555 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
556 $mockReport->_set(
'objectManager', $this->mockObjectManager);
557 $statusMock = $this->createMock(Status::class);
558 $this->mockObjectManager
559 ->expects($this->at(3))
561 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::OK)
562 ->will($this->returnValue($statusMock));
563 $mockReport->_set(
'listUtility', $mockListUtility);
564 $mockReport->_set(
'languageService', $this->mockLanguageService);
566 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
568 $loadedResult = $result->existingoutdated;
569 $this->assertSame($statusMock, $loadedResult);
578 $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
580 ->expects($this->any())
581 ->method(
'getVersion')
582 ->will($this->returnValue(
'1.0.6'));
584 ->expects($this->atLeastOnce())
585 ->method(
'getReviewState')
586 ->will($this->returnValue(-2));
587 $mockExtensionList = [
589 'terObject' => $mockTerObject
593 $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
595 ->expects($this->once())
596 ->method(
'getAvailableAndInstalledExtensionsWithAdditionalInformation')
597 ->will($this->returnValue($mockExtensionList));
600 $mockReport = $this->getAccessibleMock(ExtensionStatus::class, [
'dummy'], [],
'',
false);
601 $mockReport->_set(
'objectManager', $this->mockObjectManager);
602 $statusMock = $this->createMock(Status::class);
603 $this->mockObjectManager
604 ->expects($this->at(3))
606 ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(),
Status::WARNING)
607 ->will($this->returnValue($statusMock));
608 $mockReport->_set(
'listUtility', $mockListUtility);
609 $mockReport->_set(
'languageService', $this->mockLanguageService);
611 $result = $mockReport->_call(
'getSecurityStatusOfExtensions');
613 $loadedResult = $result->existingoutdated;
614 $this->assertSame($statusMock, $loadedResult);