TYPO3 CMS  TYPO3_8-7
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 
22 class DatabaseUniqueUidNewRowTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
23 {
27  protected $subject;
28 
29  protected function setUp()
30  {
31  $this->subject = new DatabaseUniqueUidNewRow();
32  }
33 
38  {
39  $input = [
40  'command' => 'edit',
41  'databaseRow' => [
42  'uid' => 42,
43  ],
44  ];
45  $this->assertSame($input, $this->subject->addData($input));
46  }
47 
52  {
53  $input = [
54  'command' => 'new',
55  'databaseRow' => [
56  'uid' => 'NEW1234',
57  ],
58  ];
59  $expected = $input;
60  $this->assertEquals($expected, $this->subject->addData($input));
61  }
62 
67  {
68  $input = [
69  'command' => 'new',
70  'databaseRow' => [
71  'uid' => 'FOO',
72  ],
73  ];
74  $this->expectException(\InvalidArgumentException::class);
75  $this->expectExceptionCode(1437991120);
76  $this->subject->addData($input);
77  }
78 
82  public function addDataSetsUniqeId()
83  {
84  $input = [
85  'command' => 'new',
86  'databaseRow' => [],
87  ];
88  $result = $this->subject->addData($input);
89  $result = substr($result['databaseRow']['uid'], 0, 3);
90  $this->assertSame('NEW', $result);
91  }
92 }