TYPO3 CMS  TYPO3_8-7
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 
20 class BackendLayoutCollectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
26  {
27  $this->expectException(\UnexpectedValueException::class);
28  $this->expectExceptionCode(1381597631);
29  $identifier = $this->getUniqueId('identifier__');
30  new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
31  }
32 
36  public function objectIsCreated()
37  {
38  $identifier = $this->getUniqueId('identifier');
39  $backendLayoutCollection = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
40 
41  $this->assertEquals($identifier, $backendLayoutCollection->getIdentifier());
42  }
43 
48  {
49  $this->expectException(\UnexpectedValueException::class);
50  $this->expectExceptionCode(1381597628);
51  $identifier = $this->getUniqueId('identifier');
52  $backendLayoutCollection = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
53  $backendLayoutIdentifier = $this->getUniqueId('identifier__');
54  $backendLayoutMock = $this->getMockBuilder(\TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
55  ->setMethods(['getIdentifier'])
56  ->disableOriginalConstructor()
57  ->getMock();
58  $backendLayoutMock->expects($this->once())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
59 
60  $backendLayoutCollection->add($backendLayoutMock);
61  }
62 
67  {
68  $this->expectException(\LogicException::class);
69  $this->expectExceptionCode(1381559376);
70  $identifier = $this->getUniqueId('identifier');
71  $backendLayoutCollection = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
72  $backendLayoutIdentifier = $this->getUniqueId('identifier');
73  $firstBackendLayoutMock = $this->getMockBuilder(\TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
74  ->setMethods(['getIdentifier'])
75  ->disableOriginalConstructor()
76  ->getMock();
77  $firstBackendLayoutMock->expects($this->once())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
78  $secondBackendLayoutMock = $this->getMockBuilder(\TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
79  ->setMethods(['getIdentifier'])
80  ->disableOriginalConstructor()
81  ->getMock();
82  $secondBackendLayoutMock->expects($this->once())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
83 
84  $backendLayoutCollection->add($firstBackendLayoutMock);
85  $backendLayoutCollection->add($secondBackendLayoutMock);
86  }
87 
91  public function backendLayoutCanBeFetched()
92  {
93  $identifier = $this->getUniqueId('identifier');
94  $backendLayoutCollection = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection($identifier);
95  $backendLayoutIdentifier = $this->getUniqueId('identifier');
96  $backendLayoutMock = $this->getMockBuilder(\TYPO3\CMS\Backend\View\BackendLayout\BackendLayout::class)
97  ->setMethods(['getIdentifier'])
98  ->disableOriginalConstructor()
99  ->getMock();
100  $backendLayoutMock->expects($this->once())->method('getIdentifier')->will($this->returnValue($backendLayoutIdentifier));
101 
102  $backendLayoutCollection->add($backendLayoutMock);
103 
104  $this->assertEquals($backendLayoutMock, $backendLayoutCollection->get($backendLayoutIdentifier));
105  }
106 }