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