PHPUnit_Util_Test::getPreserveGlobalStateSettings PHP Метод

getPreserveGlobalStateSettings() публичный статический Метод

Returns the preserve global state settings for a test.
public static getPreserveGlobalStateSettings ( string $className, string $methodName ) : boolean
$className string
$methodName string
Результат boolean
    public static function getPreserveGlobalStateSettings($className, $methodName)
    {
        return self::getBooleanAnnotationSetting($className, $methodName, 'preserveGlobalState');
    }

Usage Example

Пример #1
0
 /**
  * @param  ReflectionClass $theClass
  * @param  string          $name
  * @param  array           $classGroups
  * @return PHPUnit_Framework_Test
  */
 public static function createTest(ReflectionClass $theClass, $name, array $classGroups = array())
 {
     $className = $theClass->getName();
     if (!$theClass->isInstantiable()) {
         return self::warning(sprintf('Cannot instantiate class "%s".', $className));
     }
     $classDocComment = $theClass->getDocComment();
     $method = new ReflectionMethod($className, $name);
     $methodDocComment = $method->getDocComment();
     $backupSettings = PHPUnit_Util_Test::getBackupSettings($className, $name);
     $preserveGlobalState = PHPUnit_Util_Test::getPreserveGlobalStateSettings($className, $name);
     $runTestInSeparateProcess = PHPUnit_Util_Test::getProcessIsolationSettings($className, $name);
     $constructor = $theClass->getConstructor();
     if ($constructor !== NULL) {
         $parameters = $constructor->getParameters();
         // TestCase() or TestCase($name)
         if (count($parameters) < 2) {
             $test = new $className();
         } else {
             $data = PHPUnit_Util_Test::getProvidedData($className, $name);
             $groups = PHPUnit_Util_Test::getGroups($className, $name);
             if (is_array($data) || $data instanceof Iterator) {
                 $test = new PHPUnit_Framework_TestSuite_DataProvider($className . '::' . $name);
                 foreach ($data as $_dataName => $_data) {
                     $_test = new $className($name, $_data, $_dataName);
                     if ($runTestInSeparateProcess) {
                         $_test->setRunTestInSeparateProcess(TRUE);
                         if ($preserveGlobalState !== NULL) {
                             $_test->setPreserveGlobalState($preserveGlobalState);
                         }
                     }
                     if ($backupSettings['backupGlobals'] !== NULL) {
                         $_test->setBackupGlobals($backupSettings['backupGlobals']);
                     }
                     if ($backupSettings['backupStaticAttributes'] !== NULL) {
                         $_test->setBackupStaticAttributes($backupSettings['backupStaticAttributes']);
                     }
                     $test->addTest($_test, $groups);
                 }
             } else {
                 $test = new $className();
             }
         }
     }
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $test->setName($name);
         if ($runTestInSeparateProcess) {
             $test->setRunTestInSeparateProcess(TRUE);
             if ($preserveGlobalState !== NULL) {
                 $test->setPreserveGlobalState($preserveGlobalState);
             }
         }
         if ($backupSettings['backupGlobals'] !== NULL) {
             $test->setBackupGlobals($backupSettings['backupGlobals']);
         }
         if ($backupSettings['backupStaticAttributes'] !== NULL) {
             $test->setBackupStaticAttributes($backupSettings['backupStaticAttributes']);
         }
     }
     return $test;
 }
All Usage Examples Of PHPUnit_Util_Test::getPreserveGlobalStateSettings