[!!!][TASK] Remove deprecated `TYPO3/CMS/Backend/Storage`
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / UnitDeprecated / Service / CoreVersionServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\UnitDeprecated\Service;
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 Prophecy\Argument;
18 use TYPO3\CMS\Core\Http\JsonResponse;
19 use TYPO3\CMS\Core\Http\RequestFactory;
20 use TYPO3\CMS\Core\Registry;
21 use TYPO3\CMS\Core\Utility\GeneralUtility;
22 use TYPO3\CMS\Install\Service\CoreVersionService;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24
25 /**
26 * Test case
27 */
28 class CoreVersionServiceTest extends UnitTestCase
29 {
30 /**
31 * @var bool Reset singletons created by subject
32 */
33 protected $resetSingletonInstances = true;
34
35 /**
36 * @test
37 */
38 public function updateVersionMatrixRemovesOldReleasesFromMatrix(): void
39 {
40 $this->setUpApiResponse([
41 '7' => [],
42 '6.2' => []
43 ]);
44 /** @var $instance CoreVersionService|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
45 $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
46 $registry = $this->createMock(Registry::class);
47 $registry
48 ->expects($this->once())
49 ->method('set')
50 ->with('TYPO3.CMS.Install', 'coreVersionMatrix', $this->logicalNot($this->arrayHasKey('6.2')));
51 $instance->expects($this->once())->method('getInstalledVersion')->will($this->returnValue('7.6.25'));
52 $instance->_set('registry', $registry);
53 $instance->updateVersionMatrix();
54 }
55
56 public function setUpApiResponse(array $responseData)
57 {
58 $response = new JsonResponse($responseData);
59 $requestFactory = $this->prophesize(RequestFactory::class);
60 $requestFactory->request('https://get.typo3.org/json', Argument::cetera())->willReturn($response);
61 GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal());
62 }
63 }