LineEndingReviewTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 53
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getReplaceSpacesDataProvider() 0 26 1
A testReviewInvalidLines() 0 12 1
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