‪TYPO3CMS  10.4
DownloadQueueTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪DownloadQueueTest extends UnitTestCase
27 {
31  protected ‪$downloadQueue;
32 
36  protected ‪$extension;
37 
38  protected function ‪setUp(): void
39  {
40  parent::setUp();
41  $this->downloadQueue = new ‪DownloadQueue();
42  $this->extension = new ‪Extension();
43  $this->extension->setExtensionKey('foobar');
44  $this->extension->setVersion('1.0.0');
45  }
46 
51  {
52  $this->downloadQueue->addExtensionToQueue($this->extension);
53  $extensionStorage = $this->downloadQueue->getExtensionQueue();
54 
55  self::assertArrayHasKey('foobar', $extensionStorage['download']);
56  }
57 
62  {
63  $this->downloadQueue->addExtensionToQueue($this->extension, 'update');
64  $extensionStorage = $this->downloadQueue->getExtensionQueue();
65 
66  self::assertArrayHasKey('foobar', $extensionStorage['update']);
67  }
68 
73  {
74  $this->expectException(ExtensionManagerException::class);
75  $this->expectExceptionCode(1342432103);
76  $this->downloadQueue->addExtensionToQueue($this->extension, 'unknownStack');
77  }
78 
83  {
84  ‪$extension = new Extension();
86  ‪$extension->‪setVersion('1.0.3');
87 
88  $this->expectException(ExtensionManagerException::class);
89  $this->expectExceptionCode(1342432101);
90  $this->downloadQueue->addExtensionToQueue(‪$extension);
91  $this->downloadQueue->addExtensionToQueue($this->extension);
92  }
93 
97  public function ‪removeExtensionFromQueueRemovesExtension(): void
98  {
99  ‪$extension = new Extension();
100  ‪$extension->‪setExtensionKey('foobarbaz');
101  ‪$extension->‪setVersion('1.0.3');
102  $this->downloadQueue->addExtensionToQueue($this->extension);
103  $this->downloadQueue->addExtensionToQueue(‪$extension);
104  $extensionStorageBefore = $this->downloadQueue->getExtensionQueue();
105 
106  self::assertTrue(array_key_exists('foobar', $extensionStorageBefore['download']));
107 
108  $this->downloadQueue->removeExtensionFromQueue($this->extension);
109  $extensionStorageAfter = $this->downloadQueue->getExtensionQueue();
110 
111  self::assertFalse(array_key_exists('foobar', $extensionStorageAfter['download']));
112  }
113 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists
‪addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists()
Definition: DownloadQueueTest.php:80
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest
Definition: DownloadQueueTest.php:27
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model
Definition: DownloadQueueTest.php:16
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setVersion
‪setVersion($version)
Definition: Extension.php:391
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:29
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue
Definition: DownloadQueue.php:26
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\$extension
‪TYPO3 CMS Extensionmanager Domain Model Extension $extension
Definition: DownloadQueueTest.php:34
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueAddsExtensionToDownloadStorageArray
‪addExtensionToQueueAddsExtensionToDownloadStorageArray()
Definition: DownloadQueueTest.php:48
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:24
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\setUp
‪setUp()
Definition: DownloadQueueTest.php:36
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven
‪addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven()
Definition: DownloadQueueTest.php:70
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\$downloadQueue
‪TYPO3 CMS Extensionmanager Domain Model DownloadQueue $downloadQueue
Definition: DownloadQueueTest.php:30
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueAddsExtensionToUpdateStorageArray
‪addExtensionToQueueAddsExtensionToUpdateStorageArray()
Definition: DownloadQueueTest.php:59
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setExtensionKey
‪setExtensionKey($extensionKey)
Definition: Extension.php:262
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\removeExtensionFromQueueRemovesExtension
‪removeExtensionFromQueueRemovesExtension()
Definition: DownloadQueueTest.php:95