Skip to content

Commit 91fa3b6

Browse files
committed
Skip tests when running in a PEAR install due to file path differences
1 parent 86712a1 commit 91fa3b6

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

tests/Core/Filters/Filter/AcceptTest.php

+22
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,35 @@ class AcceptTest extends TestCase
3333
protected static $ruleset;
3434

3535

36+
/**
37+
* Initialize the test.
38+
*
39+
* @return void
40+
*/
41+
public function setUp()
42+
{
43+
if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) {
44+
// PEAR installs test and sniff files into different locations
45+
// so these tests will not pass as they directly reference files
46+
// by relative location.
47+
$this->markTestSkipped('Test cannot run from a PEAR install');
48+
}
49+
50+
}//end setUp()
51+
52+
3653
/**
3754
* Initialize the config and ruleset objects based on the `AcceptTest.xml` ruleset file.
3855
*
3956
* @return void
4057
*/
4158
public static function setUpBeforeClass()
4259
{
60+
if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) {
61+
// This test will be skipped.
62+
return;
63+
}
64+
4365
$standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';
4466
self::$config = new Config(["--standard=$standard", "--ignore=*/somethingelse/*"]);
4567
self::$ruleset = new Ruleset(self::$config);

tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ class RuleInclusionAbsoluteLinuxTest extends TestCase
4545
*/
4646
public function setUp()
4747
{
48+
if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) {
49+
// PEAR installs test and sniff files into different locations
50+
// so these tests will not pass as they directly reference files
51+
// by relative location.
52+
$this->markTestSkipped('Test cannot run from a PEAR install');
53+
}
54+
4855
$this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';
4956
$repoRootDir = dirname(dirname(dirname(__DIR__)));
5057

tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public function setUp()
4949
$this->markTestSkipped('Windows specific test');
5050
}
5151

52+
if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) {
53+
// PEAR installs test and sniff files into different locations
54+
// so these tests will not pass as they directly reference files
55+
// by relative location.
56+
$this->markTestSkipped('Test cannot run from a PEAR install');
57+
}
58+
5259
$this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';
5360
$repoRootDir = dirname(dirname(dirname(__DIR__)));
5461

tests/Core/Ruleset/RuleInclusionTest.php

+22
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,35 @@ class RuleInclusionTest extends TestCase
2424
protected static $ruleset;
2525

2626

27+
/**
28+
* Initialize the test.
29+
*
30+
* @return void
31+
*/
32+
public function setUp()
33+
{
34+
if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) {
35+
// PEAR installs test and sniff files into different locations
36+
// so these tests will not pass as they directly reference files
37+
// by relative location.
38+
$this->markTestSkipped('Test cannot run from a PEAR install');
39+
}
40+
41+
}//end setUp()
42+
43+
2744
/**
2845
* Initialize the config and ruleset objects based on the `RuleInclusionTest.xml` ruleset file.
2946
*
3047
* @return void
3148
*/
3249
public static function setUpBeforeClass()
3350
{
51+
if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) {
52+
// This test will be skipped.
53+
return;
54+
}
55+
3456
$standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';
3557
$config = new Config(["--standard=$standard"]);
3658
self::$ruleset = new Ruleset($config);

0 commit comments

Comments
 (0)