‪TYPO3CMS  10.4
RecordHistoryStoreTest.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 
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 
24 class ‪RecordHistoryStoreTest extends FunctionalTestCase
25 {
29  private ‪$subject;
30 
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  $this->subject = new ‪RecordHistoryStore();
38  }
39 
40  protected function ‪getRecordCountByCorrelationId(‪CorrelationId $correlationId): int
41  {
42  $queryBuilder = $this->getConnectionPool()->getQueryBuilderForTable('sys_history');
43  return (int)$queryBuilder
44  ->count('uid')
45  ->from('sys_history')
46  ->where($queryBuilder->expr()->eq('correlation_id', $queryBuilder->createNamedParameter((string)$correlationId)))
47  ->execute()
48  ->fetchColumn(0);
49  }
50 
54  public function ‪addRecordAddsARecordToTheDatabase(): void
55  {
56  $correlationId = ‪CorrelationId::forSubject('092a640c-bd8c-490d-b993-ed4bcef1a1f2');
57  self::assertSame(0, $this->‪getRecordCountByCorrelationId($correlationId));
58  $this->subject->addRecord('foo', 1, [], $correlationId);
59  self::assertSame(1, $this->‪getRecordCountByCorrelationId($correlationId));
60  }
61 
65  public function ‪modifyRecordAddsARecordToTheDatabase(): void
66  {
67  $correlationId = ‪CorrelationId::forSubject('058f117c-5e21-4222-b308-085fc1113604');
68  self::assertSame(0, $this->‪getRecordCountByCorrelationId($correlationId));
69  $this->subject->modifyRecord('foo', 1, [], $correlationId);
70  self::assertSame(1, $this->‪getRecordCountByCorrelationId($correlationId));
71  }
72 
76  public function ‪deleteRecordAddsARecordToTheDatabase(): void
77  {
78  $correlationId = ‪CorrelationId::forSubject('e1a2ea91-fe2f-4a01-b50b-5c2924a27568');
79  self::assertSame(0, $this->‪getRecordCountByCorrelationId($correlationId));
80  $this->subject->deleteRecord('foo', 1, $correlationId);
81  self::assertSame(1, $this->‪getRecordCountByCorrelationId($correlationId));
82  }
83 
87  public function ‪undeleteRecordAddsARecordToTheDatabase(): void
88  {
89  $correlationId = ‪CorrelationId::forSubject('ab902256-56f2-43bd-b857-f7a0b974e9db');
90  self::assertSame(0, $this->‪getRecordCountByCorrelationId($correlationId));
91  $this->subject->undeleteRecord('foo', 1, $correlationId);
92  self::assertSame(1, $this->‪getRecordCountByCorrelationId($correlationId));
93  }
94 
98  public function ‪moveRecordAddsARecordToTheDatabase(): void
99  {
100  $correlationId = ‪CorrelationId::forSubject('9d806d3a-1d7a-4e62-816f-9fa1a1b3fe5b');
101  self::assertSame(0, $this->‪getRecordCountByCorrelationId($correlationId));
102  $this->subject->moveRecord('foo', 1, [], $correlationId);
103  self::assertSame(1, $this->‪getRecordCountByCorrelationId($correlationId));
104  }
105 }
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest\moveRecordAddsARecordToTheDatabase
‪moveRecordAddsARecordToTheDatabase()
Definition: RecordHistoryStoreTest.php:97
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest
Definition: RecordHistoryStoreTest.php:25
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest\modifyRecordAddsARecordToTheDatabase
‪modifyRecordAddsARecordToTheDatabase()
Definition: RecordHistoryStoreTest.php:64
‪TYPO3\CMS\Backend\Tests\Functional\History
Definition: RecordHistoryStoreTest.php:18
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest\addRecordAddsARecordToTheDatabase
‪addRecordAddsARecordToTheDatabase()
Definition: RecordHistoryStoreTest.php:53
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest\undeleteRecordAddsARecordToTheDatabase
‪undeleteRecordAddsARecordToTheDatabase()
Definition: RecordHistoryStoreTest.php:86
‪TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore
Definition: RecordHistoryStore.php:31
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest\$subject
‪RecordHistoryStore $subject
Definition: RecordHistoryStoreTest.php:28
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest\deleteRecordAddsARecordToTheDatabase
‪deleteRecordAddsARecordToTheDatabase()
Definition: RecordHistoryStoreTest.php:75
‪TYPO3\CMS\Core\DataHandling\Model\CorrelationId
Definition: CorrelationId.php:29
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest\getRecordCountByCorrelationId
‪getRecordCountByCorrelationId(CorrelationId $correlationId)
Definition: RecordHistoryStoreTest.php:39
‪TYPO3\CMS\Backend\Tests\Functional\History\RecordHistoryStoreTest\setUp
‪setUp()
Definition: RecordHistoryStoreTest.php:33
‪TYPO3\CMS\Core\DataHandling\Model\CorrelationId\forSubject
‪static forSubject(string $subject, string ... $aspects)
Definition: CorrelationId.php:64