TYPO3  7.6
Format/CaseViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Format;
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 General Public License, either version 3 of the *
9  * License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
16 
21 {
25  protected $subject;
26 
27  protected function setUp()
28  {
29  parent::setUp();
30  $this->subject = $this->getMock(CaseViewHelper::class, array('renderChildren'));
31  $this->injectDependenciesIntoViewHelper($this->subject);
32  }
33 
38  {
39  $this->subject->expects($this->once())->method('renderChildren');
40  $this->subject->render();
41  }
42 
47  {
48  $this->subject->expects($this->never())->method('renderChildren');
49  $this->subject->render('');
50  $this->subject->render(0);
51  $this->subject->render('foo');
52  }
53 
59  {
60  $this->subject->render('Foo', 'incorrectMode');
61  }
62 
67  {
68  $this->assertSame('FOOB4R', $this->subject->render('FooB4r'));
69  }
70 
75  {
76  return array(
77  array('FooB4r', CaseViewHelper::CASE_LOWER, 'foob4r'),
78  array('FooB4r', CaseViewHelper::CASE_UPPER, 'FOOB4R'),
79  array('foo bar', CaseViewHelper::CASE_CAPITAL, 'Foo bar'),
80  array('FOO Bar', CaseViewHelper::CASE_UNCAPITAL, 'fOO Bar'),
81  array('smørrebrød', CaseViewHelper::CASE_UPPER, 'SMØRREBRØD'),
82  array('smørrebrød', CaseViewHelper::CASE_CAPITAL, 'Smørrebrød'),
83  array('römtömtömtöm', CaseViewHelper::CASE_UPPER, 'RÖMTÖMTÖMTÖM'),
84  array('Ἕλλάς α ω', CaseViewHelper::CASE_UPPER, 'ἝΛΛΆΣ Α Ω'),
85  );
86  }
87 
92  public function viewHelperConvertsCorrectly($input, $mode, $expected)
93  {
94  $this->assertSame($expected, $this->subject->render($input, $mode), sprintf('The conversion with mode "%s" did not perform as expected.', $mode));
95  }
96 }