TYPO3  7.6
SpacelessViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.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  * */
15 
20 {
27  public function testRender($input, $expected)
28  {
29  $instance = new SpacelessViewHelper();
30  $instance->setRenderChildrenClosure(function () use ($input) { return $input; });
31  $instance->setRenderingContext($this->getMock(RenderingContextInterface::class));
32  $instance->setArguments(array());
33  $this->assertEquals($expected, $instance->render());
34  }
35 
42  public function testRenderStatic($input, $expected)
43  {
44  $context = $this->getMock(RenderingContextInterface::class);
45  $this->assertEquals($expected, SpacelessViewHelper::renderStatic(array(), function () use ($input) { return $input; }, $context));
46  }
47 
51  public function getRenderStaticData()
52  {
53  return array(
54  'extra whitespace between tags' => array('<div>foo</div> <div>bar</div>', '<div>foo</div><div>bar</div>'),
55  'whitespace preserved in text node' => array(PHP_EOL . '<div>' . PHP_EOL . 'foo</div>', '<div>' . PHP_EOL . 'foo</div>'),
56  'whitespace removed from non-text node' => array(PHP_EOL . '<div>' . PHP_EOL . '<div>foo</div></div>', '<div><div>foo</div></div>')
57  );
58  }
59 }