‪TYPO3CMS  9.5
DatabaseUniqueUidNewRowTest.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 
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪DatabaseUniqueUidNewRowTest extends UnitTestCase
24 {
28  protected ‪$subject;
29 
30  protected function ‪setUp()
31  {
32  $this->subject = new ‪DatabaseUniqueUidNewRow();
33  }
34 
39  {
40  $input = [
41  'command' => 'edit',
42  'databaseRow' => [
43  'uid' => 42,
44  ],
45  ];
46  $this->assertSame($input, $this->subject->addData($input));
47  }
48 
52  public function ‪addDataKeepsGivenUidIfAlreadySet()
53  {
54  $input = [
55  'command' => 'new',
56  'databaseRow' => [
57  'uid' => 'NEW1234',
58  ],
59  ];
60  $expected = $input;
61  $this->assertEquals($expected, $this->subject->addData($input));
62  }
63 
68  {
69  $input = [
70  'command' => 'new',
71  'databaseRow' => [
72  'uid' => 'FOO',
73  ],
74  ];
75  $this->expectException(\InvalidArgumentException::class);
76  $this->expectExceptionCode(1437991120);
77  $this->subject->addData($input);
78  }
79 
83  public function ‪addDataSetsUniqeId()
84  {
85  $input = [
86  'command' => 'new',
87  'databaseRow' => [],
88  ];
89  $result = $this->subject->addData($input);
90  $result = substr($result['databaseRow']['uid'], 0, 3);
91  $this->assertSame('NEW', $result);
92  }
93 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\setUp
‪setUp()
Definition: DatabaseUniqueUidNewRowTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\$subject
‪DatabaseUniqueUidNewRow $subject
Definition: DatabaseUniqueUidNewRowTest.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\addDataKeepsGivenUidIfAlreadySet
‪addDataKeepsGivenUidIfAlreadySet()
Definition: DatabaseUniqueUidNewRowTest.php:51
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\addDataThrowsExceptionIfUidIsAlreadySetButDoesNotStartWithNewKeyword
‪addDataThrowsExceptionIfUidIsAlreadySetButDoesNotStartWithNewKeyword()
Definition: DatabaseUniqueUidNewRowTest.php:66
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\addDataSetsUniqeId
‪addDataSetsUniqeId()
Definition: DatabaseUniqueUidNewRowTest.php:82
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest
Definition: DatabaseUniqueUidNewRowTest.php:24
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseUniqueUidNewRowTest\addDataReturnSameDataIfCommandIsEdit
‪addDataReturnSameDataIfCommandIsEdit()
Definition: DatabaseUniqueUidNewRowTest.php:37
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseUniqueUidNewRow
Definition: DatabaseUniqueUidNewRow.php:24
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:3