[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Controller / UploadExtensionFileControllerTest.php
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
17 /**
18 * Update from TER controller test
19 *
20 */
21 class UploadExtensionFileControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
22
23 /**
24 * @return array The test data for getExtensionFromZipFileExtractsExtensionKey
25 */
26 public function getExtensionFromZipFileExtractsExtensionKeyDataProvider() {
27 return array(
28 'simple' => array(
29 'extension_0.0.0.zip',
30 'extension'
31 ),
32 'underscore in extension name' => array(
33 'extension_key_10.100.356.zip',
34 'extension_key'
35 ),
36 'camel case file name' => array(
37 'extensionName_1.1.1.zip',
38 'extensionname'
39 ),
40 'version with dashes' => array(
41 'extension_1-2-3.zip',
42 'extension'
43 ),
44 'characters after version' => array(
45 'extension_1-2-3(1).zip',
46 'extension'
47 ),
48 'characters after version with extra space' => array(
49 'extension_1-2-3 (1).zip',
50 'extension'
51 ),
52 'no version' => array(
53 'extension.zip',
54 'extension'
55 )
56 );
57 }
58 /**
59 * @test
60 * @dataProvider getExtensionFromZipFileExtractsExtensionKeyDataProvider
61 * @param string $filename The file name to test
62 * @param string $expectedKey The expected extension key
63 * @return void
64 */
65 public function getExtensionFromZipFileExtractsExtensionKey($filename, $expectedKey) {
66 $fixture = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Controller\\UploadExtensionFileController', array('dummy'));
67 $installUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\InstallUtility', array(), array(), '', FALSE);
68 $installUtilityMock->expects($this->once())
69 ->method('isAvailable')
70 ->with($expectedKey)
71 ->will($this->returnValue(FALSE));
72 $fixture->_set('installUtility', $installUtilityMock);
73 $fileHandlingUtilityMock = $this->getMock('TYPO3\\CMS\\Extensionmanager\\Utility\\FileHandlingUtility');
74 $fileHandlingUtilityMock->expects($this->once())->method('unzipExtensionFromFile');
75 $fixture->_set('fileHandlingUtility', $fileHandlingUtilityMock);
76
77 $extensionDetails = $fixture->_call('getExtensionFromZipFile', '', $filename);
78 $this->assertEquals($expectedKey, $extensionDetails['extKey']);
79 }
80
81 }