‪TYPO3CMS  10.4
PageLayoutViewTest.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 Prophecy\Argument;
21 use Psr\EventDispatcher\EventDispatcherInterface;
26 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
27 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
28 
29 class ‪PageLayoutViewTest extends FunctionalTestCase
30 {
34  private ‪$subject;
35 
39  protected function ‪setUp(): void
40  {
41  parent::setUp();
42 
43  $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
44  $eventDispatcher->dispatch(Argument::cetera())->willReturnArgument(0);
45 
46  $this->setUpBackendUserFromFixture(1);
48 
49  $site = new ‪Site('test', 1, [
50  'identifier' => 'test',
51  'rootPageId' => 1,
52  'base' => '/',
53  'languages' => [
54  [
55  'languageId' => 0,
56  'locale' => '',
57  'base' => '/',
58  'title' => 'default',
59  ],
60  [
61  'languageId' => 1,
62  'locale' => '',
63  'base' => '/',
64  'title' => 'german',
65  ],
66  [
67  'languageId' => 2,
68  'locale' => '',
69  'base' => '/',
70  'title' => 'french',
71  ],
72  [
73  'languageId' => 3,
74  'locale' => '',
75  'base' => '/',
76  'title' => 'polish',
77  ],
78  ],
79  ]);
80  $this->subject = $this->getAccessibleMock(PageLayoutView::class, ['dummy'], [$eventDispatcher->reveal()]);
81  $this->subject->_set('siteLanguages', $site->getLanguages());
82  }
83 
88  {
89  $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/View/Fixtures/LanguageSelectorScenarioDefault.csv');
90 
91  $result = $this->subject->languageSelector(17);
92 
93  $matches = [];
94 
95  preg_match_all('/<option value=.+<\/option>/', $result, $matches);
96  $resultingOptions = ‪GeneralUtility::trimExplode('</option>', $matches[0][0], true);
97  self::assertCount(4, $resultingOptions);
98  // first entry is the empty option
99  self::assertStringEndsWith('german', $resultingOptions[1]);
100  self::assertStringEndsWith('french', $resultingOptions[2]);
101  self::assertStringEndsWith('polish', $resultingOptions[3]);
102  }
103 
108  {
109  $this->importCSVDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/View/Fixtures/LanguageSelectorScenarioTranslationDone.csv');
110  $result = $this->subject->languageSelector(17);
111 
112  $matches = [];
113 
114  preg_match_all('/<option value=.+<\/option>/', $result, $matches);
115  $resultingOptions = ‪GeneralUtility::trimExplode('</option>', $matches[0][0], true);
116  self::assertCount(3, $resultingOptions);
117  // first entry is the empty option
118  self::assertStringEndsWith('german', $resultingOptions[1]);
119  self::assertStringEndsWith('french', $resultingOptions[2]);
120  }
121 }
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\$subject
‪PageLayoutView AccessibleObjectInterface $subject
Definition: PageLayoutViewTest.php:33
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\setUp
‪setUp()
Definition: PageLayoutViewTest.php:38
‪TYPO3\CMS\Backend\Tests\Functional\View
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:40
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:617
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest
Definition: PageLayoutViewTest.php:30
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static string[] trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:1059
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\languageSelectorShowsAllAvailableLanguagesForTranslation
‪languageSelectorShowsAllAvailableLanguagesForTranslation()
Definition: PageLayoutViewTest.php:86
‪TYPO3\CMS\Backend\Tests\Functional\View\PageLayoutViewTest\languageSelectorDoesNotOfferLanguageIfTranslationHasBeenDoneAlready
‪languageSelectorDoesNotOfferLanguageIfTranslationHasBeenDoneAlready()
Definition: PageLayoutViewTest.php:106
‪TYPO3\CMS\Backend\View\PageLayoutView
Definition: PageLayoutView.php:61
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46