‪TYPO3CMS  9.5
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  */
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪DownloadQueueTest extends UnitTestCase
23 {
27  protected ‪$downloadQueueMock;
28 
32  protected ‪$extensionMock;
33 
36  protected function ‪setUp()
37  {
38  $this->downloadQueueMock = $this->getAccessibleMock(\‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue::class, ['dummy']);
39  $this->extensionMock = $this->getMockBuilder(\‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class)
40  ->setMethods(['dummy'])
41  ->getMock();
42  $this->extensionMock->setExtensionKey('foobar');
43  $this->extensionMock->setVersion('1.0.0');
44  }
45 
50  {
51  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
52  $extensionStorage = $this->downloadQueueMock->_get('extensionStorage');
53 
54  $this->assertArrayHasKey('foobar', $extensionStorage['download']);
55  }
56 
61  {
62  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'update');
63  $extensionStorage = $this->downloadQueueMock->_get('extensionStorage');
64 
65  $this->assertArrayHasKey('foobar', $extensionStorage['update']);
66  }
67 
72  {
73  $this->expectException(ExtensionManagerException::class);
74  $this->expectExceptionCode(1342432103);
75  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'unknownStack');
76  }
77 
82  {
84  $extensionMock2 = $this->getMockBuilder(\‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class)
85  ->setMethods(['dummy'])
86  ->getMock();
87  $extensionMock2->setExtensionKey('foobar');
88  $extensionMock2->setVersion('1.0.3');
89 
90  $this->expectException(ExtensionManagerException::class);
91  $this->expectExceptionCode(1342432101);
92  $this->downloadQueueMock->addExtensionToQueue($extensionMock2);
93  $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
94  }
95 
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 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists
‪addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists()
Definition: DownloadQueueTest.php:79
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest
Definition: DownloadQueueTest.php:23
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model
Definition: DownloadQueueTest.php:2
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:24
‪TYPO3
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue
Definition: DownloadQueue.php:24
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\$extensionMock
‪PHPUnit_Framework_MockObject_MockObject TYPO3 CMS Extensionmanager Domain Model Extension $extensionMock
Definition: DownloadQueueTest.php:30
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\$downloadQueueMock
‪PHPUnit_Framework_MockObject_MockObject TYPO3 TestingFramework Core AccessibleObjectInterface TYPO3 CMS Extensionmanager Domain Model DownloadQueue $downloadQueueMock
Definition: DownloadQueueTest.php:26
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueAddsExtensionToDownloadStorageArray
‪addExtensionToQueueAddsExtensionToDownloadStorageArray()
Definition: DownloadQueueTest.php:47
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:23
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\setUp
‪setUp()
Definition: DownloadQueueTest.php:34
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven
‪addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven()
Definition: DownloadQueueTest.php:69
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueAddsExtensionToUpdateStorageArray
‪addExtensionToQueueAddsExtensionToUpdateStorageArray()
Definition: DownloadQueueTest.php:58
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\removeExtensionFromQueueRemovesExtension
‪removeExtensionFromQueueRemovesExtension()
Definition: DownloadQueueTest.php:97