‪TYPO3CMS  11.5
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 Prophecy\PhpUnit\ProphecyTrait;
26 
28 {
29  use ProphecyTrait;
30 
35  {
36  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
37  $subject = new ‪LimitToTablesRestrictionContainer();
38  $subject->addForTables(new ‪HiddenRestriction(), ['bt']);
39  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
40 
41  self::assertSame('"bt"."hidden" = 0', (string)$expression);
42  }
43 
48  {
49  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
50  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
51  $subject = new ‪LimitToTablesRestrictionContainer();
52  $subject->addForTables(new ‪DefaultRestrictionContainer(), ['bt']);
53  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
54 
55  self::assertSame('("bt"."deleted" = 0) AND ("bt"."hidden" = 0)', (string)$expression);
56  }
57 
62  {
63  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
64  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
65  $subject = new ‪LimitToTablesRestrictionContainer();
66  $subject->addForTables(new ‪DefaultRestrictionContainer(), ['bt']);
67  $subject->removeByType(DeletedRestriction::class);
68  $expression = $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
69 
70  self::assertSame('"bt"."hidden" = 0', (string)$expression);
71  }
72 
77  {
78  ‪$GLOBALS['TCA']['bTable']['ctrl']['enablecolumns']['disabled'] = 'hidden';
79  ‪$GLOBALS['TCA']['bTable']['ctrl']['delete'] = 'deleted';
80  $subject = new ‪LimitToTablesRestrictionContainer();
81  $containerProphecy = $this->prophesize(QueryRestrictionContainerInterface::class);
82  $containerProphecy->removeByType(DeletedRestriction::class)->shouldBeCalled();
83  $containerProphecy->buildExpression(['bt' => 'bTable'], $this->expressionBuilder)->willReturn($this->expressionBuilder->andX([]))->shouldBeCalled();
84  $subject->addForTables($containerProphecy->reveal(), ['bt']);
85  $subject->removeByType(DeletedRestriction::class);
86  $subject->buildExpression(['aTable' => 'aTable', 'bTable' => 'bTable', 'bt' => 'bTable'], $this->expressionBuilder);
87  }
88 }
‪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:60
‪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:33
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionTestCase
Definition: AbstractRestrictionTestCase.php:29
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\LimitToTablesRestrictionContainerTest\buildExpressionAddsRestrictionsOfDefaultRestrictionContainerOnlyToGivenAlias
‪buildExpressionAddsRestrictionsOfDefaultRestrictionContainerOnlyToGivenAlias()
Definition: LimitToTablesRestrictionContainerTest.php:46
‪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:75
‪$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