‪TYPO3CMS  ‪main
ModifyDefaultConstraintsForDatabaseQueryEventTest.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 PHPUnit\Framework\Attributes\Test;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
29 {
30  #[Test]
31  public function ‪gettersReturnInitializedObjects(): void
32  {
33  $table = 'a_table';
34  $tableAlias = 'table_alias';
35  $expressionBuilder = new ‪ExpressionBuilder($this->createMock(Connection::class));
36  $constraints = [new ‪CompositeExpression('foo')];
37  $enableFieldsToIgnore = ['a_field' => true];
38  $context = new ‪Context();
39 
41  $table,
42  $tableAlias,
43  $expressionBuilder,
44  $constraints,
45  $enableFieldsToIgnore,
46  $context
47  );
48 
49  self::assertEquals($table, $event->getTable());
50  self::assertEquals($tableAlias, $event->getTableAlias());
51  self::assertEquals($expressionBuilder, $event->getExpressionBuilder());
52  self::assertEquals($constraints, $event->getConstraints());
53  self::assertEquals(array_keys($enableFieldsToIgnore), $event->getEnableFieldsToIgnore());
54  self::assertEquals($context, $event->getContext());
55  }
56 
57  #[Test]
59  {
61  '',
62  '',
63  new ‪ExpressionBuilder($this->createMock(Connection::class)),
64  [],
65  [],
66  new ‪Context()
67  );
68 
69  self::assertEmpty($event->getConstraints());
70 
71  $constraints = [new ‪CompositeExpression('foo')];
72  $event->setConstraints($constraints);
73  self::assertEquals($constraints, $event->getConstraints());
74 
75  // unset constraints again
76  $event->setConstraints([]);
77  self::assertEmpty($event->getConstraints());
78  }
79 }
‪TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder
Definition: ExpressionBuilder.php:40
‪TYPO3\CMS\Core\Tests\Unit\Domain\Event\ModifyDefaultConstraintsForDatabaseQueryEventTest\gettersReturnInitializedObjects
‪gettersReturnInitializedObjects()
Definition: ModifyDefaultConstraintsForDatabaseQueryEventTest.php:31
‪TYPO3\CMS\Core\Tests\Unit\Domain\Event\ModifyDefaultConstraintsForDatabaseQueryEventTest
Definition: ModifyDefaultConstraintsForDatabaseQueryEventTest.php:29
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:54
‪TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression
Definition: CompositeExpression.php:27
‪TYPO3\CMS\Core\Tests\Unit\Domain\Event\ModifyDefaultConstraintsForDatabaseQueryEventTest\setConstraintsAllowsModifiyingDefaultConstraints
‪setConstraintsAllowsModifiyingDefaultConstraints()
Definition: ModifyDefaultConstraintsForDatabaseQueryEventTest.php:58
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:41
‪TYPO3\CMS\Core\Domain\Event\ModifyDefaultConstraintsForDatabaseQueryEvent
Definition: ModifyDefaultConstraintsForDatabaseQueryEvent.php:34
‪TYPO3\CMS\Core\Tests\Unit\Domain\Event
Definition: BeforePageIsRetrievedEventTest.php:18