‪TYPO3CMS  9.5
CaseContentObjectTest.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\Unit\UnitTestCase;
24 
28 class ‪CaseContentObjectTest extends UnitTestCase
29 {
33  protected ‪$resetSingletonInstances = true;
34 
38  protected ‪$subject;
39 
43  protected function ‪setUp(): void
44  {
46  $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)
47  ->setMethods(['dummy'])
48  ->disableOriginalConstructor()
49  ->getMock();
50 
51  $contentObjectRenderer = new ‪ContentObjectRenderer($tsfe);
52  $contentObjectRenderer->setContentObjectClassMap([
53  'CASE' => CaseContentObject::class,
54  'TEXT' => TextContentObject::class,
55  ]);
56  $this->subject = new ‪CaseContentObject($contentObjectRenderer);
57  }
58 
63  {
64  $conf = [
65  'key' => 'not existing'
66  ];
67  $this->assertSame('', $this->subject->render($conf));
68  }
69 
74  {
75  $conf = [
76  'key' => 'not existing',
77  'default' => 'TEXT',
78  'default.' => [
79  'value' => 'expected value'
80  ],
81  ];
82  $this->assertSame('expected value', $this->subject->render($conf));
83  }
84 }
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: CaseContentObjectTest.php:32
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\setUp
‪setUp()
Definition: CaseContentObjectTest.php:41
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\$subject
‪CaseContentObject PHPUnit_Framework_MockObject_MockObject $subject
Definition: CaseContentObjectTest.php:36
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\renderReturnsContentFromDefaultObjectIfKeyDoesNotExist
‪renderReturnsContentFromDefaultObjectIfKeyDoesNotExist()
Definition: CaseContentObjectTest.php:71
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject
Definition: CaseContentObjectTest.php:4
‪TYPO3\CMS\Frontend\ContentObject\CaseContentObject
Definition: CaseContentObject.php:21
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest
Definition: CaseContentObjectTest.php:29
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:97
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\renderReturnsEmptyStringIfNoKeyMatchesAndIfNoDefaultObjectIsSet
‪renderReturnsEmptyStringIfNoKeyMatchesAndIfNoDefaultObjectIsSet()
Definition: CaseContentObjectTest.php:60
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:91
‪TYPO3\CMS\Frontend\ContentObject\TextContentObject
Definition: TextContentObject.php:21