‪TYPO3CMS  9.5
PageLayoutViewTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
23 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 class ‪PageLayoutViewTest extends FunctionalTestCase
27 {
31  private ‪$subject;
32 
36  protected function ‪setUp(): void
37  {
38  parent::setUp();
39 
40  $this->setUpBackendUserFromFixture(1);
42 
43  $site = new ‪Site('test', 1, [
44  'identifier' => 'test',
45  'rootPageId' => 1,
46  'base' => '/',
47  'languages' => [
48  [
49  'languageId' => 0,
50  'locale' => '',
51  'base' => '/',
52  'title' => 'default',
53  ],
54  [
55  'languageId' => 1,
56  'locale' => '',
57  'base' => '/',
58  'title' => 'german',
59  ],
60  [
61  'languageId' => 2,
62  'locale' => '',
63  'base' => '/',
64  'title' => 'french',
65  ],
66  [
67  'languageId' => 3,
68  'locale' => '',
69  'base' => '/',
70  'title' => 'polish',
71  ],
72  ],
73  ]);
74  $this->subject = $this->getAccessibleMock(PageLayoutView::class, ['dummy']);
75  $this->subject->_set('siteLanguages', $site->getLanguages());
76  }
77 
82  {
83  $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/View/Fixtures/LanguageSelectorScenarioDefault.csv');
84 
85  $result = $this->subject->languageSelector(17);
86 
87  $matches = [];
88 
89  preg_match_all('/<option value=.+<\/option>/', $result, $matches);
90  $resultingOptions = GeneralUtility::trimExplode('</option>', $matches[0][0], true);
91  $this->assertCount(4, $resultingOptions);
92  // first entry is the empty option
93  $this->assertStringEndsWith('german', $resultingOptions[1]);
94  $this->assertStringEndsWith('french', $resultingOptions[2]);
95  $this->assertStringEndsWith('polish', $resultingOptions[3]);
96  }
97 
102  {
103  $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/View/Fixtures/LanguageSelectorScenarioTranslationDone.csv');
104  $result = $this->subject->languageSelector(17);
105 
106  $matches = [];
107 
108  preg_match_all('/<option value=.+<\/option>/', $result, $matches);
109  $resultingOptions = GeneralUtility::trimExplode('</option>', $matches[0][0], true);
110  $this->assertCount(3, $resultingOptions);
111  // first entry is the empty option
112  $this->assertStringEndsWith('german', $resultingOptions[1]);
113  $this->assertStringEndsWith('french', $resultingOptions[2]);
114  }
115 }
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\$subject
‪PageLayoutView AccessibleObjectInterface $subject
Definition: PageLayoutViewTest.php:30
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\setUp
‪setUp()
Definition: PageLayoutViewTest.php:35
‪TYPO3\CMS\Backend\Tests\Functional\View
Definition: PageLayoutViewTest.php:4
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:39
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest
Definition: PageLayoutViewTest.php:27
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\languageSelectorShowsAllAvailableLanguagesForTranslation
‪languageSelectorShowsAllAvailableLanguagesForTranslation()
Definition: PageLayoutViewTest.php:80
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\languageSelectorDoesNotOfferLanguageIfTranslationHasBeenDoneAlready
‪languageSelectorDoesNotOfferLanguageIfTranslationHasBeenDoneAlready()
Definition: PageLayoutViewTest.php:100
‪TYPO3\CMS\Backend\View\PageLayoutView
Definition: PageLayoutView.php:61
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static Bootstrap null initializeLanguageObject()
Definition: Bootstrap.php:986