Exemple #1
0
 public function nodeListFromXpath($xpath)
 {
     if (!is_string($xpath)) {
         throw yTest_Exception::invalid('string', $xpath);
     }
     $nodeList = $this->domxpath->evaluate($xpath);
     $this->testCase->assertType('DOMNodeList', $nodeList);
     return $nodeList;
 }
 private function getConstantValue()
 {
     if ($this->className === null) {
         $consts = get_defined_constants();
         if (!array_key_exists($this->constName, $consts)) {
             throw yTest_Exception::noSuch("constant", $this->constName);
         }
         return $consts[$this->constName];
     } else {
         $refl = new ReflectionClass($this->className);
         return $refl->getConstant($this->constName);
     }
 }
 public function __construct($functionName, $delegateObject, $delegateMethodName = null)
 {
     $this->functionName = $functionName;
     if (!is_object($delegateObject)) {
         throw yTest_Exception::badDelegateObject($delegateObject, $functionName);
     }
     $this->delegateObject = $delegateObject;
     if ($delegateMethodName === null) {
         $delegateMethodName = $functionName;
     }
     $this->delegateMethodName = $delegateMethodName;
     $this->delegateClassName = get_class($delegateObject);
 }
Exemple #4
0
 /**
  * @return false | array('arg1' => 'value1', ...)
  */
 public static function getArgsFromUrl($url)
 {
     $res = parse_url($url, PHP_URL_QUERY);
     if ($res === false) {
         throw yTest_Exception::invalid('URL', $url);
     }
     $args = explode('&', $res);
     $map = array();
     foreach ($args as $a) {
         list($key, $val) = explode('=', $a);
         $map[$key] = $val;
     }
     return $map;
 }
 private function __construct($rewireMode, $instance, $className, $methodName, $delegateObject, $delegateMethodName = null)
 {
     $this->rewireMode = $rewireMode;
     if ($delegateMethodName === null) {
         $delegateMethodName = $methodName;
     }
     $this->instance = $instance;
     $this->methodName = $methodName;
     $this->className = $className;
     if (!is_object($delegateObject)) {
         throw yTest_Exception::badDelegateObject($delegateObject, $methodName);
     }
     $this->delegateObject = $delegateObject;
     $this->delegateMethodName = $delegateMethodName;
     $this->delegateClassName = get_class($delegateObject);
 }
 /**
  * @param string One PCRE regexp string (including delimiters).
  */
 public function __construct()
 {
     $regexps = func_get_args();
     if (is_array($regexps)) {
         foreach ($regexps as $regexp) {
             if (!is_string($regexp)) {
                 throw yTest_Exception::invalid('regexp', $regexp);
             }
         }
         $this->regexps = $regexps;
     } else {
         if (!is_string($regexps)) {
             throw yTest_Exception::invalid('regexp', $regexps);
         }
         $this->regexps = array($regexps);
     }
 }
Exemple #7
0
 public function runQuery($query, $serverId = null)
 {
     if (!$this->isInitialized()) {
         $this->initialize();
     }
     if ($serverId === null) {
         foreach ($this->pdos as $serverIdx => $pdo) {
             $res = $this->runQuery($query, $serverIdx);
         }
         return $res;
     }
     try {
         $res = $this->pdos[$serverId]->query($query);
     } catch (PDOException $ex) {
         $res = false;
     }
     if ($res === false) {
         throw yTest_Exception::sqlError($query, $ex);
     }
     return $res;
 }
 public final function backupStaticProperty($className, $propertyName)
 {
     if (!yTest_Reflection::isStaticProperty($className, $propertyName)) {
         throw yTest_Exception::noSuch("static property", "{$className}::{$propertyName}");
     }
     $isPublic = yTest_Reflection::isPropertyPublic($className, $propertyName);
     if (!$isPublic) {
         $this->letMeAccess($className, $propertyName);
     }
     $change = new yTest_BackupStaticProperty($className, $propertyName, $isPublic);
     $this->codeChanger->enqueue($change);
 }