getReplaceSpacesDataProvider()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
c 0
b 0
f 0
rs 8.8571
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
  namespace Funivan\Cs\Tools\Tests\LineEnding;
4
5
  use Funivan\Cs\Tools\LineEnding\LineEndingReview;
6
  use Tests\Funivan\Cs\BaseTestCase;
7
8
  /**
9
   * @author Ivan Shcherbak <[email protected]> 2016
10
   */
11
  class LineEndingReviewTest extends BaseTestCase {
12
13
14
    /**
15
     * @return array
16
     */
17
    public function getReplaceSpacesDataProvider() {
18
      return [
19
        [
20
          'code' => '<?php\n 
21
  echo 1;\r',
22
          'lines' => [2],
23
        ],
24
        [
25
          'code' => '<?php echo 1;',
26
          'lines' => [],
27
        ],
28
        [
29
          'code' => '<?php\r\n
30
          echo 1;\n
31
          \r',
32
          'lines' => [1, 2],
33
        ],
34
        [
35
          'code' => '<?php\n
36
\r\n
37
\r\n',
38
          'lines' => [2],
39
40
        ],
41
      ];
42
    }
43
44
45
    /**
46
     * @dataProvider getReplaceSpacesDataProvider
47
     * @param string $input
48
     * @param array $expectErrorLines
49
     */
50
    public function testReviewInvalidLines($input, array $expectErrorLines) {
51
      $map = [
52
        '\r' => "\r",
53
        '\n' => "\n",
54
      ];
55
56
      $input = str_replace("\n", '', $input);
57
      $input = strtr($input, $map);
58
59
60
      static::assertReview(new LineEndingReview(), $input, $expectErrorLines);
61
    }
62
63
  }
64