TYPO3 CMS  TYPO3_7-6
DownloadQueueTest.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 {
26  protected $downloadQueueMock;
27 
31  protected $extensionMock;
32 
36  protected function setUp()
37  {
38  $this->downloadQueueMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue::class, ['dummy']);
39  $this->extensionMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class, ['dummy']);
40  $this->extensionMock->setExtensionKey('foobar');
41  $this->extensionMock->setVersion('1.0.0');
42  }
43 
49  {
50  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
51  $extensionStorage = $this->downloadQueueMock->_get('extensionStorage');
52 
53  $this->assertArrayHasKey('foobar', $extensionStorage['download']);
54  }
55 
61  {
62  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'update');
63  $extensionStorage = $this->downloadQueueMock->_get('extensionStorage');
64 
65  $this->assertArrayHasKey('foobar', $extensionStorage['update']);
66  }
67 
74  {
75  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'unknownStack');
76  }
77 
84  public function addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists()
85  {
87  $extensionMock2 = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class, ['dummy']);
88  $extensionMock2->setExtensionKey('foobar');
89  $extensionMock2->setVersion('1.0.3');
90 
91  $this->downloadQueueMock->addExtensionToQueue($extensionMock2);
92  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
93  }
94 
100  {
101  $extensionMock2 = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class, ['dummy']);
102  $extensionMock2->_set('extensionKey', 'foobarbaz');
103  $extensionMock2->_set('version', '1.0.3');
104  $this->downloadQueueMock->_set('extensionStorage', [
105  'download' => [
106  'foobar' => $this->extensionMock,
107  'foobarbaz' => $extensionMock2
108  ]
109  ]);
110  $extensionStorageBefore = $this->downloadQueueMock->_get('extensionStorage');
111 
112  $this->assertTrue(array_key_exists('foobar', $extensionStorageBefore['download']));
113 
114  $this->downloadQueueMock->removeExtensionFromQueue($this->extensionMock);
115  $extensionStorageAfter = $this->downloadQueueMock->_get('extensionStorage');
116 
117  $this->assertFalse(array_key_exists('foobar', $extensionStorageAfter['download']));
118  }
119 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)