‪TYPO3CMS  10.4
DatabaseUniqueUidNewRowTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪DatabaseUniqueUidNewRowTest extends UnitTestCase
25 {
29  protected ‪$subject;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->subject = new ‪DatabaseUniqueUidNewRow();
35  }
36 
41  {
42  $input = [
43  'command' => 'edit',
44  'databaseRow' => [
45  'uid' => 42,
46  ],
47  ];
48  self::assertSame($input, $this->subject->addData($input));
49  }
50 
54  public function ‪addDataKeepsGivenUidIfAlreadySet()
55  {
56  $input = [
57  'command' => 'new',
58  'databaseRow' => [
59  'uid' => 'NEW1234',
60  ],
61  ];
62  $expected = $input;
63  self::assertEquals($expected, $this->subject->addData($input));
64  }
65 
70  {
71  $input = [
72  'command' => 'new',
73  'databaseRow' => [
74  'uid' => 'FOO',
75  ],
76  ];
77  $this->expectException(\InvalidArgumentException::class);
78  $this->expectExceptionCode(1437991120);
79  $this->subject->addData($input);
80  }
81 
85  public function ‪addDataSetsUniqueId()
86  {
87  $input = [
88  'command' => 'new',
89  'databaseRow' => [],
90  ];
91  $result = $this->subject->addData($input);
92  $result = substr($result['databaseRow']['uid'], 0, 3);
93  self::assertSame('NEW', $result);
94  }
95 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\setUp
‪setUp()
Definition: DatabaseUniqueUidNewRowTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\$subject
‪DatabaseUniqueUidNewRow $subject
Definition: DatabaseUniqueUidNewRowTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\addDataKeepsGivenUidIfAlreadySet
‪addDataKeepsGivenUidIfAlreadySet()
Definition: DatabaseUniqueUidNewRowTest.php:53
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\addDataThrowsExceptionIfUidIsAlreadySetButDoesNotStartWithNewKeyword
‪addDataThrowsExceptionIfUidIsAlreadySetButDoesNotStartWithNewKeyword()
Definition: DatabaseUniqueUidNewRowTest.php:68
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest
Definition: DatabaseUniqueUidNewRowTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\addDataReturnSameDataIfCommandIsEdit
‪addDataReturnSameDataIfCommandIsEdit()
Definition: DatabaseUniqueUidNewRowTest.php:39
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseUniqueUidNewRow
Definition: DatabaseUniqueUidNewRow.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\addDataSetsUniqueId
‪addDataSetsUniqueId()
Definition: DatabaseUniqueUidNewRowTest.php:84
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18