Completed
Push — master ( 2eb3b3...c3dff2 )
by Shcherbak
02:38
created

LineAfterOpenTagReviewTest::testLineAfterOpenTag()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 7
nc 2
nop 3
1
<?php
2
3
  namespace Funivan\Cs\Tools\Php\LineAfterOpenTag\Tests;
4
5
  use Funivan\Cs\Tools\Php\LineAfterOpenTag\LineAfterOpenTagReview;
6
  use Tests\Funivan\Cs\ReviewTestCase;
7
8
  /**
9
   *
10
   */
11
  class LineAfterOpenTagReviewTest extends ReviewTestCase {
12
13
    /**
14
     * @return array
15
     */
16
    public function getLineAfterOpenTagDataProvider() {
17
      return [
18
        [
19
          '<?php
20
21
22
23
',
24
          [1],
25
        ],
26
        [
27
          '<?php
28
29
echo 1;
30
',
31
          [],
32
        ],
33
        [
34
          '<?php
35
36
echo 1;?>
37
<?
38
39
40
',
41
          [4],
42
          'process' => (boolean) ini_get('short_open_tag'),
43
        ],
44
        [
45
          '<?
46
47
echo 1;
48
',
49
          [],
50
          'process' => (boolean) ini_get('short_open_tag'),
51
        ],
52
        [
53
          '<?
54
55
56
echo 1;
57
',
58
          [1],
59
          'process' => (boolean) ini_get('short_open_tag'),
60
        ],
61
      ];
62
    }
63
64
65
    /**
66
     * @dataProvider getLineAfterOpenTagDataProvider
67
     * @param string $input
68
     * @param array $errorLines
69
     * @param bool $process
70
     */
71
    public function testLineAfterOpenTag($input, array $errorLines, $process = true) {
72
      if ($process === false) {
73
        $this->markTestSkipped('PHP short open tags are not enabled.');
74
        return;
75
      }
76
      $tool = new LineAfterOpenTagReview();
77
      $report = $this->process($tool, $input);
78
      $this->assertInvalidLinesInReport($report, $errorLines);
79
    }
80
81
  }
82