TYPO3 CMS  TYPO3_7-6
UploadExtensionFileControllerTest.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 
22 {
27  {
28  return [
29  'simple' => [
30  'extension_0.0.0.zip',
31  'extension'
32  ],
33  'underscore in extension name' => [
34  'extension_key_10.100.356.zip',
35  'extension_key'
36  ],
37  'camel case file name' => [
38  'extensionName_1.1.1.zip',
39  'extensionname'
40  ],
41  'version with dashes' => [
42  'extension_1-2-3.zip',
43  'extension'
44  ],
45  'characters after version' => [
46  'extension_1-2-3(1).zip',
47  'extension'
48  ],
49  'characters after version with extra space' => [
50  'extension_1-2-3 (1).zip',
51  'extension'
52  ],
53  'no version' => [
54  'extension.zip',
55  'extension'
56  ]
57  ];
58  }
66  public function getExtensionFromZipFileExtractsExtensionKey($filename, $expectedKey)
67  {
68  $fixture = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Controller\UploadExtensionFileController::class, ['dummy']);
69  $managementServiceMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService::class, ['isAvailable'], [], '', 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, [], [], '', 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 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)