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