From 24c7a7f7a30b38fffcaf0aecedc6882e97f5ad4e Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Mon, 18 May 2015 15:21:47 +1000 Subject: [PATCH] Disable caching during test runs + allow -w to override -n from a ruleset --- src/Config.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Config.php b/src/Config.php index f930611601..15d7be2a17 100644 --- a/src/Config.php +++ b/src/Config.php @@ -472,9 +472,11 @@ public function restoreDefaults() $this->colors = (bool) $colors; } - $cache = self::getConfigData('cache'); - if ($cache !== null) { - $this->cache = (bool) $cache; + if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { + $cache = self::getConfigData('cache'); + if ($cache !== null) { + $this->cache = (bool) $cache; + } } }//end restoreDefaults() @@ -534,12 +536,16 @@ public function processShortArgument($arg, $pos) } break; case 'n' : - $this->warningSeverity = 0; - $this->overriddenDefaults['warningSeverity'] = true; + if (isset($this->overriddenDefaults['warningSeverity']) === false) { + $this->warningSeverity = 0; + $this->overriddenDefaults['warningSeverity'] = true; + } break; case 'w' : - $this->warningSeverity = $this->errorSeverity; - $this->overriddenDefaults['warningSeverity'] = true; + if (isset($this->overriddenDefaults['warningSeverity']) === false) { + $this->warningSeverity = $this->errorSeverity; + $this->overriddenDefaults['warningSeverity'] = true; + } break; default: if ($this->dieOnUnknownArg === false) { @@ -579,8 +585,10 @@ public function processLongArgument($arg, $pos) $this->overriddenDefaults['colors'] = true; break; case 'cache': - $this->cache = true; - $this->overriddenDefaults['cache'] = true; + if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { + $this->cache = true; + $this->overriddenDefaults['cache'] = true; + } break; case 'no-cache': $this->cache = false;