[TASK] Change $fixture to $subject in unit-tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Tests / Unit / Filter / StripNewLinesFilterTest.php
1 <?php
2 namespace TYPO3\CMS\Form\Tests\Unit\Filter;
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 * @author Andreas Lappe <nd@kaeufli.ch>
21 */
22 class StripNewLinesFilterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
23
24 /**
25 * @var \TYPO3\CMS\Form\Filter\StripNewLinesFilter
26 */
27 protected $subject = NULL;
28
29 /**
30 * Set up
31 */
32 protected function setUp() {
33 $this->subject = new \TYPO3\CMS\Form\Filter\StripNewLinesFilter();
34 }
35
36 public function dataProviderWithNewlines() {
37 return array(
38 'some\rtext' => array("some\rtext", 'some text'),
39 'some\ntext' => array("some\ntext", 'some text'),
40 'some\r\ntext' => array("some\r\ntext", 'some text'),
41 'somechr(13)text' => array('some' . chr(13) . 'text', 'some text'),
42 'somechr(10)text' => array('some' . chr(10) . 'text', 'some text'),
43 'somechr(13)chr(10)text' => array('some' . chr(13) . chr(10) . 'text', 'some text'),
44 'someCRtext' => array('some' . CR . 'text', 'some text'),
45 'someLFtext' => array('some' . LF . 'text', 'some text'),
46 'someCRLFtext' => array('some' . CRLF . 'text', 'some text'),
47 'some^Mtext' => array('some
48 text', 'some text'),
49 'trailing newline\r' => array("trailing newline\n", 'trailing newline '),
50 'trailing newline\n' => array("trailing newline\r", 'trailing newline '),
51 'trailing newline\r\n' => array("trailing newline\r\n", 'trailing newline '),
52 'trailing newlinechr(13)' => array('trailing newline' . chr(13), 'trailing newline '),
53 'trailing newlinechr(10)' => array('trailing newline' . chr(10), 'trailing newline '),
54 'trailing newlinechr(13)chr(10)' => array('trailing newline' . chr(13) . chr(10), 'trailing newline '),
55 'trailing newlineCR' => array('trailing newline' . CR, 'trailing newline '),
56 'trailing newlineLF' => array('trailing newline' . LF, 'trailing newline '),
57 'trailing newlineCRLF' => array('trailing newline' . CRLF, 'trailing newline '),
58 'trailing newline^M' => array('trailing newline
59 ', 'trailing newline ')
60 );
61 }
62
63 /**
64 * @test
65 * @dataProvider dataProviderWithNewlines
66 */
67 public function filterForStringWithNewlineReturnsStringWithoutNewline($input, $expected) {
68 $this->assertSame(
69 $expected,
70 $this->subject->filter($input)
71 );
72 }
73
74 }