‪TYPO3CMS  11.5
SiteProcessorTest.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\PhpUnit\ProphecyTrait;
22 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
30 class ‪SiteProcessorTest extends UnitTestCase
31 {
32  use ProphecyTrait;
33 
37  public function ‪siteIsRetrieved(): void
38  {
39  $processorConfiguration = ['as' => 'variable'];
40  $mockedContentObjectRenderer = $this->getAccessibleMock(ContentObjectRenderer::class, ['stdWrapValue'], [], '', false);
41  $mockedContentObjectRenderer->method('stdWrapValue')->with('as', $processorConfiguration, 'site')->willReturn('variable');
42 
43  $site = new ‪Site('site123', 123, []);
44  $tsfeProphecy = $this->prophesize(TypoScriptFrontendController::class);
45  $tsfeProphecy->getSite()->willReturn($site);
46 
47  $subject = new ‪SiteProcessor($tsfeProphecy->reveal());
48  $processedData = $subject->process($mockedContentObjectRenderer, [], $processorConfiguration, []);
49  self::assertEquals($site, $processedData['variable']);
50  }
51 
55  public function ‪nullIsProvidedIfSiteCouldNotBeRetrieved(): void
56  {
57  $processorConfiguration = ['as' => 'variable'];
58  $mockedContentObjectRenderer = $this->getAccessibleMock(ContentObjectRenderer::class, ['stdWrapValue'], [], '', false);
59  $mockedContentObjectRenderer->method('stdWrapValue')->with('as', $processorConfiguration, 'site')->willReturn('variable');
60 
61  $subject = new ‪SiteProcessor();
62  $processedData = $subject->process($mockedContentObjectRenderer, [], $processorConfiguration, []);
63 
64  self::assertNull($processedData['variable']);
65  }
66 }
‪TYPO3\CMS\Frontend\DataProcessing\SiteProcessor
Definition: SiteProcessor.php:38
‪TYPO3\CMS\Frontend\Tests\Unit\DataProcessing\SiteProcessorTest
Definition: SiteProcessorTest.php:31
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:42
‪TYPO3\CMS\Frontend\Tests\Unit\DataProcessing\SiteProcessorTest\siteIsRetrieved
‪siteIsRetrieved()
Definition: SiteProcessorTest.php:36
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:104
‪TYPO3\CMS\Frontend\Tests\Unit\DataProcessing
Definition: FlexFormProcessorTest.php:5
‪TYPO3\CMS\Frontend\Tests\Unit\DataProcessing\SiteProcessorTest\nullIsProvidedIfSiteCouldNotBeRetrieved
‪nullIsProvidedIfSiteCouldNotBeRetrieved()
Definition: SiteProcessorTest.php:54