TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
DatabaseParentPageRowTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
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 
17 use Prophecy\Prophecy\ObjectProphecy;
21 
26 {
30  protected $subject;
31 
35  protected $dbProphecy;
36 
37  protected function setUp()
38  {
39  $this->subject = $this->getMockBuilder(DatabaseParentPageRow::class)
40  ->setMethods(['getDatabaseRow'])
41  ->getMock();
42  }
43 
48  {
49  $input = [
50  'tableName' => 'tt_content',
51  'command' => 'new',
52  'vanillaUid' => -10,
53  ];
54  $parentPageRow = [
55  'uid' => 123,
56  'pid' => 321
57  ];
58 
59  $this->subject->expects($this->at(0))
60  ->method('getDatabaseRow')
61  ->with($input['tableName'], 10)
62  ->willReturn(['pid' => 123]);
63 
64  $this->subject->expects($this->at(1))
65  ->method('getDatabaseRow')
66  ->with('pages', 123)
67  ->willReturn($parentPageRow);
68 
69  $result = $this->subject->addData($input);
70 
71  $this->assertSame($parentPageRow, $result['parentPageRow']);
72  }
73 
78  {
79  $input = [
80  'tableName' => 'tt_content',
81  'command' => 'new',
82  'vanillaUid' => -10,
83  ];
84  $neigborRow = [
85  'uid' => 10,
86  'pid' => 321
87  ];
88  $parentPageRow = [
89  'uid' => 123,
90  'pid' => 321
91  ];
92  $this->subject->expects($this->at(0))
93  ->method('getDatabaseRow')
94  ->with($input['tableName'], 10)
95  ->willReturn($neigborRow);
96 
97  $this->subject->expects($this->at(1))
98  ->method('getDatabaseRow')
99  ->with('pages', 321)
100  ->willReturn($parentPageRow);
101 
102  $result = $this->subject->addData($input);
103 
104  $this->assertSame($neigborRow, $result['neighborRow']);
105  }
106 
111  {
112  $input = [
113  'tableName' => 'tt_content',
114  'command' => 'new',
115  'vanillaUid' => -10,
116  ];
117 
118  $this->subject->expects($this->once())
119  ->method('getDatabaseRow')
120  ->with($input['tableName'], 10)
121  ->willReturn(['pid' => 0]);
122 
123  $result = $this->subject->addData($input);
124 
125  $this->assertNull($result['parentPageRow']);
126  }
127 
132  {
133  $input = [
134  'tableName' => 'tt_content',
135  'command' => 'new',
136  'vanillaUid' => 123,
137  ];
138  $parentPageRow = [
139  'uid' => 123,
140  'pid' => 321
141  ];
142 
143  $this->subject->expects($this->once())
144  ->method('getDatabaseRow')
145  ->with('pages', 123)
146  ->willReturn($parentPageRow);
147 
148  $result = $this->subject->addData($input);
149 
150  $this->assertSame($parentPageRow, $result['parentPageRow']);
151  }
152 
157  {
158  $input = [
159  'tableName' => 'tt_content',
160  'command' => 'edit',
161  'vanillaUid' => 123,
162  'databaseRow' => [
163  'uid' => 123,
164  'pid' => 321
165  ],
166  ];
167  $parentPageRow = [
168  'uid' => 321,
169  'pid' => 456
170  ];
171  $this->subject->expects($this->once())
172  ->method('getDatabaseRow')
173  ->with('pages', 321)
174  ->willReturn($parentPageRow);
175 
176  $result = $this->subject->addData($input);
177 
178  $this->assertSame($parentPageRow, $result['parentPageRow']);
179  }
180 }