|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* |
|
5
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
6
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
7
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
8
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
9
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
10
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
11
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
12
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
13
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
14
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
15
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
16
|
|
|
* |
|
17
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
18
|
|
|
* and is licensed under the LGPL. For more information please see |
|
19
|
|
|
* <http://phing.info>. |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Tests for PhpCodeSnifferTask |
|
24
|
|
|
* |
|
25
|
|
|
* @author Michiel Rook <[email protected]> |
|
26
|
|
|
* @package phing.tasks.ext |
|
27
|
|
|
*/ |
|
28
|
|
|
class PhpCodeSnifferTaskTest extends BuildFileTest |
|
29
|
|
|
{ |
|
30
|
|
|
public function setUp(): void |
|
31
|
|
|
{ |
|
32
|
|
|
if (defined('HHVM_VERSION')) { |
|
33
|
|
|
$this->markTestSkipped("PHP CodeSniffer tests do not (yet) run on HHVM"); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
if (!class_exists('PHP_CodeSniffer')) { |
|
37
|
|
|
$this->markTestSkipped('PHP CodeSniffer package not available.'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$this->configureProject(PHING_TEST_BASE . "/etc/tasks/ext/phpcs/build.xml"); |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testNestedFormatters() |
|
44
|
|
|
{ |
|
45
|
|
|
ob_start(); |
|
46
|
|
|
$this->executeTarget(__FUNCTION__); |
|
47
|
|
|
$output = ob_get_clean(); |
|
48
|
|
|
$this->assertContains("PHP CODE SNIFFER REPORT SUMMARY", $output); |
|
49
|
|
|
$this->assertFileExists( |
|
50
|
|
|
PHING_TEST_BASE . '/etc/tasks/ext/phpcs/report.txt' |
|
|
|
|
|
|
51
|
|
|
); |
|
52
|
|
|
unlink(PHING_TEST_BASE . '/etc/tasks/ext/phpcs/report.txt'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testCustomStandard() |
|
56
|
|
|
{ |
|
57
|
|
|
ob_start(); |
|
58
|
|
|
$this->executeTarget(__FUNCTION__); |
|
59
|
|
|
$output = ob_get_clean(); |
|
60
|
|
|
$this->assertContains("PHP CODE SNIFFER REPORT SUMMARY", $output); |
|
61
|
|
|
$this->assertFileExists( |
|
62
|
|
|
PHING_TEST_BASE . '/etc/tasks/ext/phpcs/report.txt' |
|
|
|
|
|
|
63
|
|
|
); |
|
64
|
|
|
unlink(PHING_TEST_BASE . '/etc/tasks/ext/phpcs/report.txt'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function testPropertyOutput() |
|
68
|
|
|
{ |
|
69
|
|
|
ob_start(); |
|
70
|
|
|
$this->executeTarget(__FUNCTION__); |
|
71
|
|
|
$output = ob_get_clean(); |
|
|
|
|
|
|
72
|
|
|
$this->assertPropertyEquals( |
|
73
|
|
|
"PhpCodeSnifferTaskTest.testPropertyOutput", |
|
74
|
|
|
"- Generic_Sniffs_PHP_DisallowShortOpenTagSniff" . PHP_EOL |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|