Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Merge [4616].

  • Loading branch information...
commit 36b06f32cd01a82753a92694c3d7b14657e67c60 1 parent a9b34ca
@sebastianbergmann authored
Showing with 44 additions and 70 deletions.
  1. +1 −1  PHPUnit/Framework/TestCase.php
  2. +43 −69 PHPUnit/Util/Test.php
View
2  PHPUnit/Framework/TestCase.php
@@ -421,7 +421,7 @@ protected function setUseOutputBufferingFromAnnotation()
$method = new ReflectionMethod($className, $this->name);
$methodDocComment = $method->getDocComment();
- $useOutputBuffering = PHPUnit_Util_Test::getOutputBuffering(
+ $useOutputBuffering = PHPUnit_Util_Test::getOutputBufferingSettings(
$classDocComment, $methodDocComment
);
View
112 PHPUnit/Util/Test.php
@@ -198,65 +198,6 @@ public static function getLinesToBeCovered($className, $methodName)
}
/**
- * Returns the backup settings for a test.
- *
- * @param string $classDocComment
- * @param string $methodDocComment
- * @return array
- * @since Method available since Release 3.4.0
- */
- public static function getBackupSettings($classDocComment, $methodDocComment)
- {
- $backupGlobals = NULL;
- $backupStaticAttributes = NULL;
-
- if (preg_match(self::REGEX_BACKUP_GLOBALS, $classDocComment, $matches)) {
- if ($matches[1] == 'enabled') {
- $backupGlobals = TRUE;
- }
-
- else if ($matches[1] == 'disabled') {
- $backupGlobals = FALSE;
- }
- }
-
- if (preg_match(self::REGEX_BACKUP_GLOBALS, $methodDocComment, $matches)) {
- if ($matches[1] == 'enabled') {
- $backupGlobals = TRUE;
- }
-
- else if ($matches[1] == 'disabled') {
- $backupGlobals = FALSE;
- }
- }
-
- if (preg_match(self::REGEX_BACKUP_STATIC_ATTRIBUTES, $classDocComment, $matches)) {
- if ($matches[1] == 'enabled') {
- $backupStaticAttributes = TRUE;
- }
-
- else if ($matches[1] == 'disabled') {
- $backupStaticAttributes = FALSE;
- }
- }
-
- if (preg_match(self::REGEX_BACKUP_STATIC_ATTRIBUTES, $methodDocComment, $matches)) {
- if ($matches[1] == 'enabled') {
- $backupStaticAttributes = TRUE;
- }
-
- else if ($matches[1] == 'disabled') {
- $backupStaticAttributes = FALSE;
- }
- }
-
- return array(
- 'backupGlobals' => $backupGlobals,
- 'backupStaticAttributes' => $backupStaticAttributes
- );
- }
-
- /**
* Returns the dependencies for a test class or method.
*
* @param string $docComment
@@ -373,38 +314,71 @@ public static function getProvidedData($className, $methodName, $docComment)
}
/**
- * Returns the output buffering settings for a test.
+ * Returns the backup settings for a test.
*
* @param string $classDocComment
* @param string $methodDocComment
* @return array
* @since Method available since Release 3.4.0
*/
- public static function getOutputBuffering($classDocComment, $methodDocComment)
+ public static function getBackupSettings($classDocComment, $methodDocComment)
+ {
+ return array(
+ 'backupGlobals' => self::getSettings(
+ $classDocComment, $methodDocComment, self::REGEX_BACKUP_GLOBALS
+ ),
+ 'backupStaticAttributes' => self::getSettings(
+ $classDocComment, $methodDocComment, self::REGEX_BACKUP_STATIC_ATTRIBUTES
+ )
+ );
+ }
+
+ /**
+ * Returns the output buffering settings for a test.
+ *
+ * @param string $classDocComment
+ * @param string $methodDocComment
+ * @return boolean
+ * @since Method available since Release 3.4.0
+ */
+ public static function getOutputBufferingSettings($classDocComment, $methodDocComment)
{
- $outputBuffering = NULL;
+ return self::getSettings(
+ $classDocComment, $methodDocComment, self::REGEX_USE_OUTPUT_BUFFERING
+ );
+ }
- if (preg_match(self::REGEX_USE_OUTPUT_BUFFERING, $classDocComment, $matches)) {
+ /**
+ * @param string $classDocComment
+ * @param string $methodDocComment
+ * @return boolean
+ * @since Method available since Release 3.4.0
+ */
+ private static function getSettings($classDocComment, $methodDocComment, $regex)
+ {
+ $result = NULL;
+
+ if (preg_match($regex, $classDocComment, $matches)) {
if ($matches[1] == 'enabled') {
- $outputBuffering = TRUE;
+ $result = TRUE;
}
else if ($matches[1] == 'disabled') {
- $outputBuffering = FALSE;
+ $result = FALSE;
}
}
- if (preg_match(self::REGEX_USE_OUTPUT_BUFFERING, $methodDocComment, $matches)) {
+ if (preg_match($regex, $methodDocComment, $matches)) {
if ($matches[1] == 'enabled') {
- $outputBuffering = TRUE;
+ $result = TRUE;
}
else if ($matches[1] == 'disabled') {
- $outputBuffering = FALSE;
+ $result = FALSE;
}
}
- return $outputBuffering;
+ return $result;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.