‪TYPO3CMS  11.5
BackendLayoutCollectionTest.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 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪BackendLayoutCollectionTest extends UnitTestCase
29 {
34  {
35  $this->expectException(\UnexpectedValueException::class);
36  $this->expectExceptionCode(1381597631);
37  $identifier = ‪StringUtility::getUniqueId('identifier__');
38  new ‪BackendLayoutCollection($identifier);
39  }
40 
44  public function ‪objectIsCreated(): void
45  {
46  $identifier = ‪StringUtility::getUniqueId('identifier');
47  $backendLayoutCollection = new ‪BackendLayoutCollection($identifier);
48 
49  self::assertEquals($identifier, $backendLayoutCollection->getIdentifier());
50  }
51 
56  {
57  $this->expectException(\UnexpectedValueException::class);
58  $this->expectExceptionCode(1381597628);
59  $identifier = ‪StringUtility::getUniqueId('identifier');
60  $backendLayoutCollection = new ‪BackendLayoutCollection($identifier);
61  $backendLayoutIdentifier = ‪StringUtility::getUniqueId('identifier__');
62  $backendLayoutMock = $this->getMockBuilder(BackendLayout::class)
63  ->onlyMethods(['getIdentifier'])
64  ->disableOriginalConstructor()
65  ->getMock();
66  $backendLayoutMock->expects(self::once())->method('getIdentifier')->willReturn($backendLayoutIdentifier);
67 
68  $backendLayoutCollection->add($backendLayoutMock);
69  }
70 
75  {
76  $this->expectException(\LogicException::class);
77  $this->expectExceptionCode(1381559376);
78  $identifier = ‪StringUtility::getUniqueId('identifier');
79  $backendLayoutCollection = new ‪BackendLayoutCollection($identifier);
80  $backendLayoutIdentifier = ‪StringUtility::getUniqueId('identifier');
81  $firstBackendLayoutMock = $this->getMockBuilder(BackendLayout::class)
82  ->onlyMethods(['getIdentifier'])
83  ->disableOriginalConstructor()
84  ->getMock();
85  $firstBackendLayoutMock->expects(self::once())->method('getIdentifier')->willReturn($backendLayoutIdentifier);
86  $secondBackendLayoutMock = $this->getMockBuilder(BackendLayout::class)
87  ->onlyMethods(['getIdentifier'])
88  ->disableOriginalConstructor()
89  ->getMock();
90  $secondBackendLayoutMock->expects(self::once())->method('getIdentifier')->willReturn($backendLayoutIdentifier);
91 
92  $backendLayoutCollection->add($firstBackendLayoutMock);
93  $backendLayoutCollection->add($secondBackendLayoutMock);
94  }
95 
99  public function ‪backendLayoutCanBeFetched(): void
100  {
101  $identifier = ‪StringUtility::getUniqueId('identifier');
102  $backendLayoutCollection = new ‪BackendLayoutCollection($identifier);
103  $backendLayoutIdentifier = ‪StringUtility::getUniqueId('identifier');
104  $backendLayoutMock = $this->getMockBuilder(BackendLayout::class)
105  ->onlyMethods(['getIdentifier'])
106  ->disableOriginalConstructor()
107  ->getMock();
108  $backendLayoutMock->expects(self::once())->method('getIdentifier')->willReturn($backendLayoutIdentifier);
109 
110  $backendLayoutCollection->add($backendLayoutMock);
111 
112  self::assertEquals($backendLayoutMock, $backendLayoutCollection->get($backendLayoutIdentifier));
113  }
114 }
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest
Definition: BackendLayoutCollectionTest.php:29
‪TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection
Definition: BackendLayoutCollection.php:22
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\backendLayoutCanBeFetched
‪backendLayoutCanBeFetched()
Definition: BackendLayoutCollectionTest.php:99
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\objectIsCreated
‪objectIsCreated()
Definition: BackendLayoutCollectionTest.php:44
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\invalidBackendLayoutIsRecognizedOnAdding
‪invalidBackendLayoutIsRecognizedOnAdding()
Definition: BackendLayoutCollectionTest.php:55
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout
Definition: BackendLayoutCollectionTest.php:18
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\duplicateBackendLayoutIsRecognizedOnAdding
‪duplicateBackendLayoutIsRecognizedOnAdding()
Definition: BackendLayoutCollectionTest.php:74
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\invalidIdentifierIsRecognizedOnCreation
‪invalidIdentifierIsRecognizedOnCreation()
Definition: BackendLayoutCollectionTest.php:33
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:128
‪TYPO3\CMS\Backend\View\BackendLayout\BackendLayout
Definition: BackendLayout.php:25
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22