‪TYPO3CMS  10.4
DatabaseParentPageRowTest.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 ‪DatabaseParentPageRowTest extends UnitTestCase
25 {
29  protected ‪$subject;
30 
31  protected function ‪setUp(): void
32  {
33  $this->subject = $this->getMockBuilder(DatabaseParentPageRow::class)
34  ->setMethods(['getDatabaseRow'])
35  ->getMock();
36  }
37 
42  {
43  $input = [
44  'tableName' => 'tt_content',
45  'command' => 'new',
46  'vanillaUid' => -10,
47  ];
48  $parentPageRow = [
49  'uid' => 123,
50  'pid' => 321
51  ];
52 
53  $this->subject->expects(self::exactly(2))
54  ->method('getDatabaseRow')
55  ->withConsecutive([$input['tableName'], 10], ['pages', 123])
56  ->willReturnOnConsecutiveCalls(['pid' => 123], $parentPageRow);
57 
58  $result = $this->subject->addData($input);
59 
60  self::assertSame($parentPageRow, $result['parentPageRow']);
61  }
62 
67  {
68  $input = [
69  'tableName' => 'tt_content',
70  'command' => 'new',
71  'vanillaUid' => -10,
72  ];
73  $neighborRow = [
74  'uid' => 10,
75  'pid' => 321
76  ];
77  $parentPageRow = [
78  'uid' => 123,
79  'pid' => 321
80  ];
81  $this->subject->expects(self::exactly(2))
82  ->method('getDatabaseRow')
83  ->withConsecutive([$input['tableName'], 10], ['pages', 321])
84  ->willReturnOnConsecutiveCalls($neighborRow, $parentPageRow);
85 
86  $result = $this->subject->addData($input);
87 
88  self::assertSame($neighborRow, $result['neighborRow']);
89  }
90 
95  {
96  $input = [
97  'tableName' => 'tt_content',
98  'command' => 'new',
99  'vanillaUid' => -10,
100  ];
101 
102  $this->subject->expects(self::once())
103  ->method('getDatabaseRow')
104  ->with($input['tableName'], 10)
105  ->willReturn(['pid' => 0]);
106 
107  $result = $this->subject->addData($input);
108 
109  self::assertNull($result['parentPageRow']);
110  }
111 
116  {
117  $input = [
118  'tableName' => 'tt_content',
119  'command' => 'new',
120  'vanillaUid' => 123,
121  ];
122  $parentPageRow = [
123  'uid' => 123,
124  'pid' => 321
125  ];
126 
127  $this->subject->expects(self::once())
128  ->method('getDatabaseRow')
129  ->with('pages', 123)
130  ->willReturn($parentPageRow);
131 
132  $result = $this->subject->addData($input);
133 
134  self::assertSame($parentPageRow, $result['parentPageRow']);
135  }
136 
141  {
142  $input = [
143  'tableName' => 'tt_content',
144  'command' => 'edit',
145  'vanillaUid' => 123,
146  'databaseRow' => [
147  'uid' => 123,
148  'pid' => 321
149  ],
150  ];
151  $parentPageRow = [
152  'uid' => 321,
153  'pid' => 456
154  ];
155  $this->subject->expects(self::once())
156  ->method('getDatabaseRow')
157  ->with('pages', 321)
158  ->willReturn($parentPageRow);
159 
160  $result = $this->subject->addData($input);
161 
162  self::assertSame($parentPageRow, $result['parentPageRow']);
163  }
164 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataSetsParentPageRowOnParentIfCommandIsEdit
‪addDataSetsParentPageRowOnParentIfCommandIsEdit()
Definition: DatabaseParentPageRowTest.php:139
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataSetsParentPageToGivenPageIdIfCommandIsNew
‪addDataSetsParentPageToGivenPageIdIfCommandIsNew()
Definition: DatabaseParentPageRowTest.php:114
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataFetchesParentPageRowOfRecordIfNeighbourGiven
‪addDataFetchesParentPageRowOfRecordIfNeighbourGiven()
Definition: DatabaseParentPageRowTest.php:40
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataSetsNeighborRowIfNegativeUidGiven
‪addDataSetsNeighborRowIfNegativeUidGiven()
Definition: DatabaseParentPageRowTest.php:65
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\addDataSetsParentPageRowToNullIfParentIsRoot
‪addDataSetsParentPageRowToNullIfParentIsRoot()
Definition: DatabaseParentPageRowTest.php:93
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\setUp
‪setUp()
Definition: DatabaseParentPageRowTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest
Definition: DatabaseParentPageRowTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseParentPageRowTest\$subject
‪DatabaseParentPageRow PHPUnit Framework MockObject MockObject $subject
Definition: DatabaseParentPageRowTest.php:28
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseParentPageRow
Definition: DatabaseParentPageRow.php:24
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18