‪TYPO3CMS  10.4
BackendLayoutViewTest.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 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪BackendLayoutViewTest extends UnitTestCase
25 {
29  protected ‪$backendLayoutView;
30 
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  $this->backendLayoutView = $this->getAccessibleMock(
38  BackendLayoutView::class,
39  ['getPage', 'getRootLine'],
40  [],
41  '',
42  false
43  );
44  }
45 
53  public function ‪selectedCombinedIdentifierIsDetermined($expected, array $page, array $rootLine)
54  {
55  $pageId = $page['uid'];
56 
57  $this->backendLayoutView->expects(self::once())
58  ->method('getPage')->with(self::equalTo($pageId))
59  ->willReturn($page);
60  $this->backendLayoutView->expects(self::any())
61  ->method('getRootLine')->with(self::equalTo($pageId))
62  ->willReturn($rootLine);
63 
64  $selectedCombinedIdentifier = $this->backendLayoutView->_call('getSelectedCombinedIdentifier', $pageId);
65  self::assertEquals($expected, $selectedCombinedIdentifier);
66  }
67 
72  {
73  return [
74  'first level w/o layout' => [
75  '0',
76  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
77  [
78  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
79  ['uid' => 0, 'pid' => null],
80  ]
81  ],
82  'first level with layout' => [
83  '1',
84  ['uid' => 1, 'pid' => 0, 'backend_layout' => '1', 'backend_layout_next_level' => '0'],
85  [
86  ['uid' => 1, 'pid' => 0, 'backend_layout' => '1', 'backend_layout_next_level' => '0'],
87  ['uid' => 0, 'pid' => null],
88  ]
89  ],
90  'first level with provided layout' => [
91  'mine_current',
92  ['uid' => 1, 'pid' => 0, 'backend_layout' => 'mine_current', 'backend_layout_next_level' => '0'],
93  [
94  ['uid' => 1, 'pid' => 0, 'backend_layout' => 'mine_current', 'backend_layout_next_level' => '0'],
95  ['uid' => 0, 'pid' => null],
96  ]
97  ],
98  'first level with next layout' => [
99  '0',
100  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '1'],
101  [
102  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '1'],
103  ['uid' => 0, 'pid' => null],
104  ]
105  ],
106  'first level with provided next layout' => [
107  '0',
108  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => 'mine_next'],
109  [
110  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => 'mine_next'],
111  ['uid' => 0, 'pid' => null],
112  ]
113  ],
114  'second level w/o layout, first level with layout' => [
115  '0',
116  ['uid' => 2, 'pid' => 1, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
117  [
118  ['uid' => 2, 'pid' => 1, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
119  ['uid' => 1, 'pid' => 0, 'backend_layout' => '1', 'backend_layout_next_level' => '0'],
120  ['uid' => 0, 'pid' => null],
121  ]
122  ],
123  'second level w/o layout, first level with next layout' => [
124  '1',
125  ['uid' => 2, 'pid' => 1, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
126  [
127  ['uid' => 2, 'pid' => 1, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
128  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '1'],
129  ['uid' => 0, 'pid' => null],
130  ]
131  ],
132  'second level with layout, first level with next layout' => [
133  '2',
134  ['uid' => 2, 'pid' => 1, 'backend_layout' => '2', 'backend_layout_next_level' => '0'],
135  [
136  ['uid' => 2, 'pid' => 1, 'backend_layout' => '2', 'backend_layout_next_level' => '0'],
137  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '1'],
138  ['uid' => 0, 'pid' => null],
139  ]
140  ],
141  'second level with layouts, first level resetting all layouts' => [
142  '1',
143  ['uid' => 2, 'pid' => 1, 'backend_layout' => '1', 'backend_layout_next_level' => '1'],
144  [
145  ['uid' => 2, 'pid' => 1, 'backend_layout' => '1', 'backend_layout_next_level' => '1'],
146  ['uid' => 1, 'pid' => 0, 'backend_layout' => '-1', 'backend_layout_next_level' => '-1'],
147  ['uid' => 0, 'pid' => null],
148  ]
149  ],
150  'second level with provided layouts, first level resetting all layouts' => [
151  'mine_current',
152  ['uid' => 2, 'pid' => 1, 'backend_layout' => 'mine_current', 'backend_layout_next_level' => 'mine_next'],
153  [
154  ['uid' => 2, 'pid' => 1, 'backend_layout' => 'mine_current', 'backend_layout_next_level' => 'mine_next'],
155  ['uid' => 1, 'pid' => 0, 'backend_layout' => '-1', 'backend_layout_next_level' => '-1'],
156  ['uid' => 0, 'pid' => null],
157  ]
158  ],
159  'second level resetting layout, first level with next layout' => [
160  false,
161  ['uid' => 2, 'pid' => 1, 'backend_layout' => '-1', 'backend_layout_next_level' => '0'],
162  [
163  ['uid' => 2, 'pid' => 1, 'backend_layout' => '-1', 'backend_layout_next_level' => '0'],
164  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '1'],
165  ['uid' => 0, 'pid' => null],
166  ]
167  ],
168  'second level resetting next layout, first level with next layout' => [
169  '1',
170  ['uid' => 2, 'pid' => 1, 'backend_layout' => '0', 'backend_layout_next_level' => '-1'],
171  [
172  ['uid' => 2, 'pid' => 1, 'backend_layout' => '0', 'backend_layout_next_level' => '-1'],
173  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '1'],
174  ['uid' => 0, 'pid' => null],
175  ]
176  ],
177  'third level w/o layout, second level resetting layout, first level with next layout' => [
178  '1',
179  ['uid' => 3, 'pid' => 2, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
180  [
181  ['uid' => 3, 'pid' => 2, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
182  ['uid' => 2, 'pid' => 1, 'backend_layout' => '-1', 'backend_layout_next_level' => '0'],
183  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '1'],
184  ['uid' => 0, 'pid' => null],
185  ]
186  ],
187  'third level w/o layout, second level resetting next layout, first level with next layout' => [
188  false,
189  ['uid' => 3, 'pid' => 2, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
190  [
191  ['uid' => 3, 'pid' => 2, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
192  ['uid' => 2, 'pid' => 1, 'backend_layout' => '0', 'backend_layout_next_level' => '-1'],
193  ['uid' => 1, 'pid' => 0, 'backend_layout' => '0', 'backend_layout_next_level' => '1'],
194  ['uid' => 0, 'pid' => null],
195  ]
196  ],
197  'third level with provided layouts, second level w/o layout, first level resetting layouts' => [
198  'mine_current',
199  ['uid' => 3, 'pid' => 2, 'backend_layout' => 'mine_current', 'backend_layout_next_level' => 'mine_next'],
200  [
201  ['uid' => 3, 'pid' => 2, 'backend_layout' => 'mine_current', 'backend_layout_next_level' => 'mine_next'],
202  ['uid' => 2, 'pid' => 1, 'backend_layout' => '0', 'backend_layout_next_level' => '0'],
203  ['uid' => 1, 'pid' => 0, 'backend_layout' => '-1', 'backend_layout_next_level' => '-1'],
204  ['uid' => 0, 'pid' => null],
205  ]
206  ],
207  ];
208  }
209 }
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayoutViewTest\selectedCombinedIdentifierIsDeterminedDataProvider
‪array selectedCombinedIdentifierIsDeterminedDataProvider()
Definition: BackendLayoutViewTest.php:70
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayoutViewTest
Definition: BackendLayoutViewTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayoutViewTest\selectedCombinedIdentifierIsDetermined
‪selectedCombinedIdentifierIsDetermined($expected, array $page, array $rootLine)
Definition: BackendLayoutViewTest.php:52
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayoutViewTest\$backendLayoutView
‪TYPO3 CMS Backend View BackendLayoutView PHPUnit Framework MockObject MockObject $backendLayoutView
Definition: BackendLayoutViewTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\View\BackendLayoutViewTest\setUp
‪setUp()
Definition: BackendLayoutViewTest.php:33
‪TYPO3\CMS\Backend\Tests\Unit\View
Definition: ArrayBrowserTest.php:16
‪TYPO3\CMS\Backend\View\BackendLayoutView
Definition: BackendLayoutView.php:36