[TASK] Fix CGL violations against ClassDocComment
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Domain / Model / DownloadQueueTest.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Susanne Moog, <susanne.moog@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Download queue test
29 *
30 * @package Extension Manager
31 * @subpackage Tests
32 */
33 class DownloadQueueTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
34
35 /**
36 * @test
37 * @return void
38 */
39 public function addExtensionToQueueAddsExtensionToDownloadStorageArray() {
40 $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
41 $extensionModelMock->_set('extensionKey', 'foobar');
42 $extensionModelMock->_set('version', '1.0.0');
43 $downloadQueueMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\DownloadQueue', array('dummy'));
44 $downloadQueueMock->addExtensionToQueue($extensionModelMock);
45 $extensionStorage = $downloadQueueMock->_get('extensionStorage');
46 $this->assertArrayHasKey('foobar', $extensionStorage['download']);
47 }
48
49 /**
50 * @test
51 * @return void
52 */
53 public function addExtensionToQueueAddsExtensionToUpdateStorageArray() {
54 $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
55 $extensionModelMock->_set('extensionKey', 'foobar');
56 $extensionModelMock->_set('version', '1.0.0');
57 $downloadQueueMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\DownloadQueue', array('dummy'));
58 $downloadQueueMock->addExtensionToQueue($extensionModelMock, 'update');
59 $extensionStorage = $downloadQueueMock->_get('extensionStorage');
60 $this->assertArrayHasKey('foobar', $extensionStorage['update']);
61 }
62
63 /**
64 * @test
65 * @return void
66 */
67 public function addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven() {
68 /** @var $extensionModelMock \TYPO3\CMS\Extensionmanager\Domain\Model\Extension */
69 $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
70 $extensionModelMock->_set('extensionKey', 'foobar');
71 $extensionModelMock->_set('version', '1.0.0');
72 /** @var $downloadQueueMock \TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue */
73 $downloadQueueMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\DownloadQueue', array('dummy'));
74 $this->setExpectedException('TYPO3\\CMS\\Extensionmanager\\Exception\\ExtensionManagerException', $this->any(), 1342432103);
75 $downloadQueueMock->addExtensionToQueue($extensionModelMock, 'unknownStack');
76 }
77
78 /**
79 * @test
80 * @return void
81 */
82 public function addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists() {
83 $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
84 $extensionModelMock->_set('extensionKey', 'foobar');
85 $extensionModelMock->_set('version', '1.0.0');
86 $extensionModelMock2 = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
87 $extensionModelMock2->_set('extensionKey', 'foobar');
88 $extensionModelMock2->_set('version', '1.0.3');
89 $downloadQueueMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\DownloadQueue', array('dummy'));
90 $downloadQueueMock->_set('extensionStorage', array('foobar' => $extensionModelMock2));
91 $this->setExpectedException('TYPO3\\CMS\\Extensionmanager\\Exception\\ExtensionManagerException', $this->any(), 1342432101);
92 $downloadQueueMock->addExtensionToQueue($extensionModelMock);
93 }
94
95 /**
96 * @test
97 * @return void
98 */
99 public function removeExtensionFromQueueRemovesExtension() {
100 $extensionModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
101 $extensionModelMock->_set('extensionKey', 'foobar');
102 $extensionModelMock->_set('version', '1.0.0');
103 $extensionModelMock2 = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Extension', array('dummy'));
104 $extensionModelMock2->_set('extensionKey', 'foobarbaz');
105 $extensionModelMock2->_set('version', '1.0.3');
106 $downloadQueueMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\DownloadQueue', array('dummy'));
107 $downloadQueueMock->_set('extensionStorage', array(
108 'download' => array(
109 'foobar' => $extensionModelMock,
110 'foobarbaz' => $extensionModelMock2
111 )
112 ));
113 $extensionStorageBefore = $downloadQueueMock->_get('extensionStorage');
114 $this->assertTrue(array_key_exists('foobar', $extensionStorageBefore['download']));
115 $downloadQueueMock->removeExtensionFromQueue($extensionModelMock);
116 $extensionStorageAfter = $downloadQueueMock->_get('extensionStorage');
117 $this->assertFalse(array_key_exists('foobar', $extensionStorageAfter['download']));
118 }
119
120 }
121
122
123 ?>