TYPO3 CMS  TYPO3_8-7
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 
20 
24 class DatabaseParentPageRowTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
25 {
29  protected $subject;
30 
34  protected $dbProphecy;
35 
36  protected function setUp()
37  {
38  $this->subject = $this->getMockBuilder(DatabaseParentPageRow::class)
39  ->setMethods(['getDatabaseRow'])
40  ->getMock();
41  }
42 
47  {
48  $input = [
49  'tableName' => 'tt_content',
50  'command' => 'new',
51  'vanillaUid' => -10,
52  ];
53  $parentPageRow = [
54  'uid' => 123,
55  'pid' => 321
56  ];
57 
58  $this->subject->expects($this->at(0))
59  ->method('getDatabaseRow')
60  ->with($input['tableName'], 10)
61  ->willReturn(['pid' => 123]);
62 
63  $this->subject->expects($this->at(1))
64  ->method('getDatabaseRow')
65  ->with('pages', 123)
66  ->willReturn($parentPageRow);
67 
68  $result = $this->subject->addData($input);
69 
70  $this->assertSame($parentPageRow, $result['parentPageRow']);
71  }
72 
77  {
78  $input = [
79  'tableName' => 'tt_content',
80  'command' => 'new',
81  'vanillaUid' => -10,
82  ];
83  $neigborRow = [
84  'uid' => 10,
85  'pid' => 321
86  ];
87  $parentPageRow = [
88  'uid' => 123,
89  'pid' => 321
90  ];
91  $this->subject->expects($this->at(0))
92  ->method('getDatabaseRow')
93  ->with($input['tableName'], 10)
94  ->willReturn($neigborRow);
95 
96  $this->subject->expects($this->at(1))
97  ->method('getDatabaseRow')
98  ->with('pages', 321)
99  ->willReturn($parentPageRow);
100 
101  $result = $this->subject->addData($input);
102 
103  $this->assertSame($neigborRow, $result['neighborRow']);
104  }
105 
110  {
111  $input = [
112  'tableName' => 'tt_content',
113  'command' => 'new',
114  'vanillaUid' => -10,
115  ];
116 
117  $this->subject->expects($this->once())
118  ->method('getDatabaseRow')
119  ->with($input['tableName'], 10)
120  ->willReturn(['pid' => 0]);
121 
122  $result = $this->subject->addData($input);
123 
124  $this->assertNull($result['parentPageRow']);
125  }
126 
131  {
132  $input = [
133  'tableName' => 'tt_content',
134  'command' => 'new',
135  'vanillaUid' => 123,
136  ];
137  $parentPageRow = [
138  'uid' => 123,
139  'pid' => 321
140  ];
141 
142  $this->subject->expects($this->once())
143  ->method('getDatabaseRow')
144  ->with('pages', 123)
145  ->willReturn($parentPageRow);
146 
147  $result = $this->subject->addData($input);
148 
149  $this->assertSame($parentPageRow, $result['parentPageRow']);
150  }
151 
156  {
157  $input = [
158  'tableName' => 'tt_content',
159  'command' => 'edit',
160  'vanillaUid' => 123,
161  'databaseRow' => [
162  'uid' => 123,
163  'pid' => 321
164  ],
165  ];
166  $parentPageRow = [
167  'uid' => 321,
168  'pid' => 456
169  ];
170  $this->subject->expects($this->once())
171  ->method('getDatabaseRow')
172  ->with('pages', 321)
173  ->willReturn($parentPageRow);
174 
175  $result = $this->subject->addData($input);
176 
177  $this->assertSame($parentPageRow, $result['parentPageRow']);
178  }
179 }