[BUGFIX] Show correct label for IRRE records
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / FormDataProvider / DatabasePageLanguageOverlayRowsTest.php
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\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
19 use TYPO3\CMS\Backend\Form\FormDataProvider\DatabasePageLanguageOverlayRows;
20 use TYPO3\CMS\Core\Database\DatabaseConnection;
21 use TYPO3\CMS\Core\Tests\UnitTestCase;
22
23 /**
24 * Test case
25 */
26 class DatabasePageLanguageOverlayRowsTest extends UnitTestCase
27 {
28 /**
29 * @var DatabasePageLanguageOverlayRows
30 */
31 protected $subject;
32
33 /**
34 * @var DatabaseConnection | ObjectProphecy
35 */
36 protected $dbProphecy;
37
38 protected function setUp()
39 {
40 $this->dbProphecy = $this->prophesize(DatabaseConnection::class);
41 $GLOBALS['TYPO3_DB'] = $this->dbProphecy->reveal();
42 $GLOBALS['TCA']['pages_language_overlay'] = array();
43
44 $this->subject = new DatabasePageLanguageOverlayRows();
45 }
46
47 /**
48 * @test
49 */
50 public function addDataThrowsExceptionOnDatabaseError()
51 {
52 $this->dbProphecy->exec_SELECTgetRows(Argument::cetera())->willReturn(null);
53 $this->dbProphecy->sql_error(Argument::cetera())->willReturn(null);
54 $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1440777705);
55 $this->subject->addData(['effectivePid' => 1]);
56 }
57
58 /**
59 * @test
60 */
61 public function addDataSetsPageLanguageOverlayRows()
62 {
63 $input = [
64 'effectivePid' => '23',
65 ];
66 $expected = $input;
67 $expected['pageLanguageOverlayRows'] = [
68 0 => [
69 'uid' => '1',
70 'pid' => '42',
71 'sys_language_uid' => '2',
72 ],
73 ];
74 $this->dbProphecy->exec_SELECTgetRows('*', 'pages_language_overlay', 'pid=23')
75 ->shouldBeCalled()
76 ->willReturn($expected['pageLanguageOverlayRows']);
77 $this->assertSame($expected, $this->subject->addData($input));
78 }
79 }