‪TYPO3CMS  9.5
DownloadControllerTest.php
Go to the documentation of this file.
1 <?php
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 PHPUnit\Framework\MockObject\MockObject;
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪DownloadControllerTest extends UnitTestCase
24 {
29  {
30  $dummyExceptionMessage = 'exception message';
31  $dummyException = new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException($dummyExceptionMessage, 1476108614);
32 
33  $dummyExtensionName = 'dummy_extension';
34  $dummyExtension = $this->getMockBuilder(\‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class)->getMock();
35  $dummyExtension->expects($this->any())->method('getExtensionKey')->will($this->returnValue($dummyExtensionName));
36 
38  $downloadUtilityMock = $this->getMockBuilder(\‪TYPO3\CMS\Extensionmanager\Utility\DownloadUtility::class)->getMock();
39  $downloadUtilityMock->expects($this->any())->method('setDownloadPath')->willThrowException($dummyException);
40 
42  $subject = new \TYPO3\CMS\Extensionmanager\Controller\DownloadController();
43  $subject->injectDownloadUtility($downloadUtilityMock);
44 
45  $reflectionClass = new \ReflectionClass($subject);
46  $reflectionMethod = $reflectionClass->getMethod('installFromTer');
47  $reflectionMethod->setAccessible(true);
48 
49  $result = $reflectionMethod->invokeArgs($subject, [$dummyExtension]);
50 
51  $expectedResult = [
52  false,
53  [
54  $dummyExtensionName => [
55  [
56  'code' => 1476108614,
57  'message' => $dummyExceptionMessage
58  ]
59  ]
60  ]
61  ];
62 
63  $this->assertSame($expectedResult, $result);
64  }
65 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Controller
Definition: DownloadControllerTest.php:2
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Controller\DownloadControllerTest\installFromTerReturnsArrayWithBooleanResultAndErrorArrayWhenExtensionManagerExceptionIsThrown
‪installFromTerReturnsArrayWithBooleanResultAndErrorArrayWhenExtensionManagerExceptionIsThrown()
Definition: DownloadControllerTest.php:28
‪TYPO3
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Controller\DownloadControllerTest
Definition: DownloadControllerTest.php:24