‪TYPO3CMS  ‪main
ParentChildTranslationTest.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 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
25 final class ‪ParentChildTranslationTest extends FunctionalTestCase
26 {
27  protected array ‪$testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/parent_child_translation'];
28 
29  protected function ‪setUp(): void
30  {
31  parent::setUp();
32 
33  $this->importCSVDataSet(__DIR__ . '/Fixtures/parentChildTranslationExampleData.csv');
34  }
35 
36  #[Test]
38  {
39  $query = $this->get(MainRepository::class)->createQuery();
40  $results = $query->execute();
41 
42  self::assertCount(2, $results);
43 
44  $children = [];
45  foreach ($results as $main) {
46  $children[] = $main->getChild()->getTitle();
47  $children[] = $main->getSqueeze()[0]->getChild()->getTitle();
48  }
49 
50  self::assertSame(
51  [
52  'Child 1 EN',
53  'Child 1 EN',
54  'Child 2 EN',
55  'Child 3 EN',
56  ],
57  $children
58  );
59  }
60 
61  #[Test]
63  {
64  $query = $this->get(MainRepository::class)->createQuery();
65  $querySettings = $query->getQuerySettings();
66  $querySettings->setStoragePageIds([1]);
67  $querySettings->setRespectSysLanguage(true);
68  $querySettings->setLanguageAspect(new ‪LanguageAspect(1, 1, ‪LanguageAspect::OVERLAYS_OFF));
69 
70  $results = $query->execute();
71 
72  self::assertCount(2, $results);
73 
74  $children = [];
75  foreach ($results as $main) {
76  $children[] = $main->getChild()->getTitle();
77  $children[] = $main->getSqueeze()[0]->getChild()->getTitle();
78  }
79 
80  self::assertSame(
81  [
82  'Kind 1 DE',
83  'Kind 1 DE',
84  'Kind 2 DE',
85  'Kind 3 DE',
86  ],
87  $children
88  );
89  }
90 }
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\ParentChildTranslationTest\localizesChildrenOfAllLanguageElementToTranslation
‪localizesChildrenOfAllLanguageElementToTranslation()
Definition: ParentChildTranslationTest.php:62
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\ParentChildTranslationTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: ParentChildTranslationTest.php:27
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence
Definition: AddTest.php:18
‪TYPO3\CMS\Core\Context\LanguageAspect
Definition: LanguageAspect.php:57
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\ParentChildTranslationTest
Definition: ParentChildTranslationTest.php:26
‪TYPO3Tests\ParentChildTranslation\Domain\Repository\MainRepository
Definition: MainRepository.php:31
‪TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_OFF
‪const OVERLAYS_OFF
Definition: LanguageAspect.php:74
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\ParentChildTranslationTest\localizeChildrenOfAllLanguageElementToDefaultLanguage
‪localizeChildrenOfAllLanguageElementToDefaultLanguage()
Definition: ParentChildTranslationTest.php:37
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\ParentChildTranslationTest\setUp
‪setUp()
Definition: ParentChildTranslationTest.php:29