[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Messaging / Renderer / BootstrapRendererTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Messaging;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Messaging\FlashMessage;
18 use TYPO3\CMS\Core\Messaging\Renderer\BootstrapRenderer;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase;
21
22 /**
23 * Test case
24 */
25 class BootstrapRendererTest extends UnitTestCase
26 {
27 /**
28 * @test
29 */
30 public function renderCreatesCorrectOutputForFlashMessage()
31 {
32 $rendererClass = GeneralUtility::makeInstance(BootstrapRenderer::class);
33 $flashMessage = GeneralUtility::makeInstance(
34 FlashMessage::class,
35 'messageBody',
36 'messageTitle',
37 FlashMessage::NOTICE
38 );
39 $output = $rendererClass->render([$flashMessage]);
40 $this->assertContains('<div class="typo3-messages">', $output);
41 $this->assertContains('<div class="alert alert-notice">', $output);
42 $this->assertContains('<div class="media-body">', $output);
43 $this->assertContains('<h4 class="alert-title">messageTitle</h4>', $output);
44 $this->assertContains('<p class="alert-message">messageBody</p>', $output);
45 }
46
47 /**
48 * @test
49 */
50 public function renderCreatesCorrectOutputForFlashMessageWithoutTitle()
51 {
52 $rendererClass = GeneralUtility::makeInstance(BootstrapRenderer::class);
53 $flashMessage = GeneralUtility::makeInstance(
54 FlashMessage::class,
55 'messageBody',
56 '',
57 FlashMessage::NOTICE
58 );
59 $output = $rendererClass->render([$flashMessage]);
60 $this->assertContains('<div class="typo3-messages">', $output);
61 $this->assertContains('<div class="alert alert-notice">', $output);
62 $this->assertContains('<div class="media-body">', $output);
63 $this->assertContains('<p class="alert-message">messageBody</p>', $output);
64 $this->assertNotContains('<h4 class="alert-title">messageTitle</h4>', $output);
65 }
66 }