[TASK] Streamline SiteLanguage related tests to be based on Site 45/63645/3
authorOliver Hader <oliver@typo3.org>
Mon, 9 Mar 2020 17:56:07 +0000 (18:56 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 9 Mar 2020 19:55:57 +0000 (20:55 +0100)
Tests making use of SiteLanguage are adjusted to have a valid parent
Site object. This way the implicit aggregate root approach of Site
is kept and hanging SiteLanguage instances are avoided.

Resolves: #90695
Releases: master, 9.5
Change-Id: I0d377f511854e3bf9acb364f8b23171007cd847d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63645
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/backend/Tests/Functional/View/PageLayoutViewTest.php
typo3/sysext/core/Tests/Functional/Routing/Aspect/PersistedAliasMapperTest.php
typo3/sysext/core/Tests/Unit/Localization/LocalesTest.php
typo3/sysext/core/Tests/Unit/Site/Entity/SiteLanguageTest.php
typo3/sysext/felogin/Tests/Unit/Controller/FrontendLoginControllerTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php
typo3/sysext/frontend/Tests/Unit/Http/RequestHandlerTest.php
typo3/sysext/frontend/Tests/Unit/Plugin/AbstractPluginTest.php

index c37dbba..141ed34 100644 (file)
@@ -20,8 +20,7 @@ use Prophecy\Argument;
 use Psr\EventDispatcher\EventDispatcherInterface;
 use TYPO3\CMS\Backend\View\PageLayoutView;
 use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\Http\Uri;
-use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
+use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
@@ -46,21 +45,39 @@ class PageLayoutViewTest extends FunctionalTestCase
         $this->setUpBackendUserFromFixture(1);
         Bootstrap::initializeLanguageObject();
 
-        $this->subject = $this->getAccessibleMock(PageLayoutView::class, ['dummy'], [$eventDispatcher->reveal()]);
-        $this->subject->_set('siteLanguages', [
-            0 => new SiteLanguage(0, '', new Uri('/'), [
-                'title' => 'default',
-            ]),
-            1 => new SiteLanguage(1, '', new Uri('/'), [
-                'title' => 'german',
-            ]),
-            2 => new SiteLanguage(2, '', new Uri('/'), [
-                'title' => 'french',
-            ]),
-            3 => new SiteLanguage(3, '', new Uri('/'), [
-                'title' => 'polish',
-            ]),
+        $site = new Site('test', 1, [
+            'identifier' => 'test',
+            'rootPageId' => 1,
+            'base' => '/',
+            'languages' => [
+                [
+                    'languageId' => 0,
+                    'locale' => '',
+                    'base' => '/',
+                    'title' => 'default',
+                ],
+                [
+                    'languageId' => 1,
+                    'locale' => '',
+                    'base' => '/',
+                    'title' => 'german',
+                ],
+                [
+                    'languageId' => 2,
+                    'locale' => '',
+                    'base' => '/',
+                    'title' => 'french',
+                ],
+                [
+                    'languageId' => 3,
+                    'locale' => '',
+                    'base' => '/',
+                    'title' => 'polish',
+                ],
+            ],
         ]);
+        $this->subject = $this->getAccessibleMock(PageLayoutView::class, ['dummy'], [$eventDispatcher->reveal()]);
+        $this->subject->_set('siteLanguages', $site->getLanguages());
     }
 
     /**
index 9224cd5..1a7c221 100644 (file)
@@ -16,8 +16,8 @@ namespace TYPO3\CMS\Core\Tests\Functional\Routing\Aspect;
  */
 
 use TYPO3\CMS\Core\Core\Bootstrap;
-use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\Routing\Aspect\PersistedAliasMapper;
+use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
@@ -59,25 +59,48 @@ class PersistedAliasMapperTest extends FunctionalTestCase
             $this->setUpDatabase();
         });
 
+        $site = new Site('acme-inc', 1000, [
+            'identifier' => 'acme-inc',
+            'rootPageId' => 1000,
+            'base' => 'https://acme.com/',
+            'languages' => [
+                [
+                    'languageId' => 3,
+                    'base' => '/es-es/',
+                    'locale' => 'es_ES.UTF-8',
+                    'fallbackType' => 'fallback',
+                    'fallbacks' => [0],
+                    'title' => 'Spanish',
+                ],
+                [
+                    'languageId' => 2,
+                    'base' => '/fr-ca/',
+                    'locale' => 'fr_CA.UTF-8',
+                    'fallbackType' => 'fallback',
+                    'fallbacks' => [1, 0],
+                    'title' => 'Franco-Canadian',
+                ],
+                [
+                    'languageId' => 1,
+                    'base' => '/fr-fr/',
+                    'locale' => 'fr_FR.UTF-8',
+                    'fallbackType' => 'fallback',
+                    'fallbacks' => [0],
+                    'French',
+                ],
+                [
+                    'languageId' => 0,
+                    'base' => 'en_US.UTF-8',
+                    'locale' => '/en-us/',
+                ],
+            ]
+        ]);
         $this->languages = [
-            'es-es' => new SiteLanguage(3, 'es_ES.UTF-8', new Uri('/es-es/'), [
-                'fallbackType' => 'fallback',
-                'fallbacks' => [0],
-                'title' => 'Spanish',
-            ]),
-            'fr-ca' => new SiteLanguage(2, 'fr_CA.UTF-8', new Uri('/fr-ca/'), [
-                'fallbackType' => 'fallback',
-                'fallbacks' => [1, 0],
-                'title' => 'Franco-Canadian',
-            ]),
-            'fr-fr' => new SiteLanguage(1, 'fr_FR.UTF-8', new Uri('/fr-fr/'), [
-                'fallbackType' => 'fallback',
-                'fallbacks' => [0],
-                'French',
-            ]),
-            'default' => new SiteLanguage(0, 'en_US.UTF-8', new Uri('/en-us/'), []),
+            'es-es' => $site->getLanguageById(3),
+            'fr-ca' => $site->getLanguageById(2),
+            'fr-fr' => $site->getLanguageById(1),
+            'default' => $site->getLanguageById(0),
         ];
-
         $this->subject = new PersistedAliasMapper(self::ASPECT_CONFIGURATION);
     }
 
index 5934448..2b35c53 100644 (file)
@@ -14,9 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\Localization\Locales;
-use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
+use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -91,8 +90,8 @@ class LocalesTest extends UnitTestCase
      */
     public function setSystemLocaleFromSiteLanguageWithoutLocaleDoesNotSetLocale(): void
     {
-        $language = new SiteLanguage(0, '', new Uri('/'), []);
-        $result = Locales::setSystemLocaleFromSiteLanguage($language);
+        $site = $this->createSiteWithDefaultLanguage('');
+        $result = Locales::setSystemLocaleFromSiteLanguage($site->getLanguageById(0));
         self::assertFalse($result);
         $currentLocale = setlocale(LC_COLLATE, 0);
         // Check that the locale was not overridden
@@ -105,8 +104,8 @@ class LocalesTest extends UnitTestCase
     public function setSystemLocaleFromSiteLanguageWithProperLocaleSetsLocale(): void
     {
         $locale = 'en_US';
-        $language = new SiteLanguage(0, $locale, new Uri('/'), []);
-        $result = Locales::setSystemLocaleFromSiteLanguage($language);
+        $site = $this->createSiteWithDefaultLanguage($locale);
+        $result = Locales::setSystemLocaleFromSiteLanguage($site->getLanguageById(0));
         self::assertTrue($result);
         $currentLocale = setlocale(LC_COLLATE, 0);
         // Check that the locale was overridden
@@ -120,11 +119,27 @@ class LocalesTest extends UnitTestCase
     public function setSystemLocaleFromSiteLanguageWithInvalidLocaleDoesNotSetLocale(): void
     {
         $locale = 'af_EUR';
-        $language = new SiteLanguage(0, $locale, new Uri('/'), []);
-        $result = Locales::setSystemLocaleFromSiteLanguage($language);
+        $site = $this->createSiteWithDefaultLanguage($locale);
+        $result = Locales::setSystemLocaleFromSiteLanguage($site->getLanguageById(0));
         self::assertFalse($result);
         $currentLocale = setlocale(LC_COLLATE, 0);
         // Check that the locale was not overridden
         self::assertEquals($this->originalLocale, $currentLocale);
     }
+
+    private function createSiteWithDefaultLanguage(string $locale): Site
+    {
+        return new Site('test', 1, [
+            'identifier' => 'test',
+            'rootPageId' => 1,
+            'base' => '/',
+            'languages' => [
+                [
+                    'languageId' => 0,
+                    'locale' => $locale,
+                    'base' => '/',
+                ],
+            ]
+        ]);
+    }
 }
index 84721da..2f83ccd 100644 (file)
@@ -16,8 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Site\Entity;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Http\Uri;
-use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
+use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class SiteLanguageTest extends UnitTestCase
@@ -66,9 +65,11 @@ class SiteLanguageTest extends UnitTestCase
     public function languageFallbackIdConversion($input, array $expected)
     {
         $configuration = [
-            'fallbacks' => $input
+            'fallbacks' => $input,
+            'locale' => 'fr',
         ];
-        $subject = new SiteLanguage(1, 'fr', new Uri('/'), $configuration);
+        $site = $this->createSiteWithLanguage($configuration);
+        $subject = $site->getLanguageById(1);
         self::assertSame($expected, $subject->getFallbackLanguageIds());
     }
 
@@ -81,14 +82,16 @@ class SiteLanguageTest extends UnitTestCase
             'navigationTitle' => 'NavTitle',
             'customValue' => 'a custom value',
             'fallbacks' => '1,2',
+            'locale' => 'de',
         ];
-        $subject = new SiteLanguage(1, 'de', new Uri('/'), $configuration);
+        $site = $this->createSiteWithLanguage($configuration);
+        $subject = $site->getLanguageById(1);
         $expected = [
             'navigationTitle' => 'NavTitle',
             'customValue' => 'a custom value',
             'fallbacks' => '1,2',
-            'languageId' => 1,
             'locale' => 'de',
+            'languageId' => 1,
             'base' => '/',
             'title' => 'Default',
             'websiteTitle' => '',
@@ -106,4 +109,22 @@ class SiteLanguageTest extends UnitTestCase
         ];
         self::assertSame($expected, $subject->toArray());
     }
+
+    private function createSiteWithLanguage(array $languageConfiguration): Site
+    {
+        return new Site('test', 1, [
+            'identifier' => 'test',
+            'rootPageId' => 1,
+            'base' => '/',
+            'languages' => [
+                array_merge(
+                    $languageConfiguration,
+                    [
+                        'languageId' => 1,
+                        'base' => '/',
+                    ]
+                )
+            ]
+        ]);
+    }
 }
index 7739dbb..e890b97 100644 (file)
@@ -17,7 +17,7 @@ namespace TYPO3\CMS\Felogin\Tests\Unit\Controller;
 
 use Prophecy\Argument;
 use TYPO3\CMS\Core\Authentication\LoginType;
-use TYPO3\CMS\Core\Http\Uri;
+use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Felogin\Controller\FrontendLoginController;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@@ -38,7 +38,20 @@ class FrontendLoginControllerTest extends UnitTestCase
 
     public function setUp(): void
     {
-        $this->language = new SiteLanguage(0, 'en_US', new Uri('/'), ['typo3Language' => 'en']);
+        $site = new Site('test', 1, [
+            'identifier' => 'test',
+            'rootPageId' => 1,
+            'base' => '/',
+            'languages' => [
+                [
+                    'languageId' => 0,
+                    'locale' => 'en_US',
+                    'typo3Language' => 'en',
+                    'base' => '/',
+                ],
+            ]
+        ]);
+        $this->language = $site->getLanguageById(0);
         parent::setUp();
     }
 
index a586aa6..b96a726 100644 (file)
@@ -28,7 +28,6 @@ use TYPO3\CMS\Core\Context\WorkspaceAspect;
 use TYPO3\CMS\Core\Core\ApplicationContext;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Domain\Repository\PageRepository;
-use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
 use TYPO3\CMS\Core\Log\Logger;
 use TYPO3\CMS\Core\Package\PackageManager;
@@ -139,6 +138,14 @@ class ContentObjectRendererTest extends UnitTestCase
     protected function setUp(): void
     {
         parent::setUp();
+
+        $site = $this->createSiteWithLanguage([
+            'base' => '/',
+            'languageId' => 2,
+            'locale' => 'en_UK',
+            'typo3Language' => 'default',
+        ]);
+
         $GLOBALS['SIM_ACCESS_TIME'] = 1534278180;
         $packageManagerMock = $this->getMockBuilder(PackageManager::class)
             ->disableOriginalConstructor()
@@ -163,7 +170,7 @@ class ContentObjectRendererTest extends UnitTestCase
         $this->frontendControllerMock->config = [];
         $this->frontendControllerMock->page = [];
         $this->frontendControllerMock->sys_page = $pageRepositoryMock;
-        $this->frontendControllerMock->_set('language', new SiteLanguage(2, 'en_UK', new Uri(), ['typo3Language' => 'default']));
+        $this->frontendControllerMock->_set('language', $site->getLanguageById(2));
         $GLOBALS['TSFE'] = $this->frontendControllerMock;
 
         $this->cacheManager = $this->prophesize(CacheManager::class);
@@ -1743,10 +1750,14 @@ class ContentObjectRendererTest extends UnitTestCase
      */
     public function getDataWithTypeSiteLanguage(): void
     {
-        $language = new SiteLanguage(1, 'de-de', new Uri('/'), [
+        $site = $this->createSiteWithLanguage([
+            'base' => '/',
+            'languageId' => 1,
+            'locale' => 'de_DE',
             'title' => 'languageTitle',
             'navigationTitle' => 'German'
         ]);
+        $language = $site->getLanguageById(1);
         $this->frontendControllerMock->_set('language', $language);
         self::assertEquals('German', $this->subject->getData('siteLanguage:navigationTitle'));
     }
@@ -6745,8 +6756,13 @@ class ContentObjectRendererTest extends UnitTestCase
      */
     public function stdWrap_langViaSiteLanguage(string $expected, string $input, array $conf, string $language): void
     {
-        $siteLanguage = new SiteLanguage(2, 'en_UK', new Uri(), ['typo3Language' => $language]);
-        $this->frontendControllerMock->_set('language', $siteLanguage);
+        $site = $this->createSiteWithLanguage([
+            'base' => '/',
+            'languageId' => 2,
+            'locale' => 'en_UK',
+            'typo3Language' => $language,
+        ]);
+        $this->frontendControllerMock->_set('language', $site->getLanguageById(2));
         self::assertSame(
             $expected,
             $this->subject->stdWrap_lang($input, $conf)
@@ -8715,4 +8731,25 @@ class ContentObjectRendererTest extends UnitTestCase
     /***************************************************************************
      * End: Mixed tests
      ***************************************************************************/
+
+    /**
+     * @param array $languageConfiguration
+     * @return Site
+     */
+    private function createSiteWithLanguage(array $languageConfiguration): Site
+    {
+        return new Site('test', 1, [
+            'identifier' => 'test',
+            'rootPageId' => 1,
+            'base' => '/',
+            'languages' => [
+                array_merge(
+                    $languageConfiguration,
+                    [
+                        'base' => '/',
+                    ]
+                )
+            ]
+        ]);
+    }
 }
index 123849e..c2f7b2e 100644 (file)
@@ -21,12 +21,10 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Http\ServerRequest;
 use TYPO3\CMS\Core\Http\ServerRequestFactory;
-use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\PageTitle\PageTitleProviderManager;
 use TYPO3\CMS\Core\Routing\PageArguments;
 use TYPO3\CMS\Core\Site\Entity\Site;
-use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -127,8 +125,12 @@ class TypoScriptFrontendControllerTest extends UnitTestCase
     public function localizationReturnsUnchangedStringIfNotLocallangLabel()
     {
         $string = StringUtility::getUniqueId();
+        $site = $this->createSiteWithDefaultLanguage([
+            'locale' => 'fr',
+            'typo3Language' => 'fr',
+        ]);
         $this->subject->page = [];
-        $this->subject->language = new SiteLanguage(0, 'fr', new Uri('/'), ['typo3Language' => 'fr']);
+        $this->subject->_set('language', $site->getLanguageById(0));
         $this->subject->_call('setOutputLanguage');
         self::assertEquals($string, $this->subject->sL($string));
     }
@@ -514,13 +516,15 @@ class TypoScriptFrontendControllerTest extends UnitTestCase
         $cacheManager->getCache('pages')->willReturn($nullCacheBackend);
         GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager->reveal());
         $GLOBALS['TYPO3_REQUEST'] = new ServerRequest('https://www.example.com/');
-        $site = new Site('test', 13, ['base' => 'https://www.example.com/']);
-        $language = new SiteLanguage(0, 'fr', new Uri('/'), ['typo3Language' => 'fr-test']);
+        $site = $this->createSiteWithDefaultLanguage([
+            'locale' => 'fr',
+            'typo3Language' => 'fr-test',
+        ]);
         // Constructor calling initPageRenderer()
         new TypoScriptFrontendController(
             new Context(),
             $site,
-            $language,
+            $site->getLanguageById(0),
             new PageArguments(13, '0', [])
         );
         // since PageRenderer is a singleton, this can be queried via the makeInstance call
@@ -537,8 +541,10 @@ class TypoScriptFrontendControllerTest extends UnitTestCase
         $cacheManager->getCache('pages')->willReturn($nullCacheBackend);
         GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager->reveal());
         $GLOBALS['TYPO3_REQUEST'] = new ServerRequest('https://www.example.com/');
-        $site = new Site('test', 13, ['base' => 'https://www.example.com/']);
-        $language = new SiteLanguage(0, 'fr', new Uri('/'), ['typo3Language' => 'fr']);
+        $site = $this->createSiteWithDefaultLanguage([
+            'locale' => 'fr',
+            'typo3Language' => 'fr',
+        ]);
         // Constructor calling setOutputLanguage()
         $subject = $this->getAccessibleMock(
             TypoScriptFrontendController::class,
@@ -546,7 +552,7 @@ class TypoScriptFrontendControllerTest extends UnitTestCase
             [
                 new Context(),
                 $site,
-                $language,
+                $site->getLanguageById(0),
                 new PageArguments(13, '0', [])
             ]
         );
@@ -554,4 +560,22 @@ class TypoScriptFrontendControllerTest extends UnitTestCase
         // since PageRenderer is a singleton, this can be queried via the makeInstance call
         self::assertEquals('fr', $languageService->lang);
     }
+
+    private function createSiteWithDefaultLanguage(array $languageConfiguration): Site
+    {
+        return new Site('test', 13, [
+            'identifier' => 'test',
+            'rootPageId' => 13,
+            'base' => 'https://www.example.com/',
+            'languages' => [
+                array_merge(
+                    $languageConfiguration,
+                    [
+                        'languageId' => 0,
+                        'base' => '/',
+                    ]
+                )
+            ]
+        ]);
+    }
 }
index ea89ba4..604677b 100644 (file)
@@ -19,9 +19,8 @@ use Prophecy\Argument;
 use Psr\EventDispatcher\EventDispatcherInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Http\ServerRequestFactory;
-use TYPO3\CMS\Core\Http\Uri;
 use TYPO3\CMS\Core\Page\PageRenderer;
-use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
+use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -233,7 +232,7 @@ class RequestHandlerTest extends UnitTestCase
             'content' => '10'
         ];
 
-        $siteLanguage = new SiteLanguage(3, 'fr_FR', new Uri(), []);
+        $siteLanguage = $this->createSiteWithLanguage()->getLanguageById(3);
         $cObj = $this->prophesize(ContentObjectRenderer::class);
         $cObj->cObjGet(Argument::cetera())->shouldBeCalled();
         $cObj->stdWrap(Argument::cetera())->willReturn($stdWrapResult);
@@ -272,7 +271,7 @@ class RequestHandlerTest extends UnitTestCase
      */
     public function generateMetaTagHtmlGeneratesCorrectTags(array $typoScript, string $stdWrapResult, array $expectedTags)
     {
-        $siteLanguage = new SiteLanguage(3, 'fr_FR', new Uri(), []);
+        $siteLanguage = $this->createSiteWithLanguage()->getLanguageById(3);
         $cObj = $this->prophesize(ContentObjectRenderer::class);
         $cObj->cObjGet(Argument::cetera())->shouldBeCalled();
         $cObj->stdWrap(Argument::cetera())->willReturn($stdWrapResult);
@@ -315,7 +314,7 @@ class RequestHandlerTest extends UnitTestCase
             'custom:key' => '',
         ];
 
-        $siteLanguage = new SiteLanguage(3, 'fr_FR', new Uri(), []);
+        $siteLanguage = $this->createSiteWithLanguage()->getLanguageById(3);
         $cObj = $this->prophesize(ContentObjectRenderer::class);
         $cObj->cObjGet(Argument::cetera())->shouldBeCalled();
         $cObj->stdWrap(Argument::cetera())->willReturn($stdWrapResult);
@@ -414,7 +413,7 @@ class RequestHandlerTest extends UnitTestCase
      */
     public function generateMultipleMetaTags(array $typoScript, string $stdWrapResult, array $expectedTags)
     {
-        $siteLanguage = new SiteLanguage(3, 'fr_FR', new Uri(), []);
+        $siteLanguage = $this->createSiteWithLanguage()->getLanguageById(3);
         $cObj = $this->prophesize(ContentObjectRenderer::class);
         $cObj->cObjGet(Argument::cetera())->shouldBeCalled();
         $cObj->stdWrap(Argument::cetera())->willReturn($stdWrapResult);
@@ -495,4 +494,20 @@ class RequestHandlerTest extends UnitTestCase
         self::assertEquals($_GET, $modifiedGetVars);
         self::assertEquals($_POST, $modifiedPostVars);
     }
+
+    private function createSiteWithLanguage(): Site
+    {
+        return new Site('test', 1, [
+            'identifier' => 'test',
+            'rootPageId' => 1,
+            'base' => '/',
+            'languages' => [
+                [
+                    'base' => '/',
+                    'languageId' => 3,
+                    'locale' => 'fr_FR',
+                ],
+            ]
+        ]);
+    }
 }
index 4d876f2..369f876 100644 (file)
@@ -16,8 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\Plugin;
  */
 
 use Prophecy\Argument;
-use TYPO3\CMS\Core\Http\Uri;
-use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
+use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@@ -51,7 +50,9 @@ class AbstractPluginTest extends UnitTestCase
 
         $tsfe = $this->prophesize(TypoScriptFrontendController::class);
         $tsfe->cObjectDepthCounter = 100;
-        $tsfe->getLanguage(Argument::cetera())->willReturn(new SiteLanguage(0, 'en_US', new Uri('/'), ['typo3Language' => 'en']));
+        $tsfe->getLanguage(Argument::cetera())->willReturn(
+            $this->createSiteWithDefaultLanguage()->getLanguageById(0)
+        );
 
         $this->abstractPlugin = new AbstractPlugin(null, $tsfe->reveal());
         $contentObjectRenderer = new ContentObjectRenderer($tsfe->reveal());
@@ -275,4 +276,21 @@ class AbstractPluginTest extends UnitTestCase
 
         unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][AbstractPlugin::class]['pi_list_browseresults']);
     }
+
+    private function createSiteWithDefaultLanguage(): Site
+    {
+        return new Site('test', 1, [
+            'identifier' => 'test',
+            'rootPageId' => 1,
+            'base' => '/',
+            'languages' => [
+                [
+                    'base' => '/',
+                    'languageId' => 0,
+                    'locale' => 'en_US',
+                    'typo3Language' => 'en'
+                ],
+            ]
+        ]);
+    }
 }