PHPUnit_Framework_ComparisonFailure::diffEqual PHP Method

diffEqual() public static method

Figures out which diff class to use for the input types then instantiates that class and returns the object.
public static diffEqual ( mixed $expected, mixed $actual, string $message = '' ) : PHPUnit_Framework_ComparisonFailure
$expected mixed Expected value retrieved.
$actual mixed Actual value retrieved.
$message string A string which is prefixed on all returned lines in the difference output.
return PHPUnit_Framework_ComparisonFailure
    public static function diffEqual($expected, $actual, $message = '')
    {
        if (is_array($expected) && is_array($actual)) {
            return new PHPUnit_Framework_ComparisonFailure_Array($expected, $actual, FALSE, $message);
        } else {
            if (is_object($expected) && is_object($actual)) {
                return new PHPUnit_Framework_ComparisonFailure_Object($expected, $actual, FALSE, $message);
            } else {
                if (is_string($expected) && !is_object($actual)) {
                    return new PHPUnit_Framework_ComparisonFailure_String($expected, $actual, FALSE, $message);
                } else {
                    if (is_null($expected) || is_scalar($expected)) {
                        return new PHPUnit_Framework_ComparisonFailure_Scalar($expected, $actual, FALSE, $message);
                    }
                }
            }
        }
    }

Usage Example

コード例 #1
0
ファイル: Driver.php プロジェクト: kingsj/core
 /**
  * Send a command to the Selenium RC server (via curl).
  *
  * @param  string $command
  * @param  array  $arguments
  * @return string
  * @author Seth Casana <*****@*****.**>
  */
 protected function doCommand($command, array $arguments = array())
 {
     $url = sprintf('http://%s:%s/selenium-server/driver/?cmd=%s', $this->host, $this->port, urlencode($command));
     $numArguments = count($arguments);
     for ($i = 0; $i < $numArguments; $i++) {
         $argNum = strval($i + 1);
         $url .= sprintf('&%s=%s', $argNum, urlencode(trim($arguments[$i])));
     }
     if (isset($this->sessionId)) {
         $url .= sprintf('&%s=%s', 'sessionId', $this->sessionId);
     }
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
     $response = curl_exec($curl);
     $info = curl_getinfo($curl);
     if (!$response) {
         throw new RuntimeException(curl_error($curl));
     }
     curl_close($curl);
     if ($info['http_code'] != 200) {
         $this->stop();
         throw new RuntimeException('The response from the Selenium RC server is invalid: ' . $response);
     }
     if (!preg_match('/^OK/', $response)) {
         throw new PHPUnit_Framework_ExpectationFailedException('Non-Ok response from Selenium RC server was received', PHPUnit_Framework_ComparisonFailure::diffEqual('OK', $response), sprintf("Response from Selenium RC server for %s(%s).\n%s.\n", $command, implode(', ', $arguments), $response));
     }
     return $response;
 }
All Usage Examples Of PHPUnit_Framework_ComparisonFailure::diffEqual