[BUGFIX] Show correct label for IRRE records
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / FormDataProvider / DatabaseUniqueUidNewRowTest.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 TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseUniqueUidNewRow;
18 use TYPO3\CMS\Core\Tests\UnitTestCase;
19
20 /**
21 * Test case
22 */
23 class DatabaseUniqueUidNewRowTest extends UnitTestCase
24 {
25 /**
26 * @var DatabaseUniqueUidNewRow
27 */
28 protected $subject;
29
30 protected function setUp()
31 {
32 $this->subject = new DatabaseUniqueUidNewRow();
33 }
34
35 /**
36 * @test
37 */
38 public function addDataReturnSameDataIfCommandIsEdit()
39 {
40 $input = [
41 'command' => 'edit',
42 'databaseRow' => [
43 'uid' => 42,
44 ],
45 ];
46 $this->assertSame($input, $this->subject->addData($input));
47 }
48
49 /**
50 * @test
51 */
52 public function addDataThrowsExceptionIfUidIsAlreadySet()
53 {
54 $input = [
55 'command' => 'new',
56 'databaseRow' => [
57 'uid' => 42,
58 ],
59 ];
60
61 $this->setExpectedException(\InvalidArgumentException::class, $this->anything(), 1437991120);
62
63 $this->subject->addData($input);
64 }
65
66 /**
67 * @test
68 */
69 public function addDataSetsUniqeId()
70 {
71 $input = [
72 'command' => 'new',
73 'databaseRow' => [],
74 ];
75 $result = $this->subject->addData($input);
76 $result = substr($result['databaseRow']['uid'], 0, 3);
77 $this->assertSame('NEW', $result);
78 }
79 }