[TASK] Add more fixers for php-cs-fixer
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Database / Query / Restriction / BackendWorkspaceRestrictionTest.php
1 <?php
2 declare(strict_types=1);
3 namespace TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction;
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
18 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
19
20 class BackendWorkspaceRestrictionTest extends AbstractRestrictionTestCase
21 {
22 /**
23 * @return void
24 */
25 protected function setUp()
26 {
27 parent::setUp();
28 }
29
30 /**
31 * @test
32 */
33 public function buildExpressionAddsLiveWorkspaceWhereClause()
34 {
35 $GLOBALS['TCA']['aTable']['ctrl'] = [
36 'versioningWS' => 2,
37 ];
38 $subject = new BackendWorkspaceRestriction(0);
39 $expression = $subject->buildExpression(['aTable' => ''], $this->expressionBuilder);
40 $this->assertSame('("aTable"."t3ver_wsid" = 0) OR ("aTable"."t3ver_state" <= 0)', (string)$expression);
41 }
42
43 /**
44 * @test
45 */
46 public function buildExpressionAddsNonLiveWorkspaceWhereClause()
47 {
48 $GLOBALS['TCA']['aTable']['ctrl'] = [
49 'versioningWS' => 2,
50 ];
51 $subject = new BackendWorkspaceRestriction(42);
52 $expression = $subject->buildExpression(['aTable' => ''], $this->expressionBuilder);
53 $this->assertSame('("aTable"."t3ver_wsid" = 42) OR ("aTable"."t3ver_state" <= 0)', (string)$expression);
54 }
55
56 /**
57 * @test
58 */
59 public function buildExpressionAddsLiveWorkspaceLimitedWhereClause()
60 {
61 $GLOBALS['TCA']['aTable']['ctrl'] = [
62 'versioningWS' => 2,
63 ];
64 $subject = new BackendWorkspaceRestriction(0, false);
65 $expression = $subject->buildExpression(['aTable' => ''], $this->expressionBuilder);
66 $this->assertSame('("aTable"."t3ver_wsid" = 0) AND ("aTable"."pid" <> -1)', (string)$expression);
67 }
68
69 /**
70 * @test
71 */
72 public function buildExpressionAddsNonLiveWorkspaceLimitedWhereClause()
73 {
74 $GLOBALS['TCA']['aTable']['ctrl'] = [
75 'versioningWS' => 2,
76 ];
77 $subject = new BackendWorkspaceRestriction(42, false);
78 $expression = $subject->buildExpression(['aTable' => ''], $this->expressionBuilder);
79 $this->assertSame('("aTable"."t3ver_wsid" = 42) AND ("aTable"."pid" = -1)', (string)$expression);
80 }
81 }