‪TYPO3CMS  9.5
AbstractRestrictionContainerTest.php
Go to the documentation of this file.
1 <?php
2 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 
22 
24 {
29  {
30  $restriction = $this->prophesize();
31  $restriction->willImplement(QueryRestrictionInterface::class);
32  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
33  $restriction->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder)
34  ->shouldBeCalled()
35  ->willReturn(new ‪CompositeExpression(CompositeExpression::TYPE_AND, ['"aTable"."pid" = 0']));
36  $restriction->isEnforced()->willReturn(true);
37 
39  $subject->add($restriction->reveal());
40  $subject->removeAll();
41 
42  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
43  $this->assertSame('"aTable"."pid" = 0', (string)$expression);
44  }
45 
50  {
51  $restriction = $this->prophesize();
52  $restriction->willImplement(QueryRestrictionInterface::class);
53  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
54  $restriction->buildExpression()->shouldNotBeCalled();
55  $restriction->isEnforced()->willReturn(true);
56 
58  $restriction = $restriction->reveal();
59  $subject->add($restriction);
60  $subject->removeByType(get_class($restriction));
61 
62  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
63  $this->assertSame('', (string)$expression);
64  }
65 
70  {
71  $restriction = $this->prophesize();
72  $restriction->willImplement(QueryRestrictionInterface::class);
73  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
74  $restriction->buildExpression()->shouldNotBeCalled();
75  $restriction->isEnforced()->willReturn(true);
76 
78  $restriction = $restriction->reveal();
79  $subject->add($restriction);
80  $subject->removeByType(get_class($restriction));
81  $subject->removeAll();
82 
83  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
84  $this->assertSame('', (string)$expression);
85  }
86 
91  {
92  $restriction = $this->prophesize();
93  $restriction->willImplement(QueryRestrictionInterface::class);
94  $restriction->buildExpression()->shouldNotBeCalled();
95 
97  $subject->add($restriction->reveal());
98  $subject->removeAll();
99 
100  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
101  $this->assertSame('', (string)$expression);
102  }
103 
108  {
109  $restriction = $this->prophesize();
110  $restriction->willImplement(QueryRestrictionInterface::class);
111  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
112  $restriction->buildExpression()->shouldNotBeCalled();
113  $restriction->isEnforced()->willReturn(false);
114 
116  $subject->add($restriction->reveal());
117  $subject->removeAll();
118 
119  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
120  $this->assertSame('', (string)$expression);
121  }
122 }
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest
Definition: AbstractRestrictionContainerTest.php:24
‪TYPO3\CMS\Core\Database\Query\Restriction\QueryRestrictionInterface
Definition: QueryRestrictionInterface.php:25
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsThatDeclareThemselvesNonStickyAreRemovedWhenRemoveAllIsCalled
‪enforceableRestrictionsThatDeclareThemselvesNonStickyAreRemovedWhenRemoveAllIsCalled()
Definition: AbstractRestrictionContainerTest.php:107
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\notEnforceableRestrictionsAreRemovedWhenRemoveAllIsCalled
‪notEnforceableRestrictionsAreRemovedWhenRemoveAllIsCalled()
Definition: AbstractRestrictionContainerTest.php:90
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsAreKeptWhenRemoveAllIsCalled
‪enforceableRestrictionsAreKeptWhenRemoveAllIsCalled()
Definition: AbstractRestrictionContainerTest.php:28
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction
Definition: AbstractRestrictionContainerTest.php:3
‪TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression
Definition: CompositeExpression.php:23
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsWillBeRemovedWhenRemovedByType
‪enforceableRestrictionsWillBeRemovedWhenRemovedByType()
Definition: AbstractRestrictionContainerTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionTestCase
Definition: AbstractRestrictionTestCase.php:26
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsWillBeRemovedWhenRemovedByTypeAndRemovedAllIsAdditionallyCalled
‪enforceableRestrictionsWillBeRemovedWhenRemovedByTypeAndRemovedAllIsAdditionallyCalled()
Definition: AbstractRestrictionContainerTest.php:69
‪TYPO3\CMS\Core\Database\Query\Restriction\EnforceableQueryRestrictionInterface
Definition: EnforceableQueryRestrictionInterface.php:25
‪TYPO3\CMS\Core\Tests\Unit\Database\Mocks\InstantiatableAbstractRestrictionContainer
Definition: InstantiatableAbstractRestrictionContainer.php:20