‪TYPO3CMS  9.5
DatabaseParentPageRowTest.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 
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪DatabaseParentPageRowTest extends UnitTestCase
24 {
28  protected ‪$subject;
29 
30  protected function ‪setUp()
31  {
32  $this->subject = $this->getMockBuilder(DatabaseParentPageRow::class)
33  ->setMethods(['getDatabaseRow'])
34  ->getMock();
35  }
36 
41  {
42  $input = [
43  'tableName' => 'tt_content',
44  'command' => 'new',
45  'vanillaUid' => -10,
46  ];
47  $parentPageRow = [
48  'uid' => 123,
49  'pid' => 321
50  ];
51 
52  $this->subject->expects($this->at(0))
53  ->method('getDatabaseRow')
54  ->with($input['tableName'], 10)
55  ->willReturn(['pid' => 123]);
56 
57  $this->subject->expects($this->at(1))
58  ->method('getDatabaseRow')
59  ->with('pages', 123)
60  ->willReturn($parentPageRow);
61 
62  $result = $this->subject->addData($input);
63 
64  $this->assertSame($parentPageRow, $result['parentPageRow']);
65  }
66 
71  {
72  $input = [
73  'tableName' => 'tt_content',
74  'command' => 'new',
75  'vanillaUid' => -10,
76  ];
77  $neigborRow = [
78  'uid' => 10,
79  'pid' => 321
80  ];
81  $parentPageRow = [
82  'uid' => 123,
83  'pid' => 321
84  ];
85  $this->subject->expects($this->at(0))
86  ->method('getDatabaseRow')
87  ->with($input['tableName'], 10)
88  ->willReturn($neigborRow);
89 
90  $this->subject->expects($this->at(1))
91  ->method('getDatabaseRow')
92  ->with('pages', 321)
93  ->willReturn($parentPageRow);
94 
95  $result = $this->subject->addData($input);
96 
97  $this->assertSame($neigborRow, $result['neighborRow']);
98  }
99 
104  {
105  $input = [
106  'tableName' => 'tt_content',
107  'command' => 'new',
108  'vanillaUid' => -10,
109  ];
110 
111  $this->subject->expects($this->once())
112  ->method('getDatabaseRow')
113  ->with($input['tableName'], 10)
114  ->willReturn(['pid' => 0]);
115 
116  $result = $this->subject->addData($input);
117 
118  $this->assertNull($result['parentPageRow']);
119  }
120 
125  {
126  $input = [
127  'tableName' => 'tt_content',
128  'command' => 'new',
129  'vanillaUid' => 123,
130  ];
131  $parentPageRow = [
132  'uid' => 123,
133  'pid' => 321
134  ];
135 
136  $this->subject->expects($this->once())
137  ->method('getDatabaseRow')
138  ->with('pages', 123)
139  ->willReturn($parentPageRow);
140 
141  $result = $this->subject->addData($input);
142 
143  $this->assertSame($parentPageRow, $result['parentPageRow']);
144  }
145 
150  {
151  $input = [
152  'tableName' => 'tt_content',
153  'command' => 'edit',
154  'vanillaUid' => 123,
155  'databaseRow' => [
156  'uid' => 123,
157  'pid' => 321
158  ],
159  ];
160  $parentPageRow = [
161  'uid' => 321,
162  'pid' => 456
163  ];
164  $this->subject->expects($this->once())
165  ->method('getDatabaseRow')
166  ->with('pages', 321)
167  ->willReturn($parentPageRow);
168 
169  $result = $this->subject->addData($input);
170 
171  $this->assertSame($parentPageRow, $result['parentPageRow']);
172  }
173 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataSetsParentPageRowOnParentIfCommandIsEdit
‪addDataSetsParentPageRowOnParentIfCommandIsEdit()
Definition: DatabaseParentPageRowTest.php:148
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\$subject
‪DatabaseParentPageRow PHPUnit_Framework_MockObject_MockObject $subject
Definition: DatabaseParentPageRowTest.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataSetsParentPageToGivenPageIdIfCommandIsNew
‪addDataSetsParentPageToGivenPageIdIfCommandIsNew()
Definition: DatabaseParentPageRowTest.php:123
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataFetchesParentPageRowOfRecordIfNeighbourGiven
‪addDataFetchesParentPageRowOfRecordIfNeighbourGiven()
Definition: DatabaseParentPageRowTest.php:39
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataSetsNeigborRowIfNegativeUidGiven
‪addDataSetsNeigborRowIfNegativeUidGiven()
Definition: DatabaseParentPageRowTest.php:69
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataSetsParentPageRowToNullIfParentIsRoot
‪addDataSetsParentPageRowToNullIfParentIsRoot()
Definition: DatabaseParentPageRowTest.php:102
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\setUp
‪setUp()
Definition: DatabaseParentPageRowTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest
Definition: DatabaseParentPageRowTest.php:24
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow
Definition: DatabaseParentPageRow.php:23
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:3