[FEATURE] Use new REST API for update checks
[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
24 /**
25 * Test case
26 */
27 class CoreVersionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
28 {
29 /**
30 * @test
31 */
32 public function updateVersionMatrixRemovesOldReleasesFromMatrix(): void
33 {
34 $this->setUpApiResponse([
35 '7' => [],
36 '6.2' => []
37 ]);
38 /** @var $instance CoreVersionService|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
39 $instance = $this->getAccessibleMock(CoreVersionService::class, ['getInstalledVersion']);
40 $registry = $this->createMock(Registry::class);
41 $registry
42 ->expects($this->once())
43 ->method('set')
44 ->with('TYPO3.CMS.Install', 'coreVersionMatrix', $this->logicalNot($this->arrayHasKey('6.2')));
45 $instance->expects($this->once())->method('getInstalledVersion')->will($this->returnValue('7.6.25'));
46 $instance->_set('registry', $registry);
47 $instance->updateVersionMatrix();
48 }
49
50 public function setUpApiResponse(array $responseData)
51 {
52 $response = new JsonResponse($responseData);
53 $requestFactory = $this->prophesize(RequestFactory::class);
54 $requestFactory->request('https://get.typo3.org/json', Argument::cetera())->willReturn($response);
55 GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal());
56 }
57 }