[FEATURE] Support literal strings in boolean arguments
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / Core / Parser / SyntaxTree / NumericNodeTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\SyntaxTree;
3
4 /* *
5 * This script belongs to the TYPO3 Flow package "Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 /**
15 * Testcase for NumericNode
16 *
17 */
18 class NumericNodeTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
19
20 /**
21 * @test
22 */
23 public function renderReturnsProperIntegerGivenInConstructor() {
24 $string = '1';
25 $node = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NumericNode($string);
26 $this->assertEquals($node->evaluate($this->getMock('TYPO3\CMS\Fluid\Core\Rendering\RenderingContext')), 1, 'The rendered value of a numeric node does not match the string given in the constructor.');
27 }
28
29 /**
30 * @test
31 */
32 public function renderReturnsProperFloatGivenInConstructor() {
33 $string = '1.1';
34 $node = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NumericNode($string);
35 $this->assertEquals($node->evaluate($this->getMock('TYPO3\CMS\Fluid\Core\Rendering\RenderingContext')), 1.1, 'The rendered value of a numeric node does not match the string given in the constructor.');
36 }
37
38 /**
39 * @test
40 * @expectedException \TYPO3\CMS\Fluid\Core\Parser\Exception
41 */
42 public function constructorThrowsExceptionIfNoNumericGiven() {
43 new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NumericNode('foo');
44 }
45
46 /**
47 * @test
48 * @expectedException \TYPO3\CMS\Fluid\Core\Parser\Exception
49 */
50 public function addChildNodeThrowsException() {
51 $node = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NumericNode('1');
52 $node->addChildNode(clone $node);
53 }
54 }
55 ?>