‪TYPO3CMS  9.5
BackendLayoutCollectionTest.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  */
16 
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪BackendLayoutCollectionTest extends UnitTestCase
23 {
28  {
29  $this->expectException(\UnexpectedValueException::class);
30  $this->expectExceptionCode(1381597631);
31  $identifier = $this->getUniqueId('identifier__');
32  new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
33  }
34 
38  public function ‪objectIsCreated()
39  {
40  $identifier = $this->getUniqueId('identifier');
41  $backendLayoutCollection = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
42 
43  $this->assertEquals($identifier, $backendLayoutCollection->getIdentifier());
44  }
45 
50  {
51  $this->expectException(\UnexpectedValueException::class);
52  $this->expectExceptionCode(1381597628);
53  $identifier = $this->getUniqueId('identifier');
54  $backendLayoutCollection = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
55  $backendLayoutIdentifier = $this->getUniqueId('identifier__');
56  $backendLayoutMock = $this->getMockBuilder(\‪TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
57  ->setMethods(['getIdentifier'])
58  ->disableOriginalConstructor()
59  ->getMock();
60  $backendLayoutMock->expects($this->once())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
61 
62  $backendLayoutCollection->add($backendLayoutMock);
63  }
64 
69  {
70  $this->expectException(\LogicException::class);
71  $this->expectExceptionCode(1381559376);
72  $identifier = $this->getUniqueId('identifier');
73  $backendLayoutCollection = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
74  $backendLayoutIdentifier = $this->getUniqueId('identifier');
75  $firstBackendLayoutMock = $this->getMockBuilder(\‪TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
76  ->setMethods(['getIdentifier'])
77  ->disableOriginalConstructor()
78  ->getMock();
79  $firstBackendLayoutMock->expects($this->once())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
80  $secondBackendLayoutMock = $this->getMockBuilder(\‪TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
81  ->setMethods(['getIdentifier'])
82  ->disableOriginalConstructor()
83  ->getMock();
84  $secondBackendLayoutMock->expects($this->once())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
85 
86  $backendLayoutCollection->add($firstBackendLayoutMock);
87  $backendLayoutCollection->add($secondBackendLayoutMock);
88  }
89 
93  public function ‪backendLayoutCanBeFetched()
94  {
95  $identifier = $this->getUniqueId('identifier');
96  $backendLayoutCollection = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
97  $backendLayoutIdentifier = $this->getUniqueId('identifier');
98  $backendLayoutMock = $this->getMockBuilder(\‪TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
99  ->setMethods(['getIdentifier'])
100  ->disableOriginalConstructor()
101  ->getMock();
102  $backendLayoutMock->expects($this->once())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
103 
104  $backendLayoutCollection->add($backendLayoutMock);
105 
106  $this->assertEquals($backendLayoutMock, $backendLayoutCollection->get($backendLayoutIdentifier));
107  }
108 }
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest
Definition: BackendLayoutCollectionTest.php:23
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\backendLayoutCanBeFetched
‪backendLayoutCanBeFetched()
Definition: BackendLayoutCollectionTest.php:93
‪TYPO3
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\objectIsCreated
‪objectIsCreated()
Definition: BackendLayoutCollectionTest.php:38
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\invalidBackendLayoutIsRecognizedOnAdding
‪invalidBackendLayoutIsRecognizedOnAdding()
Definition: BackendLayoutCollectionTest.php:49
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout
Definition: BackendLayoutCollectionTest.php:2
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\duplicateBackendLayoutIsRecognizedOnAdding
‪duplicateBackendLayoutIsRecognizedOnAdding()
Definition: BackendLayoutCollectionTest.php:68
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayout\BackendLayoutCollectionTest\invalidIdentifierIsRecognizedOnCreation
‪invalidIdentifierIsRecognizedOnCreation()
Definition: BackendLayoutCollectionTest.php:27