‪TYPO3CMS  ‪main
DownloadQueueTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\Test;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 final class ‪DownloadQueueTest extends UnitTestCase
30 {
34  protected ‪$downloadQueue;
35 
39  protected ‪$extension;
40 
41  protected function ‪setUp(): void
42  {
43  parent::setUp();
44  $this->downloadQueue = new ‪DownloadQueue();
45  $this->extension = new ‪Extension();
46  $this->extension->setExtensionKey('foobar');
47  $this->extension->setVersion('1.0.0');
48  }
49 
50  #[Test]
52  {
53  $this->downloadQueue->addExtensionToQueue($this->extension);
54  $extensionStorage = $this->downloadQueue->getExtensionQueue();
55 
56  self::assertArrayHasKey('foobar', $extensionStorage['download']);
57  }
58 
59  #[Test]
61  {
62  $this->downloadQueue->addExtensionToQueue($this->extension, 'update');
63  $extensionStorage = $this->downloadQueue->getExtensionQueue();
64 
65  self::assertArrayHasKey('foobar', $extensionStorage['update']);
66  }
67 
68  #[Test]
70  {
71  $this->expectException(ExtensionManagerException::class);
72  $this->expectExceptionCode(1342432103);
73  $this->downloadQueue->addExtensionToQueue($this->extension, 'unknownStack');
74  }
75 
76  #[Test]
78  {
81  ‪$extension->‪setVersion('1.0.3');
82 
83  $this->expectException(ExtensionManagerException::class);
84  $this->expectExceptionCode(1342432101);
85  $this->downloadQueue->addExtensionToQueue(‪$extension);
86  $this->downloadQueue->addExtensionToQueue($this->extension);
87  }
88 
89  #[Test]
90  public function ‪removeExtensionFromQueueRemovesExtension(): void
91  {
93  ‪$extension->‪setExtensionKey('foobarbaz');
94  ‪$extension->‪setVersion('1.0.3');
95  $this->downloadQueue->addExtensionToQueue($this->extension);
96  $this->downloadQueue->addExtensionToQueue(‪$extension);
97  $extensionStorageBefore = $this->downloadQueue->getExtensionQueue();
98 
99  self::assertArrayHasKey('foobar', $extensionStorageBefore['download']);
100 
101  $this->downloadQueue->removeExtensionFromQueue($this->extension);
102  $extensionStorageAfter = $this->downloadQueue->getExtensionQueue();
103 
104  self::assertArrayNotHasKey('foobar', $extensionStorageAfter['download']);
105  }
106 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists
‪addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists()
Definition: DownloadQueueTest.php:75
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest
Definition: DownloadQueueTest.php:30
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model
Definition: DependencyTest.php:18
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\$extension
‪Extension $extension
Definition: DownloadQueueTest.php:37
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension
Definition: Extension.php:30
‪TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue
Definition: DownloadQueue.php:28
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setExtensionKey
‪setExtensionKey(string $extensionKey)
Definition: Extension.php:171
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueAddsExtensionToDownloadStorageArray
‪addExtensionToQueueAddsExtensionToDownloadStorageArray()
Definition: DownloadQueueTest.php:49
‪TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
Definition: ExtensionManagerException.php:25
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\setUp
‪setUp()
Definition: DownloadQueueTest.php:39
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\$downloadQueue
‪DownloadQueue $downloadQueue
Definition: DownloadQueueTest.php:33
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model\DownloadQueueTest\addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven
‪addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven()
Definition: DownloadQueueTest.php:67
‪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:88
‪TYPO3\CMS\Extensionmanager\Domain\Model\Extension\setVersion
‪setVersion(string $version)
Definition: Extension.php:262