TYPO3 CMS  TYPO3_7-6
MessageTest.php
Go to the documentation of this file.
1 <?php
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 
21 {
26  {
27  $messageMessage = 'The message';
28  $error = new \TYPO3\CMS\Extbase\Error\Message($messageMessage, 0);
29  $this->assertEquals($messageMessage, $error->getMessage());
30  }
31 
36  {
37  $messageCode = 123456789;
38  $error = new \TYPO3\CMS\Extbase\Error\Message('', $messageCode);
39  $this->assertEquals($messageCode, $error->getCode());
40  }
41 
46  {
47  $messageArguments = ['foo', 'bar'];
48  $error = new \TYPO3\CMS\Extbase\Error\Message('', 1, $messageArguments);
49  $this->assertEquals($messageArguments, $error->getArguments());
50  }
51 
56  {
57  $messageTitle = 'Title';
58  $error = new \TYPO3\CMS\Extbase\Error\Message('', 1, [], $messageTitle);
59  $this->assertEquals($messageTitle, $error->getTitle());
60  }
61 
66  {
67  $error = new \TYPO3\CMS\Extbase\Error\Message('Message', 1);
68  $this->assertEquals('Message', $error->render());
69  }
70 
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 
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 }