‪TYPO3CMS  ‪main
RelationHandlerTest.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 
20 use PHPUnit\Framework\Attributes\Test;
21 use PHPUnit\Framework\MockObject\MockObject;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 final class ‪RelationHandlerTest extends UnitTestCase
26 {
27  protected ‪RelationHandler&MockObject ‪$subject;
28 
29  protected function ‪setUp(): void
30  {
31  parent::setUp();
32  $this->subject = $this->getMockBuilder(RelationHandler::class)
33  ->onlyMethods(['purgeVersionedIds', 'purgeLiveVersionedIds'])
34  ->getMock();
35  }
36 
37  #[Test]
39  {
40  ‪$GLOBALS['TCA']['sys_category']['ctrl']['versioningWS'] = false;
41 
42  $this->subject->tableArray = [
43  'sys_category' => [1, 2, 3],
44  ];
45 
46  self::assertFalse($this->subject->purgeItemArray(0));
47  }
48 
49  #[Test]
51  {
52  ‪$GLOBALS['TCA']['sys_category']['ctrl']['versioningWS'] = true;
53 
54  $this->subject->tableArray = [
55  'sys_category' => [1, 2, 3],
56  ];
57 
58  $this->subject->expects(self::once())
59  ->method('purgeVersionedIds')
60  ->with('sys_category', [1, 2, 3])
61  ->willReturn([2]);
62 
63  self::assertTrue($this->subject->purgeItemArray(0));
64  }
65 }
‪TYPO3\CMS\Core\Database\RelationHandler
Definition: RelationHandler.php:36
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest\purgeItemArrayReturnsFalseIfVersioningForTableIsDisabled
‪purgeItemArrayReturnsFalseIfVersioningForTableIsDisabled()
Definition: RelationHandlerTest.php:38
‪TYPO3\CMS\Core\Tests\Unit\Database
Definition: ConnectionPoolTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest\setUp
‪setUp()
Definition: RelationHandlerTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest
Definition: RelationHandlerTest.php:26
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest\$subject
‪RelationHandler &MockObject $subject
Definition: RelationHandlerTest.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest\purgeItemArrayReturnsTrueIfItemsHaveBeenPurged
‪purgeItemArrayReturnsTrueIfItemsHaveBeenPurged()
Definition: RelationHandlerTest.php:50