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