From 91fa3b6756c162f42ed258b85940f88db0319257 Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Fri, 31 Jan 2020 09:09:57 +1100 Subject: [PATCH] Skip tests when running in a PEAR install due to file path differences --- tests/Core/Filters/Filter/AcceptTest.php | 22 +++++++++++++++++++ .../RuleInclusionAbsoluteLinuxTest.php | 7 ++++++ .../RuleInclusionAbsoluteWindowsTest.php | 7 ++++++ tests/Core/Ruleset/RuleInclusionTest.php | 22 +++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php index 51e41a023e..5d928c38b8 100644 --- a/tests/Core/Filters/Filter/AcceptTest.php +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -33,6 +33,23 @@ class AcceptTest extends TestCase protected static $ruleset; + /** + * Initialize the test. + * + * @return void + */ + public function setUp() + { + if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { + // PEAR installs test and sniff files into different locations + // so these tests will not pass as they directly reference files + // by relative location. + $this->markTestSkipped('Test cannot run from a PEAR install'); + } + + }//end setUp() + + /** * Initialize the config and ruleset objects based on the `AcceptTest.xml` ruleset file. * @@ -40,6 +57,11 @@ class AcceptTest extends TestCase */ public static function setUpBeforeClass() { + if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { + // This test will be skipped. + return; + } + $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; self::$config = new Config(["--standard=$standard", "--ignore=*/somethingelse/*"]); self::$ruleset = new Ruleset(self::$config); diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php index 7e78d907eb..8b138e0b01 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php @@ -45,6 +45,13 @@ class RuleInclusionAbsoluteLinuxTest extends TestCase */ public function setUp() { + if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { + // PEAR installs test and sniff files into different locations + // so these tests will not pass as they directly reference files + // by relative location. + $this->markTestSkipped('Test cannot run from a PEAR install'); + } + $this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; $repoRootDir = dirname(dirname(dirname(__DIR__))); diff --git a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php index 324f39a4ce..f8e3255b88 100644 --- a/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php +++ b/tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php @@ -49,6 +49,13 @@ public function setUp() $this->markTestSkipped('Windows specific test'); } + if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { + // PEAR installs test and sniff files into different locations + // so these tests will not pass as they directly reference files + // by relative location. + $this->markTestSkipped('Test cannot run from a PEAR install'); + } + $this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; $repoRootDir = dirname(dirname(dirname(__DIR__))); diff --git a/tests/Core/Ruleset/RuleInclusionTest.php b/tests/Core/Ruleset/RuleInclusionTest.php index ac535ee2db..1ccbfdc026 100644 --- a/tests/Core/Ruleset/RuleInclusionTest.php +++ b/tests/Core/Ruleset/RuleInclusionTest.php @@ -24,6 +24,23 @@ class RuleInclusionTest extends TestCase protected static $ruleset; + /** + * Initialize the test. + * + * @return void + */ + public function setUp() + { + if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { + // PEAR installs test and sniff files into different locations + // so these tests will not pass as they directly reference files + // by relative location. + $this->markTestSkipped('Test cannot run from a PEAR install'); + } + + }//end setUp() + + /** * Initialize the config and ruleset objects based on the `RuleInclusionTest.xml` ruleset file. * @@ -31,6 +48,11 @@ class RuleInclusionTest extends TestCase */ public static function setUpBeforeClass() { + if ($GLOBALS['PHP_CODESNIFFER_PEAR'] === true) { + // This test will be skipped. + return; + } + $standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml'; $config = new Config(["--standard=$standard"]); self::$ruleset = new Ruleset($config);