‪TYPO3CMS  11.5
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 
20 use Prophecy\PhpUnit\ProphecyTrait;
25 
27 {
28  use ProphecyTrait;
29 
34  {
35  $restriction = $this->prophesize();
36  $restriction->willImplement(QueryRestrictionInterface::class);
37  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
38  $restriction->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder)
39  ->shouldBeCalled()
40  ->willReturn(‪CompositeExpression::and('"aTable"."pid" = 0'));
41  $restriction->isEnforced()->willReturn(true);
42 
44  $subject->add($restriction->reveal());
45  $subject->removeAll();
46 
47  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
48  self::assertSame('"aTable"."pid" = 0', (string)$expression);
49  }
50 
55  {
56  $restriction = $this->prophesize();
57  $restriction->willImplement(QueryRestrictionInterface::class);
58  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
59  $restriction->buildExpression()->shouldNotBeCalled();
60  $restriction->isEnforced()->willReturn(true);
61 
63  $restriction = $restriction->reveal();
64  $subject->add($restriction);
65  $subject->removeByType(get_class($restriction));
66 
67  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
68  self::assertSame('', (string)$expression);
69  }
70 
75  {
76  $restriction = $this->prophesize();
77  $restriction->willImplement(QueryRestrictionInterface::class);
78  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
79  $restriction->buildExpression()->shouldNotBeCalled();
80  $restriction->isEnforced()->willReturn(true);
81 
83  $restriction = $restriction->reveal();
84  $subject->add($restriction);
85  $subject->removeByType(get_class($restriction));
86  $subject->removeAll();
87 
88  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
89  self::assertSame('', (string)$expression);
90  }
91 
96  {
97  $restriction = $this->prophesize();
98  $restriction->willImplement(QueryRestrictionInterface::class);
99  $restriction->buildExpression()->shouldNotBeCalled();
100 
102  $subject->add($restriction->reveal());
103  $subject->removeAll();
104 
105  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
106  self::assertSame('', (string)$expression);
107  }
108 
113  {
114  $restriction = $this->prophesize();
115  $restriction->willImplement(QueryRestrictionInterface::class);
116  $restriction->willImplement(EnforceableQueryRestrictionInterface::class);
117  $restriction->buildExpression()->shouldNotBeCalled();
118  $restriction->isEnforced()->willReturn(false);
119 
121  $subject->add($restriction->reveal());
122  $subject->removeAll();
123 
124  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
125  self::assertSame('', (string)$expression);
126  }
127 }
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest
Definition: AbstractRestrictionContainerTest.php:27
‪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:111
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\notEnforceableRestrictionsAreRemovedWhenRemoveAllIsCalled
‪notEnforceableRestrictionsAreRemovedWhenRemoveAllIsCalled()
Definition: AbstractRestrictionContainerTest.php:94
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsAreKeptWhenRemoveAllIsCalled
‪enforceableRestrictionsAreKeptWhenRemoveAllIsCalled()
Definition: AbstractRestrictionContainerTest.php:32
‪TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression\and
‪static and($part=null,... $parts)
Definition: CompositeExpression.php:96
‪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:53
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionTestCase
Definition: AbstractRestrictionTestCase.php:29
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionContainerTest\enforceableRestrictionsWillBeRemovedWhenRemovedByTypeAndRemovedAllIsAdditionallyCalled
‪enforceableRestrictionsWillBeRemovedWhenRemovedByTypeAndRemovedAllIsAdditionallyCalled()
Definition: AbstractRestrictionContainerTest.php:73
‪TYPO3\CMS\Core\Database\Query\Restriction\EnforceableQueryRestrictionInterface
Definition: EnforceableQueryRestrictionInterface.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Mocks\InstantiatableAbstractRestrictionContainer
Definition: InstantiatableAbstractRestrictionContainer.php:22