‪TYPO3CMS  9.5
UpgradeControllerTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Psr\Http\Message\ServerRequestInterface;
20 use TYPO3\CMS\Core\Package\PackageManager;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪UpgradeControllerTest extends UnitTestCase
29 {
33  public function ‪versionDataProvider(): array
34  {
35  return [
36  ['master', false],
37  ['1.0', false],
38  ['1.10', false],
39  ['2.3.4', false],
40  ['2.3.20', false],
41  ['7.6.x', false],
42  ['10.0', false],
43  ['10.10', false],
44  ['10.10.5', false],
45  ['10.10.husel', true],
46  ['1.2.3.4', true],
47  ['9.8.x.x', true],
48  ['a.b.c', true],
49  ['4.3.x.1', true],
50  ['../../../../../../../etc/passwd', true],
51  ['husel', true],
52  ];
53  }
54 
61  public function ‪versionIsAsserted(string $version, bool $expectsException): void
62  {
63  if ($expectsException) {
64  $this->expectException(\InvalidArgumentException::class);
65  $this->expectExceptionCode(1537209128);
66  }
67  $requestProphecy = $this->prophesize(ServerRequestInterface::class);
68  $requestProphecy->getQueryParams()->willReturn([
69  'install' => [
70  'version' => $version,
71  ],
72  ]);
73 
74  $packageManagerMock = $this->getMockBuilder(PackageManager::class)
75  ->disableOriginalConstructor()
76  ->getMock();
78  $subject = $this->getMockBuilder(UpgradeController::class)
79  ->setConstructorArgs([$packageManagerMock])
80  ->setMethods(['getDocumentationFiles', 'initializeStandaloneView'])
81  ->getMock();
82 
83  $subject->expects($this->any())->method('getDocumentationFiles')->willReturn([
84  'normalFiles' => [],
85  'readFiles' => [],
86  'notAffectedFiles' => [],
87  ]);
88  $subject->expects($this->any())
89  ->method('initializeStandaloneView')
90  ->willReturn($this->prophesize(StandaloneView::class)->reveal());
91  $subject->upgradeDocsGetChangelogForVersionAction($requestProphecy->reveal());
92  }
93 }
‪TYPO3\CMS\Install\Controller\UpgradeController
Definition: UpgradeController.php:76
‪TYPO3\CMS\Install\Tests\Unit\Controller\UpgradeControllerTest\versionIsAsserted
‪versionIsAsserted(string $version, bool $expectsException)
Definition: UpgradeControllerTest.php:61
‪TYPO3\CMS\Install\Tests\Unit\Controller\UpgradeControllerTest\versionDataProvider
‪array versionDataProvider()
Definition: UpgradeControllerTest.php:33
‪TYPO3\CMS\Install\Tests\Unit\Controller\UpgradeControllerTest
Definition: UpgradeControllerTest.php:29
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪TYPO3\CMS\Install\Tests\Unit\Controller
Definition: UpgradeControllerTest.php:4