‪TYPO3CMS  10.4
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 
25 
27 {
32  {
33  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
34  $subject = new ‪LimitToTablesRestrictionContainer();
35  $subject->addForTables(new ‪HiddenRestriction(), ['bt']);
36  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
37 
38  self::assertSame('"bt"."hidden" = 0', (string)$expression);
39  }
40 
45  {
46  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
47  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
48  $subject = new ‪LimitToTablesRestrictionContainer();
49  $subject->addForTables(new ‪DefaultRestrictionContainer(), ['bt']);
50  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
51 
52  self::assertSame('("bt"."deleted" = 0) AND ("bt"."hidden" = 0)', (string)$expression);
53  }
54 
59  {
60  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
61  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
62  $subject = new ‪LimitToTablesRestrictionContainer();
63  $subject->addForTables(new ‪DefaultRestrictionContainer(), ['bt']);
64  $subject->removeByType(DeletedRestriction::class);
65  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
66 
67  self::assertSame('"bt"."hidden" = 0', (string)$expression);
68  }
69 
74  {
75  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
76  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
77  $subject = new ‪LimitToTablesRestrictionContainer();
78  $containerProphecy = $this->prophesize(QueryRestrictionContainerInterface::class);
79  $containerProphecy->removeByType(DeletedRestriction::class)->shouldBeCalled();
80  $containerProphecy->buildExpression(['bt' => 'bTable'], $this->expressionBuilder)->willReturn($this->expressionBuilder->andX([]))->shouldBeCalled();
81  $subject->addForTables($containerProphecy->reveal(), ['bt']);
82  $subject->removeByType(DeletedRestriction::class);
83  $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
84  }
85 }
‪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:58
‪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:31
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionTestCase
Definition: AbstractRestrictionTestCase.php:28
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest\buildExpressionAddsRestrictionsOfDefaultRestrictionContainerOnlyToGivenAlias
‪buildExpressionAddsRestrictionsOfDefaultRestrictionContainerOnlyToGivenAlias()
Definition: LimitToTablesRestrictionContainerTest.php:44
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest
Definition: LimitToTablesRestrictionContainerTest.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest\removeByTypeRemovesRestrictionsByTypeAlsoFromAnyRestrictionContainer
‪removeByTypeRemovesRestrictionsByTypeAlsoFromAnyRestrictionContainer()
Definition: LimitToTablesRestrictionContainerTest.php:73
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:28
‪TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer
Definition: DefaultRestrictionContainer.php:24