[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Error / MessageTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Error;
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 /**
18 * Test case
19 */
20 class MessageTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
21 {
22 /**
23 * @test
24 */
25 public function theConstructorSetsTheMessageMessageCorrectly()
26 {
27 $messageMessage = 'The message';
28 $error = new \TYPO3\CMS\Extbase\Error\Message($messageMessage, 0);
29 $this->assertEquals($messageMessage, $error->getMessage());
30 }
31
32 /**
33 * @test
34 */
35 public function theConstructorSetsTheMessageCodeCorrectly()
36 {
37 $messageCode = 123456789;
38 $error = new \TYPO3\CMS\Extbase\Error\Message('', $messageCode);
39 $this->assertEquals($messageCode, $error->getCode());
40 }
41
42 /**
43 * @test
44 */
45 public function theConstructorSetsTheMessageArgumentsCorrectly()
46 {
47 $messageArguments = ['foo', 'bar'];
48 $error = new \TYPO3\CMS\Extbase\Error\Message('', 1, $messageArguments);
49 $this->assertEquals($messageArguments, $error->getArguments());
50 }
51
52 /**
53 * @test
54 */
55 public function theConstructorSetsTheMessageTitleCorrectly()
56 {
57 $messageTitle = 'Title';
58 $error = new \TYPO3\CMS\Extbase\Error\Message('', 1, [], $messageTitle);
59 $this->assertEquals($messageTitle, $error->getTitle());
60 }
61
62 /**
63 * @test
64 */
65 public function renderRendersCorrectlyWithoutArguments()
66 {
67 $error = new \TYPO3\CMS\Extbase\Error\Message('Message', 1);
68 $this->assertEquals('Message', $error->render());
69 }
70
71 /**
72 * @test
73 */
74 public function renderRendersCorrectlyWithArguments()
75 {
76 $error = new \TYPO3\CMS\Extbase\Error\Message('Foo is %s and Bar is %s', 1, ['baz', 'qux']);
77 $this->assertEquals('Foo is baz and Bar is qux', $error->render());
78 }
79
80 /**
81 * @test
82 */
83 public function toStringCallsRender()
84 {
85 $error = new \TYPO3\CMS\Extbase\Error\Message('Foo is %s and Bar is %s', 1, ['baz', 'qux']);
86 $this->assertEquals('Foo is baz and Bar is qux', $error);
87 }
88 }