‪TYPO3CMS  11.5
EnableFieldsTest.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 
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
23 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
24 
29 {
30  public const ‪TABLE_Blog = 'tx_blogexample_domain_model_blog';
31 
32  protected ‪$testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
33 
37  protected function ‪setUp(): void
38  {
39  parent::setUp();
40 
41  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
42  $this->importCSVDataSet(__DIR__ . '/../Persistence/Fixtures/fe_groups.csv');
43  $this->importCSVDataSet(__DIR__ . '/../Persistence/Fixtures/fe_users.csv');
44  $this->importCSVDataSet(__DIR__ . '/../Persistence/Fixtures/blogs-with-fe_groups.csv');
45 
46  $this->‪setUpFrontendSite(1);
47  $this->setUpFrontendRootPage(1, ['typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/Frontend/JsonRenderer.typoscript']);
48  }
49 
54  {
55  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(1));
56  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections('Extbase:list()');
57  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
58  ->setTable(self::TABLE_Blog)->setField('title')->setValues('Blog1'));
59  }
60 
65  {
66  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(1), (new InternalRequestContext())->withFrontendUserId(1));
67  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections('Extbase:list()');
68  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
69  ->setTable(self::TABLE_Blog)->setField('title')->setValues('Blog1', 'Blog2'));
70  }
71 
76  {
77  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(1), (new InternalRequestContext())->withFrontendUserId(2));
78  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections('Extbase:list()');
79  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
80  ->setTable(self::TABLE_Blog)->setField('title')->setValues('Blog1', 'Blog3'));
81  }
82 
87  {
88  // first request to fill the query cache
89  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(1), (new InternalRequestContext())->withFrontendUserId(1));
90  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections('Extbase:list()');
91  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
92  ->setTable(self::TABLE_Blog)->setField('title')->setValues('Blog1', 'Blog2'));
93 
94  // second request with other frontenduser
95  $response = $this->executeFrontendSubRequest((new InternalRequest())->withPageId(1), (new InternalRequestContext())->withFrontendUserId(2));
96  $responseSections = ResponseContent::fromString((string)$response->getBody())->getSections('Extbase:list()');
97  self::assertThat($responseSections, $this->‪getRequestSectionHasRecordConstraint()
98  ->setTable(self::TABLE_Blog)->setField('title')->setValues('Blog1', 'Blog3'));
99  }
100 }
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\EnableFieldsTest\$testExtensionsToLoad
‪$testExtensionsToLoad
Definition: EnableFieldsTest.php:32
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\EnableFieldsTest\TABLE_Blog
‪const TABLE_Blog
Definition: EnableFieldsTest.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\setUpFrontendSite
‪setUpFrontendSite(int $pageId, array $additionalLanguages=[])
Definition: AbstractDataHandlerActionTestCase.php:127
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getRequestSectionHasRecordConstraint
‪HasRecordConstraint getRequestSectionHasRecordConstraint()
Definition: AbstractDataHandlerActionTestCase.php:245
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\EnableFieldsTest\onlyReturnProtectedRecordsForTheSecondUserGroup
‪onlyReturnProtectedRecordsForTheSecondUserGroup()
Definition: EnableFieldsTest.php:75
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\EnableFieldsTest\onlyReturnProtectedRecordsForTheFirstUserGroup
‪onlyReturnProtectedRecordsForTheFirstUserGroup()
Definition: EnableFieldsTest.php:64
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\EnableFieldsTest\setUp
‪setUp()
Definition: EnableFieldsTest.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:41
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\EnableFieldsTest\protectedRecordsNotFoundIfNoUserLoggedIn
‪protectedRecordsNotFoundIfNoUserLoggedIn()
Definition: EnableFieldsTest.php:53
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\EnableFieldsTest
Definition: EnableFieldsTest.php:29
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence
Definition: AddTest.php:18
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\EnableFieldsTest\onlyOwnProtectedRecordsWithQueryCacheInvolvedAreReturned
‪onlyOwnProtectedRecordsWithQueryCacheInvolvedAreReturned()
Definition: EnableFieldsTest.php:86