Completed
Push — master ( 0496dc...50ef2b )
by Shcherbak
02:37
created

getReplaceSpacesDataProvider()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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