‪TYPO3CMS  ‪main
LimitToTablesRestrictionContainerTest.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;
26 
28 {
29  #[Test]
31  {
32  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
33  $subject = new ‪LimitToTablesRestrictionContainer();
34  $subject->addForTables(new ‪HiddenRestriction(), ['bt']);
35  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
36 
37  self::assertSame('"bt"."hidden" = 0', (string)$expression);
38  }
39 
40  #[Test]
42  {
43  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
44  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
45  $subject = new ‪LimitToTablesRestrictionContainer();
46  $subject->addForTables(new ‪DefaultRestrictionContainer(), ['bt']);
47  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
48 
49  self::assertSame('(("bt"."deleted" = 0) AND ("bt"."hidden" = 0))', (string)$expression);
50  }
51 
52  #[Test]
54  {
55  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
56  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
57  $subject = new ‪LimitToTablesRestrictionContainer();
58  $subject->addForTables(new ‪DefaultRestrictionContainer(), ['bt']);
59  $subject->removeByType(DeletedRestriction::class);
60  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
61 
62  self::assertSame('"bt"."hidden" = 0', (string)$expression);
63  }
64 
65  #[Test]
67  {
68  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
69  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
70  $subject = new ‪LimitToTablesRestrictionContainer();
71  $containerMock = $this->createMock(QueryRestrictionContainerInterface::class);
72  $containerMock->expects(self::atLeastOnce())->method('removeByType')->with(DeletedRestriction::class);
73  $containerMock->expects(self::atLeastOnce())->method('buildExpression')->with(['bt' => 'bTable'], $this->expressionBuilder)
74  ->willReturn($this->expressionBuilder->and(...[]));
75  $subject->addForTables($containerMock, ['bt']);
76  $subject->removeByType(DeletedRestriction::class);
77  $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
78  }
79 }
‪TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction
Definition: HiddenRestriction.php:27
‪TYPO3\CMS\Core\Database\Query\Restriction\LimitToTablesRestrictionContainer
Definition: LimitToTablesRestrictionContainer.php:28
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest\removeByTypeRemovesRestrictionsByTypeAlsoFromDefaultRestrictionContainer
‪removeByTypeRemovesRestrictionsByTypeAlsoFromDefaultRestrictionContainer()
Definition: LimitToTablesRestrictionContainerTest.php:53
‪TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionContainerInterface
Definition: QueryRestrictionContainerInterface.php:25
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction
Definition: AbstractRestrictionContainerTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest\buildExpressionAddsRestrictionsOnlyToGivenAlias
‪buildExpressionAddsRestrictionsOnlyToGivenAlias()
Definition: LimitToTablesRestrictionContainerTest.php:30
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionTestCase
Definition: AbstractRestrictionTestCase.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest\buildExpressionAddsRestrictionsOfDefaultRestrictionContainerOnlyToGivenAlias
‪buildExpressionAddsRestrictionsOfDefaultRestrictionContainerOnlyToGivenAlias()
Definition: LimitToTablesRestrictionContainerTest.php:41
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest
Definition: LimitToTablesRestrictionContainerTest.php:28
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest\removeByTypeRemovesRestrictionsByTypeAlsoFromAnyRestrictionContainer
‪removeByTypeRemovesRestrictionsByTypeAlsoFromAnyRestrictionContainer()
Definition: LimitToTablesRestrictionContainerTest.php:66
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:28
‪TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer
Definition: DefaultRestrictionContainer.php:24