‪TYPO3CMS  11.5
DownloadControllerTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Prophecy\PhpUnit\ProphecyTrait;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪DownloadControllerTest extends UnitTestCase
32 {
33  use ProphecyTrait;
34 
39  {
40  $dummyExceptionMessage = 'exception message';
41  $dummyException = new ‪ExtensionManagerException($dummyExceptionMessage, 1476108614);
42 
43  $dummyExtensionName = 'dummy_extension';
44  $dummyExtension = new ‪Extension();
45  $dummyExtension->setExtensionKey($dummyExtensionName);
46 
47  $extensionManagementServiceMock = $this->getMockBuilder(ExtensionManagementService::class)->disableOriginalConstructor()->getMock();
48  $extensionManagementServiceMock->method('setDownloadPath')->willThrowException($dummyException);
49 
50  $subject = new ‪DownloadController($this->prophesize(ExtensionRepository::class)->reveal(), $extensionManagementServiceMock);
51 
52  $reflectionClass = new \ReflectionClass($subject);
53  $reflectionMethod = $reflectionClass->getMethod('installFromTer');
54  $reflectionMethod->setAccessible(true);
55 
56  $result = $reflectionMethod->invokeArgs($subject, [$dummyExtension]);
57 
58  $expectedResult = [
59  false,
60  [
61  $dummyExtensionName => [
62  [
63  'code' => 1476108614,
64  'message' => $dummyExceptionMessage,
65  ],
66  ],
67  ],
68  ];
69 
70  self::assertSame($expectedResult, $result);
71  }
72 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Controller
Definition: ActionControllerTest.php:18
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:28
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Controller\DownloadControllerTest\installFromTerReturnsArrayWithBooleanResultAndErrorArrayWhenExtensionManagerExceptionIsThrown
‪installFromTerReturnsArrayWithBooleanResultAndErrorArrayWhenExtensionManagerExceptionIsThrown()
Definition: DownloadControllerTest.php:37
‪TYPO3\CMS\Extensionmanager\Controller\DownloadController
Definition: DownloadController.php:38
‪TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository
Definition: ExtensionRepository.php:34
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:23
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Controller\DownloadControllerTest
Definition: DownloadControllerTest.php:32
‪TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService
Definition: ExtensionManagementService.php:36