‪TYPO3CMS  ‪main
WorkspaceRestrictionTest.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;
22 
24 {
25  #[Test]
27  {
28  ‪$GLOBALS['TCA']['aTable']['ctrl'] = [
29  'versioningWS' => true,
30  ];
31  $subject = new ‪WorkspaceRestriction(0);
32  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
33  self::assertSame('(("aTable"."t3ver_wsid" = 0) AND ((("aTable"."t3ver_oid" = 0) OR ("aTable"."t3ver_state" = 4))))', (string)$expression);
34  }
35 
36  #[Test]
38  {
39  ‪$GLOBALS['TCA']['aTable']['ctrl'] = [
40  'versioningWS' => true,
41  ];
42  $subject = new ‪WorkspaceRestriction(42);
43  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
44  self::assertSame('(("aTable"."t3ver_wsid" IN (0, 42)) AND ((("aTable"."t3ver_oid" = 0) OR ("aTable"."t3ver_state" = 4))))', (string)$expression);
45  }
46 
47  #[Test]
49  {
50  ‪$GLOBALS['TCA']['aTable']['ctrl'] = [
51  'versioningWS' => false,
52  ];
53  $subject = new ‪WorkspaceRestriction(0);
54  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
55  self::assertSame('', (string)$expression);
56  }
57 
58  #[Test]
60  {
61  ‪$GLOBALS['TCA']['aTable']['ctrl'] = [
62  'versioningWS' => false,
63  ];
64  $subject = new ‪WorkspaceRestriction(42);
65  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
66  self::assertSame('', (string)$expression);
67  }
68 
69  #[Test]
71  {
72  ‪$GLOBALS['TCA']['aTable']['ctrl'] = [
73  'versioningWS' => true,
74  ];
75  $subject = new ‪WorkspaceRestriction(42, true);
76  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
77  self::assertSame('(("aTable"."t3ver_wsid" IN (0, 42)) AND ("t3ver_state" <> 2))', (string)$expression);
78  }
79  #[Test]
81  {
82  ‪$GLOBALS['TCA']['aTable']['ctrl'] = [
83  'versioningWS' => true,
84  ];
85  $subject = new ‪WorkspaceRestriction(0, true);
86  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
87  self::assertSame('(("aTable"."t3ver_wsid" = 0) AND ("t3ver_state" <> 2))', (string)$expression);
88  }
89 }
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\WorkspaceRestrictionTest\buildExpressionQueriesAllVersionedRecordsWithinLiveStillRemovesDeletedState
‪buildExpressionQueriesAllVersionedRecordsWithinLiveStillRemovesDeletedState()
Definition: WorkspaceRestrictionTest.php:80
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\WorkspaceRestrictionTest\buildExpressionAddsNonLiveWorkspaceWhereClause
‪buildExpressionAddsNonLiveWorkspaceWhereClause()
Definition: WorkspaceRestrictionTest.php:37
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\WorkspaceRestrictionTest\buildExpressionQueriesAllVersionedRecordsWithinAWorkspaceAsWell
‪buildExpressionQueriesAllVersionedRecordsWithinAWorkspaceAsWell()
Definition: WorkspaceRestrictionTest.php:70
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\WorkspaceRestrictionTest
Definition: WorkspaceRestrictionTest.php:24
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\WorkspaceRestrictionTest\buildExpressionAddsLiveWorkspaceWhereClause
‪buildExpressionAddsLiveWorkspaceWhereClause()
Definition: WorkspaceRestrictionTest.php:26
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction
Definition: AbstractRestrictionContainerTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\AbstractRestrictionTestCase
Definition: AbstractRestrictionTestCase.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\WorkspaceRestrictionTest\buildExpressionAddsLiveWorkspaceLimitedWhereClause
‪buildExpressionAddsLiveWorkspaceLimitedWhereClause()
Definition: WorkspaceRestrictionTest.php:48
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction\WorkspaceRestrictionTest\buildExpressionAddsNonLiveWorkspaceLimitedWhereClause
‪buildExpressionAddsNonLiveWorkspaceLimitedWhereClause()
Definition: WorkspaceRestrictionTest.php:59
‪TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction
Definition: WorkspaceRestriction.php:39