Skip to content

Commit

Permalink
Skip tests when running in a PEAR install due to file path differences
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jan 30, 2020
1 parent 86712a1 commit 91fa3b6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Core/Filters/Filter/AcceptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,35 @@ 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.
*
* @return void
*/
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);
Expand Down
7 changes: 7 additions & 0 deletions tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__)));

Expand Down
7 changes: 7 additions & 0 deletions tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__)));

Expand Down
22 changes: 22 additions & 0 deletions tests/Core/Ruleset/RuleInclusionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,35 @@ 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.
*
* @return void
*/
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);
Expand Down

0 comments on commit 91fa3b6

Please sign in to comment.