‪TYPO3CMS  ‪main
Typo3DbBackendTest.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;
32 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
35 
36 final class ‪Typo3DbBackendTest extends FunctionalTestCase
37 {
38  protected bool ‪$resetSingletonInstances = true;
39 
40  protected array ‪$testExtensionsToLoad = [
41  'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example',
42  ];
43 
44  #[Test]
46  {
47  $this->importCSVDataSet(__DIR__ . '/Fixtures/Typo3DbBackendTestImport.csv');
48  $domainObject = new ‪Tag('Tag10');
49  $typo3DbBackend = $this->get(Typo3DbBackend::class);
50  $result = $typo3DbBackend->getUidOfAlreadyPersistedValueObject($domainObject);
51  self::assertSame(10, $result);
52  }
53 
54  #[Test]
56  {
57  $this->importCSVDataSet(__DIR__ . '/Fixtures/Typo3DbBackendTestImport.csv');
58  $frontendTypoScript = new ‪FrontendTypoScript(new ‪RootNode(), [], [], []);
59  $frontendTypoScript->setSetupArray([]);
60  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest())
61  ->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_FE)
62  ->withAttribute('frontend.typoscript', $frontendTypoScript);
63 
64  $blogRepository = $this->get(BlogRepository::class);
65  $context = new ‪Context();
66  $context->setAspect('workspace', new ‪WorkspaceAspect(1));
67  $context->setAspect('language', new ‪LanguageAspect(0, 0));
68  GeneralUtility::setSingletonInstance(Context::class, $context);
69  $querySettings = new ‪Typo3QuerySettings($context, $this->get(ConfigurationManagerInterface::class));
70  $querySettings->setRespectStoragePage(false);
71  $query = $blogRepository->createQuery();
72  $query->setQuerySettings($querySettings);
73  $query->matching($query->equals('uid', 1));
74 
75  $typo3DbBackend = $this->get(Typo3DbBackend::class);
76  $objectData = $typo3DbBackend->getObjectDataByQuery($query);
77 
78  self::assertCount(1, $objectData);
79  self::assertArrayHasKey('_ORIG_uid', $objectData[0]);
80  self::assertSame(101, $objectData[0]['_ORIG_uid']);
81  self::assertSame('WorkspaceOverlay Blog1', $objectData[0]['title']);
82  }
83 }
‪TYPO3Tests\BlogExample\Domain\Model\Tag
Definition: Tag.php:26
‪TYPO3\CMS\Core\Context\WorkspaceAspect
Definition: WorkspaceAspect.php:31
‪TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbBackend
Definition: Typo3DbBackend.php:56
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\Generic\Storage\Typo3DbBackendTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: Typo3DbBackendTest.php:40
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\Generic\Storage\Typo3DbBackendTest\getObjectDataByQueryChangesUidIfInPreview
‪getObjectDataByQueryChangesUidIfInPreview()
Definition: Typo3DbBackendTest.php:55
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:28
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\Generic\Storage\Typo3DbBackendTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: Typo3DbBackendTest.php:38
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:54
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\Generic\Storage
Definition: Typo3DbBackendTest.php:18
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\Generic\Storage\Typo3DbBackendTest\uidOfAlreadyPersistedValueObjectIsDeterminedCorrectly
‪uidOfAlreadyPersistedValueObjectIsDeterminedCorrectly()
Definition: Typo3DbBackendTest.php:45
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Core\Context\LanguageAspect
Definition: LanguageAspect.php:57
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\Generic\Storage\Typo3DbBackendTest
Definition: Typo3DbBackendTest.php:37
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\TypoScript\AST\Node\RootNode
Definition: RootNode.php:26
‪TYPO3Tests\BlogExample\Domain\Repository\BlogRepository
Definition: BlogRepository.php:29
‪TYPO3\CMS\Core\TypoScript\FrontendTypoScript
Definition: FrontendTypoScript.php:30
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:43
‪TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings
Definition: Typo3QuerySettings.php:28