‪TYPO3CMS  10.4
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 
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪CaseContentObjectTest extends UnitTestCase
30 {
34  protected ‪$resetSingletonInstances = true;
35 
39  protected ‪$subject;
40 
44  protected function ‪setUp(): void
45  {
46  parent::setUp();
48  $tsfe = $this->getMockBuilder(TypoScriptFrontendController::class)
49  ->setMethods(['dummy'])
50  ->disableOriginalConstructor()
51  ->getMock();
52 
53  $contentObjectRenderer = new ‪ContentObjectRenderer($tsfe);
54  $contentObjectRenderer->setContentObjectClassMap([
55  'CASE' => CaseContentObject::class,
56  'TEXT' => TextContentObject::class,
57  ]);
58  $this->subject = new ‪CaseContentObject($contentObjectRenderer);
59  }
60 
65  {
66  $conf = [
67  'key' => 'not existing'
68  ];
69  self::assertSame('', $this->subject->render($conf));
70  }
71 
76  {
77  $conf = [
78  'key' => 'not existing',
79  'default' => 'TEXT',
80  'default.' => [
81  'value' => 'expected value'
82  ],
83  ];
84  self::assertSame('expected value', $this->subject->render($conf));
85  }
86 }
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: CaseContentObjectTest.php:33
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\setUp
‪setUp()
Definition: CaseContentObjectTest.php:42
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\$subject
‪CaseContentObject PHPUnit Framework MockObject MockObject $subject
Definition: CaseContentObjectTest.php:37
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\renderReturnsContentFromDefaultObjectIfKeyDoesNotExist
‪renderReturnsContentFromDefaultObjectIfKeyDoesNotExist()
Definition: CaseContentObjectTest.php:73
‪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:30
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:98
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\CaseContentObjectTest\renderReturnsEmptyStringIfNoKeyMatchesAndIfNoDefaultObjectIsSet
‪renderReturnsEmptyStringIfNoKeyMatchesAndIfNoDefaultObjectIsSet()
Definition: CaseContentObjectTest.php:62
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:97
‪TYPO3\CMS\Frontend\ContentObject\TextContentObject
Definition: TextContentObject.php:22