TYPO3 CMS  TYPO3_8-7
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 
20 class DownloadControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
26  {
27  $dummyExceptionMessage = 'exception message';
28  $dummyException = new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException($dummyExceptionMessage, 1476108614);
29 
30  $dummyExtensionName = 'dummy_extension';
31  $dummyExtension = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class)->getMock();
32  $dummyExtension->expects($this->any())->method('getExtensionKey')->will($this->returnValue($dummyExtensionName));
33 
34  $downloadUtilityMock = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Utility\DownloadUtility::class)->getMock();
35  $downloadUtilityMock->expects($this->any())->method('setDownloadPath')->willThrowException($dummyException);
36 
37  $subject = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Controller\DownloadController::class, ['dummy']);
38  $subject->_set('downloadUtility', $downloadUtilityMock);
39 
40  $result = $subject->_call('installFromTer', $dummyExtension);
41 
42  $expectedResult = [
43  false,
44  [
45  $dummyExtensionName => [
46  [
47  'code' => 1476108614,
48  'message' => $dummyExceptionMessage
49  ]
50  ]
51  ]
52  ];
53 
54  $this->assertSame($expectedResult, $result);
55  }
56 }