Completed
Push — master ( 385e70...bfc368 )
by Shcherbak
02:13
created

LineEndingFixerTest::getTool()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
  namespace Funivan\Cs\Tools\LineEnding\Tests;
4
5
  use Funivan\Cs\Tools\LineEnding\LineEndingFixer;
6
  use Tests\Funivan\Cs\FixerTestCase;
7
8
  /**
9
   *
10
   */
11
  class LineEndingFixerTest extends FixerTestCase {
12
13
    /**
14
     * @return array
15
     */
16
    public function getReplaceSpacesDataProvider() {
17
      return [
18
        [
19
          '<?php\n 
20
  echo 1;\r',
21
          '<?php\n 
22
  echo 1;\n',
23
        ],
24
        [
25
          '<?php echo 1;',
26
          '<?php echo 1;',
27
        ],
28
        [
29
          '<?php\r\n
30
          echo 1;\n
31
          \r',
32
          '<?php\n
33
          echo 1;\n
34
          \n',
35
36
        ],
37
        [
38
          '<?php\n
39
\n
40
\n',
41
          '<?php\n
42
\n
43
\n',
44
45
        ],
46
      ];
47
    }
48
49
50
    /**
51
     * @dataProvider getReplaceSpacesDataProvider
52
     * @param string $input
53
     * @param string $expect
54
     */
55
    public function testReplaceInvalidLines($input, $expect) {
56
      $map = [
57
        '\r' => "\r",
58
        '\n' => "\n",
59
      ];
60
61
62
      $input = str_replace("\n", '', $input);
63
      $expect = str_replace("\n", '', $expect);
64
      $input = strtr($input, $map);
65
66
      $output = $this->convert(new LineEndingFixer(), $input);
67
68
      $output = strtr($output, array_flip($map));
69
      $this->assertEquals($expect, $output);
70
71
    }
72
73
  }
74