TYPO3 CMS  TYPO3_8-7
FrontendWorkspaceRestrictionTest.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 
20 
22 {
25  protected function setUp()
26  {
27  parent::setUp();
28  }
29 
34  {
35  $GLOBALS['TCA'] = [
36  'aTable' => [
37  'ctrl' => [
38  'versioningWS' => 2,
39  ],
40  ]
41  ];
42 
43  $pageRepository = $this->createMock(PageRepository::class);
44  $pageRepository->versioningPreview = false;
45 
46  $subject = new FrontendWorkspaceRestriction(0);
47  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
48  $this->assertSame('("aTable"."t3ver_state" <= 0) AND ("aTable"."pid" <> -1)', (string)$expression);
49  }
50 
55  {
56  $GLOBALS['TCA'] = [
57  'aTable' => [
58  'ctrl' => [
59  'versioningWS' => 2,
60  ],
61  ]
62  ];
63 
64  $pageRepository = $this->createMock(PageRepository::class);
65  $pageRepository->versioningPreview = true;
66  $pageRepository->versioningWorkspaceId = 42;
67 
68  $subject = new FrontendWorkspaceRestriction(42, true);
69  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
70  $this->assertSame('(("aTable"."t3ver_wsid" = 0) OR ("aTable"."t3ver_wsid" = 42)) AND ("aTable"."pid" <> -1)', (string)$expression);
71  }
72 
77  {
78  $GLOBALS['TCA'] = [
79  'aTable' => [
80  'ctrl' => [
81  'versioningWS' => 2,
82  ],
83  ]
84  ];
85 
86  $pageRepository = $this->createMock(PageRepository::class);
87  $pageRepository->versioningPreview = true;
88  $pageRepository->versioningWorkspaceId = 42;
89 
90  $subject = new FrontendWorkspaceRestriction(42, true, false);
91  $expression = $subject->buildExpression(['aTable' => 'aTable'], $this->expressionBuilder);
92  $this->assertSame('("aTable"."t3ver_wsid" = 0) OR ("aTable"."t3ver_wsid" = 42)', (string)$expression);
93  }
94 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']