‪TYPO3CMS  11.5
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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪RelationHandlerTest extends UnitTestCase
27 {
31  protected ‪$subject;
32 
33  protected function ‪setUp(): void
34  {
35  parent::setUp();
36  $this->subject = $this->getMockBuilder(RelationHandler::class)
37  ->onlyMethods(['purgeVersionedIds', 'purgeLiveVersionedIds'])
38  ->getMock();
39  }
40 
45  {
46  ‪$GLOBALS['TCA']['sys_category']['ctrl']['versioningWS'] = false;
47 
48  $this->subject->tableArray = [
49  'sys_category' => [1, 2, 3],
50  ];
51 
52  self::assertFalse($this->subject->purgeItemArray(0));
53  }
54 
59  {
60  ‪$GLOBALS['TCA']['sys_category']['ctrl']['versioningWS'] = true;
61 
62  $this->subject->tableArray = [
63  'sys_category' => [1, 2, 3],
64  ];
65 
66  $this->subject->expects(self::once())
67  ->method('purgeVersionedIds')
68  ->with('sys_category', [1, 2, 3])
69  ->willReturn([2]);
70 
71  self::assertTrue($this->subject->purgeItemArray(0));
72  }
73 }
‪TYPO3\CMS\Core\Database\RelationHandler
Definition: RelationHandler.php:37
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest\purgeItemArrayReturnsFalseIfVersioningForTableIsDisabled
‪purgeItemArrayReturnsFalseIfVersioningForTableIsDisabled()
Definition: RelationHandlerTest.php:43
‪TYPO3\CMS\Core\Tests\Unit\Database
Definition: ConnectionPoolTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest\setUp
‪setUp()
Definition: RelationHandlerTest.php:32
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest
Definition: RelationHandlerTest.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest\$subject
‪RelationHandler $subject
Definition: RelationHandlerTest.php:30
‪TYPO3\CMS\Core\Tests\Unit\Database\RelationHandlerTest\purgeItemArrayReturnsTrueIfItemsHaveBeenPurged
‪purgeItemArrayReturnsTrueIfItemsHaveBeenPurged()
Definition: RelationHandlerTest.php:57