TYPO3  7.6
UploadExtensionFileControllerTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Controller;
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 
21 class UploadExtensionFileControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
22 {
27  {
28  return array(
29  'simple' => array(
30  'extension_0.0.0.zip',
31  'extension'
32  ),
33  'underscore in extension name' => array(
34  'extension_key_10.100.356.zip',
35  'extension_key'
36  ),
37  'camel case file name' => array(
38  'extensionName_1.1.1.zip',
39  'extensionname'
40  ),
41  'version with dashes' => array(
42  'extension_1-2-3.zip',
43  'extension'
44  ),
45  'characters after version' => array(
46  'extension_1-2-3(1).zip',
47  'extension'
48  ),
49  'characters after version with extra space' => array(
50  'extension_1-2-3 (1).zip',
51  'extension'
52  ),
53  'no version' => array(
54  'extension.zip',
55  'extension'
56  )
57  );
58  }
67  {
68  $fixture = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Controller\UploadExtensionFileController::class, array('dummy'));
69  $managementServiceMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService::class, array('isAvailable'), array(), '', false);
70  $managementServiceMock->expects($this->once())
71  ->method('isAvailable')
72  ->with($expectedKey)
73  ->will($this->returnValue(false));
74  $fixture->_set('managementService', $managementServiceMock);
75  $fileHandlingUtilityMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility::class, array(), array(), '', false);
76  $fileHandlingUtilityMock->expects($this->once())->method('unzipExtensionFromFile');
77  $fixture->_set('fileHandlingUtility', $fileHandlingUtilityMock);
78 
79  $extensionDetails = $fixture->_call('getExtensionFromZipFile', '', $filename);
80  $this->assertEquals($expectedKey, $extensionDetails['extKey']);
81  }
82 }