‪TYPO3CMS  10.4
AbstractRestrictionContainerTest.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 
24 
26 {
31  {
32  $restriction = $this->prophesize();
33  $restriction->willImplement(QueryRestrictionInterface::class);
34  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
35  $restriction->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder)
36  ->shouldBeCalled()
37  ->willReturn(new ‪CompositeExpression(CompositeExpression::TYPE_AND, ['"aTable"."pid" = 0']));
38  $restriction->isEnforced()->willReturn(true);
39 
41  $subject->add($restriction->reveal());
42  $subject->removeAll();
43 
44  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
45  self::assertSame('"aTable"."pid" = 0', (string)$expression);
46  }
47 
52  {
53  $restriction = $this->prophesize();
54  $restriction->willImplement(QueryRestrictionInterface::class);
55  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
56  $restriction->buildExpression()->shouldNotBeCalled();
57  $restriction->isEnforced()->willReturn(true);
58 
60  $restriction = $restriction->reveal();
61  $subject->add($restriction);
62  $subject->removeByType(get_class($restriction));
63 
64  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
65  self::assertSame('', (string)$expression);
66  }
67 
72  {
73  $restriction = $this->prophesize();
74  $restriction->willImplement(QueryRestrictionInterface::class);
75  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
76  $restriction->buildExpression()->shouldNotBeCalled();
77  $restriction->isEnforced()->willReturn(true);
78 
80  $restriction = $restriction->reveal();
81  $subject->add($restriction);
82  $subject->removeByType(get_class($restriction));
83  $subject->removeAll();
84 
85  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
86  self::assertSame('', (string)$expression);
87  }
88 
93  {
94  $restriction = $this->prophesize();
95  $restriction->willImplement(QueryRestrictionInterface::class);
96  $restriction->buildExpression()->shouldNotBeCalled();
97 
99  $subject->add($restriction->reveal());
100  $subject->removeAll();
101 
102  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
103  self::assertSame('', (string)$expression);
104  }
105 
110  {
111  $restriction = $this->prophesize();
112  $restriction->willImplement(QueryRestrictionInterface::class);
113  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
114  $restriction->buildExpression()->shouldNotBeCalled();
115  $restriction->isEnforced()->willReturn(false);
116 
118  $subject->add($restriction->reveal());
119  $subject->removeAll();
120 
121  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
122  self::assertSame('', (string)$expression);
123  }
124 }
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest
Definition: AbstractRestrictionContainerTest.php:26
‪TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionInterface
Definition: QueryRestrictionInterface.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsThatDeclareThemselvesNonStickyAreRemovedWhenRemoveAllIsCalled
‪enforceableRestrictionsThatDeclareThemselvesNonStickyAreRemovedWhenRemoveAllIsCalled()
Definition: AbstractRestrictionContainerTest.php:109
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\notEnforceableRestrictionsAreRemovedWhenRemoveAllIsCalled
‪notEnforceableRestrictionsAreRemovedWhenRemoveAllIsCalled()
Definition: AbstractRestrictionContainerTest.php:92
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsAreKeptWhenRemoveAllIsCalled
‪enforceableRestrictionsAreKeptWhenRemoveAllIsCalled()
Definition: AbstractRestrictionContainerTest.php:30
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction
Definition: AbstractRestrictionContainerTest.php:18
‪TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression
Definition: CompositeExpression.php:25
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsWillBeRemovedWhenRemovedByType
‪enforceableRestrictionsWillBeRemovedWhenRemovedByType()
Definition: AbstractRestrictionContainerTest.php:51
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionTestCase
Definition: AbstractRestrictionTestCase.php:28
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsWillBeRemovedWhenRemovedByTypeAndRemovedAllIsAdditionallyCalled
‪enforceableRestrictionsWillBeRemovedWhenRemovedByTypeAndRemovedAllIsAdditionallyCalled()
Definition: AbstractRestrictionContainerTest.php:71
‪TYPO3\CMS\Core\Database\Query\Restriction\EnforceableQueryRestrictionInterface
Definition: EnforceableQueryRestrictionInterface.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Mocks\InstantiatableAbstractRestrictionContainer
Definition: InstantiatableAbstractRestrictionContainer.php:21