‪TYPO3CMS  11.5
CaseContentObjectTest.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;
21 use Psr\Http\Message\ServerRequestInterface;
23 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪CaseContentObjectTest extends UnitTestCase
32 {
33  use ProphecyTrait;
34 
38  protected ‪$resetSingletonInstances = true;
39 
44 
48  protected function ‪setUp(): void
49  {
50  parent::setUp();
51  $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)
52  ->addMethods(['dummy'])
53  ->disableOriginalConstructor()
54  ->getMock();
55 
56  $contentObjectRenderer = new ContentObjectRenderer($tsfe);
57  $contentObjectRenderer->setRequest($this->prophesize(ServerRequestInterface::class)->reveal());
58  $contentObjectRenderer->setContentObjectClassMap([
59  'CASE' => CaseContentObject::class,
60  'TEXT' => TextContentObject::class,
61  ]);
62  $this->subject = new ‪CaseContentObject($contentObjectRenderer);
63  }
64 
69  {
70  $conf = [
71  'key' => 'not existing',
72  ];
73  self::assertSame('', $this->subject->render($conf));
74  }
75 
80  {
81  $conf = [
82  'key' => 'not existing',
83  'default' => 'TEXT',
84  'default.' => [
85  'value' => 'expected value',
86  ],
87  ];
88  self::assertSame('expected value', $this->subject->render($conf));
89  }
90 }
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: CaseContentObjectTest.php:36
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\setUp
‪setUp()
Definition: CaseContentObjectTest.php:46
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\$subject
‪CaseContentObject $subject
Definition: CaseContentObjectTest.php:41
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\renderReturnsContentFromDefaultObjectIfKeyDoesNotExist
‪renderReturnsContentFromDefaultObjectIfKeyDoesNotExist()
Definition: CaseContentObjectTest.php:77
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject
Definition: CaseContentObjectTest.php:18
‪TYPO3\CMS\Frontend\ContentObject\CaseContentObject
Definition: CaseContentObject.php:22
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest
Definition: CaseContentObjectTest.php:32
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:104
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\renderReturnsEmptyStringIfNoKeyMatchesAndIfNoDefaultObjectIsSet
‪renderReturnsEmptyStringIfNoKeyMatchesAndIfNoDefaultObjectIsSet()
Definition: CaseContentObjectTest.php:66
‪TYPO3\CMS\Frontend\ContentObject\TextContentObject
Definition: TextContentObject.php:22