TYPO3 CMS  TYPO3_7-6
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 
22 
27 {
31  protected $subject;
32 
36  protected $dbProphecy;
37 
38  protected function setUp()
39  {
40  $this->subject = new DatabaseParentPageRow();
41 
42  $this->dbProphecy = $this->prophesize(DatabaseConnection::class);
43  $GLOBALS['TYPO3_DB'] = $this->dbProphecy->reveal();
44  }
45 
50  {
51  $input = [
52  'tableName' => 'tt_content',
53  'command' => 'new',
54  'vanillaUid' => -10,
55  ];
56  $parentPageRow = [
57  'uid' => 123,
58  'pid' => 321
59  ];
60  $this->dbProphecy->quoteStr(Argument::cetera())->willReturnArgument(0);
61  $this->dbProphecy->exec_SELECTgetSingleRow('*', $input['tableName'], 'uid=10')->willReturn(['pid' => 123]);
62  $this->dbProphecy->exec_SELECTgetSingleRow('*', 'pages', 'uid=123')->willReturn($parentPageRow);
63 
64  $result = $this->subject->addData($input);
65 
66  $this->assertSame($parentPageRow, $result['parentPageRow']);
67  }
68 
73  {
74  $input = [
75  'tableName' => 'tt_content',
76  'command' => 'new',
77  'vanillaUid' => -10,
78  ];
79  $neigborRow = [
80  'uid' => 10,
81  'pid' => 321
82  ];
83  $this->dbProphecy->quoteStr(Argument::cetera())->willReturnArgument(0);
84  $this->dbProphecy->exec_SELECTgetSingleRow('*', $input['tableName'], 'uid=10')->willReturn($neigborRow);
85  $this->dbProphecy->exec_SELECTgetSingleRow('*', 'pages', 'uid=321')->willReturn([]);
86 
87  $result = $this->subject->addData($input);
88 
89  $this->assertSame($neigborRow, $result['neighborRow']);
90  }
91 
96  {
97  $input = [
98  'tableName' => 'tt_content',
99  'command' => 'new',
100  'vanillaUid' => -10,
101  ];
102  $this->dbProphecy->quoteStr(Argument::cetera())->willReturnArgument(0);
103  $this->dbProphecy->exec_SELECTgetSingleRow('*', $input['tableName'], 'uid=10')->willReturn(['pid' => 0]);
104 
105  $result = $this->subject->addData($input);
106 
107  $this->assertNull($result['parentPageRow']);
108  }
109 
114  {
115  $input = [
116  'tableName' => 'tt_content',
117  'command' => 'new',
118  'vanillaUid' => 123,
119  ];
120  $parentPageRow = [
121  'uid' => 123,
122  'pid' => 321
123  ];
124  $this->dbProphecy->quoteStr(Argument::cetera())->willReturnArgument(0);
125  $this->dbProphecy->exec_SELECTgetSingleRow('*', 'pages', 'uid=123')->willReturn($parentPageRow);
126 
127  $result = $this->subject->addData($input);
128 
129  $this->assertSame($parentPageRow, $result['parentPageRow']);
130  }
131 
136  {
137  $input = [
138  'tableName' => 'tt_content',
139  'command' => 'edit',
140  'vanillaUid' => 123,
141  'databaseRow' => [
142  'uid' => 123,
143  'pid' => 321
144  ],
145  ];
146  $parentPageRow = [
147  'uid' => 321,
148  'pid' => 456
149  ];
150  $this->dbProphecy->quoteStr(Argument::cetera())->willReturnArgument(0);
151  $this->dbProphecy->exec_SELECTgetSingleRow('*', 'pages', 'uid=321')->willReturn($parentPageRow);
152 
153  $result = $this->subject->addData($input);
154 
155  $this->assertSame($parentPageRow, $result['parentPageRow']);
156  }
157 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']