You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/08/02 16:11:44 UTC
svn commit: r681982 [6/27] - in /incubator/shindig/trunk/php: external/
external/PHPUnit/ external/PHPUnit/Extensions/
external/PHPUnit/Extensions/Database/
external/PHPUnit/Extensions/Database/Constraint/
external/PHPUnit/Extensions/Database/DB/ exter...
Added: incubator/shindig/trunk/php/external/PHPUnit/Framework/Assert.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Framework/Assert.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Framework/Assert.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Framework/Assert.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,1678 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Assert.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 2.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/Type.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+if (!class_exists('PHPUnit_Framework_Assert', FALSE)) {
+
+/**
+ * A set of assert methods.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 2.0.0
+ * @abstract
+ */
+abstract class PHPUnit_Framework_Assert
+{
+ /**
+ * Asserts that an array has a specified key.
+ *
+ * @param mixed $key
+ * @param array $array
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertArrayHasKey($key, array $array, $message = '')
+ {
+ if (!(is_integer($key) || is_string($key))) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_ArrayHasKey($key);
+
+ self::assertThat($array, $constraint, $message);
+ }
+
+ /**
+ * Asserts that an array does not have a specified key.
+ *
+ * @param mixed $key
+ * @param array $array
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertArrayNotHasKey($key, array $array, $message = '')
+ {
+ if (!(is_integer($key) || is_string($key))) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_ArrayHasKey($key)
+ );
+
+ self::assertThat($array, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a haystack contains a needle.
+ *
+ * @param mixed $needle
+ * @param mixed $haystack
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 2.1.0
+ */
+ public static function assertContains($needle, $haystack, $message = '')
+ {
+ if (is_array($haystack) ||
+ is_object($haystack) && $haystack instanceof Iterator) {
+ $constraint = new PHPUnit_Framework_Constraint_TraversableContains($needle);
+ }
+
+ else if (is_string($haystack)) {
+ $constraint = new PHPUnit_Framework_Constraint_StringContains($needle);
+ }
+
+ else {
+ throw new InvalidArgumentException;
+ }
+
+ self::assertThat($haystack, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a haystack that is stored in a static attribute of a class
+ * or an attribute of an object contains a needle.
+ *
+ * @param mixed $needle
+ * @param string $haystackAttributeName
+ * @param mixed $haystackClassOrObject
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '')
+ {
+ self::assertContains(
+ $needle,
+ self::readAttribute($haystackClassOrObject, $haystackAttributeName),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a haystack does not contain a needle.
+ *
+ * @param mixed $needle
+ * @param mixed $haystack
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 2.1.0
+ */
+ public static function assertNotContains($needle, $haystack, $message = '')
+ {
+ if (is_array($haystack) ||
+ is_object($haystack) && $haystack instanceof Iterator) {
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_TraversableContains($needle)
+ );
+ }
+
+ else if (is_string($haystack)) {
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_StringContains($needle)
+ );
+ }
+
+ else {
+ throw new InvalidArgumentException;
+ }
+
+ self::assertThat($haystack, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a haystack that is stored in a static attribute of a class
+ * or an attribute of an object does not contain a needle.
+ *
+ * @param mixed $needle
+ * @param string $haystackAttributeName
+ * @param mixed $haystackClassOrObject
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '')
+ {
+ self::assertNotContains(
+ $needle,
+ self::readAttribute($haystackClassOrObject, $haystackAttributeName),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a haystack contains only values of a given type.
+ *
+ * @param string $type
+ * @param mixed $haystack
+ * @param boolean $isNativeType
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.4
+ */
+ public static function assertContainsOnly($type, $haystack, $isNativeType = NULL, $message = '')
+ {
+ if (!(is_array($haystack) ||
+ is_object($haystack) && $haystack instanceof Iterator)) {
+ throw new InvalidArgumentException;
+ }
+
+ if ($isNativeType == NULL) {
+ $isNativeType = PHPUnit_Util_Type::isType($type);
+ }
+
+ self::assertThat(
+ $haystack,
+ new PHPUnit_Framework_Constraint_TraversableContainsOnly(
+ $type, $isNativeType
+ ),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a haystack that is stored in a static attribute of a class
+ * or an attribute of an object contains only values of a given type.
+ *
+ * @param string $type
+ * @param string $haystackAttributeName
+ * @param mixed $haystackClassOrObject
+ * @param boolean $isNativeType
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.4
+ */
+ public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '')
+ {
+ self::assertContainsOnly(
+ $type,
+ self::readAttribute($haystackClassOrObject, $haystackAttributeName),
+ $isNativeType,
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a haystack does not contain only values of a given type.
+ *
+ * @param string $type
+ * @param mixed $haystack
+ * @param boolean $isNativeType
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.4
+ */
+ public static function assertNotContainsOnly($type, $haystack, $isNativeType = NULL, $message = '')
+ {
+ if (!(is_array($haystack) ||
+ is_object($haystack) && $haystack instanceof Iterator)) {
+ throw new InvalidArgumentException;
+ }
+
+ if ($isNativeType == NULL) {
+ $isNativeType = PHPUnit_Util_Type::isType($type);
+ }
+
+ self::assertThat(
+ $haystack,
+ new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_TraversableContainsOnly(
+ $type, $isNativeType
+ )
+ ),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a haystack that is stored in a static attribute of a class
+ * or an attribute of an object does not contain only values of a given type.
+ *
+ * @param string $type
+ * @param string $haystackAttributeName
+ * @param mixed $haystackClassOrObject
+ * @param boolean $isNativeType
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.4
+ */
+ public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = NULL, $message = '')
+ {
+ self::assertNotContainsOnly(
+ $type,
+ self::readAttribute($haystackClassOrObject, $haystackAttributeName),
+ $isNativeType,
+ $message
+ );
+ }
+
+ /**
+ * Asserts that two variables are equal.
+ *
+ * @param mixed $expected
+ * @param mixed $actual
+ * @param string $message
+ * @param float $delta
+ * @param integer $maxDepth
+ * @access public
+ * @static
+ */
+ public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10)
+ {
+ $constraint = new PHPUnit_Framework_Constraint_IsEqual(
+ $expected,
+ $delta,
+ $maxDepth
+ );
+
+ self::assertThat($actual, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a variable is equal to an attribute of an object.
+ *
+ * @param mixed $expected
+ * @param string $actualAttributeName
+ * @param string $actualClassOrObject
+ * @param string $message
+ * @param float $delta
+ * @param integer $maxDepth
+ * @access public
+ * @static
+ */
+ public static function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10)
+ {
+ self::assertEquals(
+ $expected,
+ self::readAttribute($actualClassOrObject, $actualAttributeName),
+ $message,
+ $delta,
+ $maxDepth
+ );
+ }
+
+ /**
+ * Asserts that two variables are not equal.
+ *
+ * @param mixed $expected
+ * @param mixed $actual
+ * @param string $message
+ * @param float $delta
+ * @param integer $maxDepth
+ * @access public
+ * @static
+ * @since Method available since Release 2.3.0
+ */
+ public static function assertNotEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10)
+ {
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_IsEqual(
+ $expected,
+ $delta,
+ $maxDepth
+ )
+ );
+
+ self::assertThat($actual, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a variable is not equal to an attribute of an object.
+ *
+ * @param mixed $expected
+ * @param string $actualAttributeName
+ * @param string $actualClassOrObject
+ * @param string $message
+ * @param float $delta
+ * @param integer $maxDepth
+ * @access public
+ * @static
+ */
+ public static function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0, $maxDepth = 10)
+ {
+ self::assertNotEquals(
+ $expected,
+ self::readAttribute($actualClassOrObject, $actualAttributeName),
+ $message,
+ $delta,
+ $maxDepth
+ );
+ }
+
+ /**
+ * Asserts that a value is greater than another value.
+ *
+ * @param mixed $expected
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertGreaterThan($expected, $actual, $message = '')
+ {
+ self::assertThat($actual, self::greaterThan($expected), $message);
+ }
+
+ /**
+ * Asserts that an attribute is greater than another value.
+ *
+ * @param mixed $expected
+ * @param string $actualAttributeName
+ * @param string $actualClassOrObject
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
+ {
+ self::assertGreaterThan(
+ $expected,
+ self::readAttribute($actualClassOrObject, $actualAttributeName),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a value is greater than or equal to another value.
+ *
+ * @param mixed $expected
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertGreaterThanOrEqual($expected, $actual, $message = '')
+ {
+ self::assertThat($actual, self::greaterThanOrEqual($expected), $message);
+ }
+
+ /**
+ * Asserts that an attribute is greater than or equal to another value.
+ *
+ * @param mixed $expected
+ * @param string $actualAttributeName
+ * @param string $actualClassOrObject
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
+ {
+ self::assertGreaterThanOrEqual(
+ $expected,
+ self::readAttribute($actualClassOrObject, $actualAttributeName),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a value is smaller than another value.
+ *
+ * @param mixed $expected
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertLessThan($expected, $actual, $message = '')
+ {
+ self::assertThat($actual, self::lessThan($expected), $message);
+ }
+
+ /**
+ * Asserts that an attribute is smaller than another value.
+ *
+ * @param mixed $expected
+ * @param string $actualAttributeName
+ * @param string $actualClassOrObject
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '')
+ {
+ self::assertLessThan(
+ $expected,
+ self::readAttribute($actualClassOrObject, $actualAttributeName),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a value is smaller than or equal to another value.
+ *
+ * @param mixed $expected
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertLessThanOrEqual($expected, $actual, $message = '')
+ {
+ self::assertThat($actual, self::lessThanOrEqual($expected), $message);
+ }
+
+ /**
+ * Asserts that an attribute is smaller than or equal to another value.
+ *
+ * @param mixed $expected
+ * @param string $actualAttributeName
+ * @param string $actualClassOrObject
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '')
+ {
+ self::assertLessThanOrEqual(
+ $expected,
+ self::readAttribute($actualClassOrObject, $actualAttributeName),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a file exists.
+ *
+ * @param string $filename
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertFileExists($filename, $message = '')
+ {
+ if (!is_string($filename)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_FileExists;
+
+ self::assertThat($filename, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a file does not exist.
+ *
+ * @param string $filename
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertFileNotExists($filename, $message = '')
+ {
+ if (!is_string($filename)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_FileExists
+ );
+
+ self::assertThat($filename, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a condition is true.
+ *
+ * @param boolean $condition
+ * @param string $message
+ * @throws PHPUnit_Framework_AssertionFailedError
+ * @access public
+ * @static
+ */
+ public static function assertTrue($condition, $message = '')
+ {
+ if ($condition !== TRUE) {
+ throw new PHPUnit_Framework_ExpectationFailedException(
+ sprintf(
+ 'Failed asserting that %s is true.',
+
+ PHPUnit_Util_Type::toString($condition)
+ ),
+ NULL,
+ $message
+ );
+ }
+ }
+
+ /**
+ * Asserts that a condition is false.
+ *
+ * @param boolean $condition
+ * @param string $message
+ * @throws PHPUnit_Framework_AssertionFailedError
+ * @access public
+ * @static
+ */
+ public static function assertFalse($condition, $message = '')
+ {
+ if ($condition !== FALSE) {
+ throw new PHPUnit_Framework_ExpectationFailedException(
+ sprintf(
+ 'Failed asserting that %s is false.',
+
+ PHPUnit_Util_Type::toString($condition)
+ ),
+ NULL,
+ $message
+ );
+ }
+ }
+
+ /**
+ * Asserts that a variable is not NULL.
+ *
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ */
+ public static function assertNotNull($actual, $message = '')
+ {
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_IsIdentical(NULL)
+ );
+
+ self::assertThat($actual, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a variable is NULL.
+ *
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ */
+ public static function assertNull($actual, $message = '')
+ {
+ $constraint = new PHPUnit_Framework_Constraint_IsIdentical(NULL);
+
+ self::assertThat($actual, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a class has a specified attribute.
+ *
+ * @param string $attributeName
+ * @param string $className
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertClassHasAttribute($attributeName, $className, $message = '')
+ {
+ if (!is_string($attributeName) || !is_string($className) || !class_exists($className, FALSE)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_ClassHasAttribute($attributeName);
+
+ self::assertThat($className, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a class does not have a specified attribute.
+ *
+ * @param string $attributeName
+ * @param string $className
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertClassNotHasAttribute($attributeName, $className, $message = '')
+ {
+ if (!is_string($attributeName) || !is_string($className) || !class_exists($className)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_ClassHasAttribute($attributeName)
+ );
+
+ self::assertThat($className, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a class has a specified static attribute.
+ *
+ * @param string $attributeName
+ * @param string $className
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertClassHasStaticAttribute($attributeName, $className, $message = '')
+ {
+ if (!is_string($attributeName) || !is_string($className) || !class_exists($className)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_ClassHasStaticAttribute($attributeName);
+
+ self::assertThat($className, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a class does not have a specified static attribute.
+ *
+ * @param string $attributeName
+ * @param string $className
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertClassNotHasStaticAttribute($attributeName, $className, $message = '')
+ {
+ if (!is_string($attributeName) || !is_string($className) || !class_exists($className)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_ClassHasStaticAttribute($attributeName)
+ );
+
+ self::assertThat($className, $constraint, $message);
+ }
+
+ /**
+ * Asserts that an object has a specified attribute.
+ *
+ * @param string $attributeName
+ * @param object $object
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertObjectHasAttribute($attributeName, $object, $message = '')
+ {
+ if (!is_string($attributeName) || !is_object($object)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName);
+
+ self::assertThat($object, $constraint, $message);
+ }
+
+ /**
+ * Asserts that an object does not have a specified attribute.
+ *
+ * @param string $attributeName
+ * @param object $object
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertObjectNotHasAttribute($attributeName, $object, $message = '')
+ {
+ if (!is_string($attributeName) || !is_object($object)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName)
+ );
+
+ self::assertThat($object, $constraint, $message);
+ }
+
+ /**
+ * Asserts that two variables have the same type and value.
+ * Used on objects, it asserts that two variables reference
+ * the same object.
+ *
+ * @param mixed $expected
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ */
+ public static function assertSame($expected, $actual, $message = '')
+ {
+ if (is_bool($expected) && is_bool($actual)) {
+ self::assertEquals($expected, $actual);
+ } else {
+ $constraint = new PHPUnit_Framework_Constraint_IsIdentical($expected);
+
+ self::assertThat($actual, $constraint, $message);
+ }
+ }
+
+ /**
+ * Asserts that a variable and an attribute of an object have the same type
+ * and value.
+ *
+ * @param mixed $expected
+ * @param string $actualAttributeName
+ * @param object $actualClassOrObject
+ * @param string $message
+ * @access public
+ * @static
+ */
+ public static function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
+ {
+ self::assertSame(
+ $expected,
+ self::readAttribute($actualClassOrObject, $actualAttributeName),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that two variables do not have the same type and value.
+ * Used on objects, it asserts that two variables do not reference
+ * the same object.
+ *
+ * @param mixed $expected
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ */
+ public static function assertNotSame($expected, $actual, $message = '')
+ {
+ if (is_bool($expected) && is_bool($actual)) {
+ self::assertNotEquals($expected, $actual);
+ } else {
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_IsIdentical($expected)
+ );
+
+ self::assertThat($actual, $constraint, $message);
+ }
+ }
+
+ /**
+ * Asserts that a variable and an attribute of an object do not have the
+ * same type and value.
+ *
+ * @param mixed $expected
+ * @param string $actualAttributeName
+ * @param object $actualClassOrObject
+ * @param string $message
+ * @access public
+ * @static
+ */
+ public static function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '')
+ {
+ self::assertNotSame(
+ $expected,
+ self::readAttribute($actualClassOrObject, $actualAttributeName),
+ $message
+ );
+ }
+
+ /**
+ * Asserts that a variable is of a given type.
+ *
+ * @param string $expected
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ */
+ public static function assertType($expected, $actual, $message = '')
+ {
+ if (is_string($expected)) {
+ if (PHPUnit_Util_Type::isType($expected)) {
+ $constraint = new PHPUnit_Framework_Constraint_IsType($expected);
+ }
+
+ else if (class_exists($expected) || interface_exists($expected)) {
+ $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf(
+ $expected
+ );
+ }
+
+ else {
+ throw new InvalidArgumentException;
+ }
+ } else {
+ throw new InvalidArgumentException;
+ }
+
+ self::assertThat($actual, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a variable is not of a given type.
+ *
+ * @param string $expected
+ * @param mixed $actual
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 2.2.0
+ */
+ public static function assertNotType($expected, $actual, $message = '')
+ {
+ if (is_string($expected)) {
+ if (PHPUnit_Util_Type::isType($expected)) {
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_IsType($expected)
+ );
+ }
+
+ else if (class_exists($expected) || interface_exists($expected)) {
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_IsInstanceOf($expected)
+ );
+ }
+
+ else {
+ throw new InvalidArgumentException;
+ }
+ } else {
+ throw new InvalidArgumentException;
+ }
+
+ self::assertThat($actual, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a string matches a given regular expression.
+ *
+ * @param string $pattern
+ * @param string $string
+ * @param string $message
+ * @access public
+ * @static
+ */
+ public static function assertRegExp($pattern, $string, $message = '')
+ {
+ if (!is_string($pattern) || !is_string($string)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_PCREMatch($pattern);
+
+ self::assertThat($string, $constraint, $message);
+ }
+
+ /**
+ * Asserts that a string does not match a given regular expression.
+ *
+ * @param string $pattern
+ * @param string $string
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 2.1.0
+ */
+ public static function assertNotRegExp($pattern, $string, $message = '')
+ {
+ if (!is_string($pattern) || !is_string($string)) {
+ throw new InvalidArgumentException;
+ }
+
+ $constraint = new PHPUnit_Framework_Constraint_Not(
+ new PHPUnit_Framework_Constraint_PCREMatch($pattern)
+ );
+
+ self::assertThat($string, $constraint, $message);
+ }
+
+ /**
+ * Asserts that two XML files are equal.
+ *
+ * @param string $expectedFile
+ * @param string $actualFile
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '')
+ {
+ self::assertFileExists($expectedFile);
+ self::assertFileExists($actualFile);
+
+ $expected = new DOMDocument;
+ $expected->load($expectedFile);
+
+ $actual = new DOMDocument;
+ $actual->load($actualFile);
+
+ self::assertEquals($expected, $actual, $message);
+ }
+
+ /**
+ * Asserts that two XML files are not equal.
+ *
+ * @param string $expectedFile
+ * @param string $actualFile
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '')
+ {
+ self::assertFileExists($expectedFile);
+ self::assertFileExists($actualFile);
+
+ $expected = new DOMDocument;
+ $expected->load($expectedFile);
+
+ $actual = new DOMDocument;
+ $actual->load($actualFile);
+
+ self::assertNotEquals($expected, $actual, $message);
+ }
+
+ /**
+ * Asserts that two XML documents are equal.
+ *
+ * @param string $expectedXml
+ * @param string $actualXml
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '')
+ {
+ $expected = new DOMDocument;
+ $expected->loadXML($expectedXml);
+
+ $actual = new DOMDocument;
+ $actual->loadXML($actualXml);
+
+ self::assertEquals($expected, $actual, $message);
+ }
+
+ /**
+ * Asserts that two XML documents are not equal.
+ *
+ * @param string $expectedXml
+ * @param string $actualXml
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '')
+ {
+ $expected = new DOMDocument;
+ $expected->loadXML($expectedXml);
+
+ $actual = new DOMDocument;
+ $actual->loadXML($actualXml);
+
+ self::assertNotEquals($expected, $actual, $message);
+ }
+
+ /**
+ *
+ *
+ * @param mixed $value
+ * @param PHPUnit_Framework_Constraint $constraint
+ * @param string $message
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function assertThat($value, PHPUnit_Framework_Constraint $constraint, $message = '')
+ {
+ if (!$constraint->evaluate($value)) {
+ $constraint->fail($value, $message);
+ }
+ }
+
+ /**
+ * Logical AND.
+ *
+ * @return PHPUnit_Framework_Constraint_And
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function logicalAnd()
+ {
+ $constraints = func_get_args();
+
+ $constraint = new PHPUnit_Framework_Constraint_And;
+ $constraint->setConstraints($constraints);
+
+ return $constraint;
+ }
+
+ /**
+ * Logical OR.
+ *
+ * @return PHPUnit_Framework_Constraint_Or
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function logicalOr()
+ {
+ $constraints = func_get_args();
+
+ $constraint = new PHPUnit_Framework_Constraint_Or;
+ $constraint->setConstraints($constraints);
+
+ return $constraint;
+ }
+
+ /**
+ * Logical NOT.
+ *
+ * @param PHPUnit_Framework_Constraint $constraint
+ * @return PHPUnit_Framework_Constraint_Not
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function logicalNot(PHPUnit_Framework_Constraint $constraint)
+ {
+ return new PHPUnit_Framework_Constraint_Not($constraint);
+ }
+
+ /**
+ * Logical XOR.
+ *
+ * @return PHPUnit_Framework_Constraint_Xor
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function logicalXor()
+ {
+ $constraints = func_get_args();
+
+ $constraint = new PHPUnit_Framework_Constraint_Xor;
+ $constraint->setConstraints($constraints);
+
+ return $constraint;
+ }
+
+ /**
+ *
+ *
+ * @return PHPUnit_Framework_Constraint_IsAnything
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function anything()
+ {
+ return new PHPUnit_Framework_Constraint_IsAnything;
+ }
+
+ /**
+ *
+ *
+ * @param PHPUnit_Framework_Constraint $constraint
+ * @param string $attributeName
+ * @return PHPUnit_Framework_Constraint_Attribute
+ * @access public
+ * @since Method available since Release 3.1.0
+ * @static
+ */
+ public static function attribute(PHPUnit_Framework_Constraint $constraint, $attributeName)
+ {
+ return new PHPUnit_Framework_Constraint_Attribute(
+ $constraint, $attributeName
+ );
+ }
+
+ /**
+ *
+ *
+ * @param mixed $value
+ * @return PHPUnit_Framework_Constraint_TraversableContains
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function contains($value)
+ {
+ return new PHPUnit_Framework_Constraint_TraversableContains($value);
+ }
+
+ /**
+ *
+ *
+ * @param string $type
+ * @return PHPUnit_Framework_Constraint_TraversableContainsOnly
+ * @access public
+ * @since Method available since Release 3.1.4
+ * @static
+ */
+ public static function containsOnly($type)
+ {
+ return new PHPUnit_Framework_Constraint_TraversableContainsOnly($type);
+ }
+
+ /**
+ *
+ *
+ * @param mixed $key
+ * @return PHPUnit_Framework_Constraint_ArrayHasKey
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function arrayHasKey($key)
+ {
+ return new PHPUnit_Framework_Constraint_ArrayHasKey($key);
+ }
+
+ /**
+ *
+ *
+ * @param mixed $value
+ * @param float $delta
+ * @param integer $maxDepth
+ * @return PHPUnit_Framework_Constraint_IsEqual
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function equalTo($value, $delta = 0, $maxDepth = 10)
+ {
+ return new PHPUnit_Framework_Constraint_IsEqual($value, $delta, $maxDepth);
+ }
+
+ /**
+ *
+ *
+ * @param string $attributeName
+ * @param mixed $value
+ * @param float $delta
+ * @param integer $maxDepth
+ * @return PHPUnit_Framework_Constraint_Attribute
+ * @access public
+ * @since Method available since Release 3.1.0
+ * @static
+ */
+ public static function attributeEqualTo($attributeName, $value, $delta = 0, $maxDepth = 10)
+ {
+ return new PHPUnit_Framework_Constraint_Attribute(
+ new PHPUnit_Framework_Constraint_IsEqual($value, $delta, $maxDepth),
+ $attributeName
+ );
+ }
+
+ /**
+ *
+ *
+ * @return PHPUnit_Framework_Constraint_FileExists
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function fileExists()
+ {
+ return new PHPUnit_Framework_Constraint_FileExists;
+ }
+
+ /**
+ *
+ *
+ * @param mixed $value
+ * @return PHPUnit_Framework_Constraint_GreaterThan
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function greaterThan($value)
+ {
+ return new PHPUnit_Framework_Constraint_GreaterThan($value);
+ }
+
+ /**
+ *
+ *
+ * @param mixed $value
+ * @return PHPUnit_Framework_Constraint_Or
+ * @access public
+ * @since Method available since Release 3.1.0
+ * @static
+ */
+ public static function greaterThanOrEqual($value)
+ {
+ return self::logicalOr(
+ new PHPUnit_Framework_Constraint_IsEqual($value),
+ new PHPUnit_Framework_Constraint_GreaterThan($value)
+ );
+ }
+
+ /**
+ *
+ *
+ * @param string $attributeName
+ * @return PHPUnit_Framework_Constraint_ClassHasAttribute
+ * @access public
+ * @since Method available since Release 3.1.0
+ * @static
+ */
+ public static function classHasAttribute($attributeName)
+ {
+ return new PHPUnit_Framework_Constraint_ClassHasAttribute($attributeName);
+ }
+
+ /**
+ *
+ *
+ * @param string $attributeName
+ * @return PHPUnit_Framework_Constraint_ClassHasStaticAttribute
+ * @access public
+ * @since Method available since Release 3.1.0
+ * @static
+ */
+ public static function classHasStaticAttribute($attributeName)
+ {
+ return new PHPUnit_Framework_Constraint_ClassHasStaticAttribute($attributeName);
+ }
+
+ /**
+ *
+ *
+ * @param string $attributeName
+ * @return PHPUnit_Framework_Constraint_ObjectHasAttribute
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function objectHasAttribute($attributeName)
+ {
+ return new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName);
+ }
+
+ /**
+ *
+ *
+ * @param mixed $value
+ * @return PHPUnit_Framework_Constraint_IsIdentical
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function identicalTo($value)
+ {
+ return new PHPUnit_Framework_Constraint_IsIdentical($value);
+ }
+
+ /**
+ *
+ *
+ * @param string $className
+ * @return PHPUnit_Framework_Constraint_IsInstanceOf
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function isInstanceOf($className)
+ {
+ return new PHPUnit_Framework_Constraint_IsInstanceOf($className);
+ }
+
+ /**
+ *
+ *
+ * @param string $type
+ * @return PHPUnit_Framework_Constraint_IsType
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function isType($type)
+ {
+ return new PHPUnit_Framework_Constraint_IsType($type);
+ }
+
+ /**
+ *
+ *
+ * @param mixed $value
+ * @return PHPUnit_Framework_Constraint_LessThan
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function lessThan($value)
+ {
+ return new PHPUnit_Framework_Constraint_LessThan($value);
+ }
+
+ /**
+ *
+ *
+ * @param mixed $value
+ * @return PHPUnit_Framework_Constraint_Or
+ * @access public
+ * @since Method available since Release 3.1.0
+ * @static
+ */
+ public static function lessThanOrEqual($value)
+ {
+ return self::logicalOr(
+ new PHPUnit_Framework_Constraint_IsEqual($value),
+ new PHPUnit_Framework_Constraint_LessThan($value)
+ );
+ }
+
+ /**
+ *
+ *
+ * @param string $pattern
+ * @return PHPUnit_Framework_Constraint_PCREMatch
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function matchesRegularExpression($pattern)
+ {
+ return new PHPUnit_Framework_Constraint_PCREMatch($pattern);
+ }
+
+ /**
+ *
+ *
+ * @param string $string
+ * @param boolean $case
+ * @return PHPUnit_Framework_Constraint_StringContains
+ * @access public
+ * @since Method available since Release 3.0.0
+ * @static
+ */
+ public static function stringContains($string, $case = TRUE)
+ {
+ return new PHPUnit_Framework_Constraint_StringContains($string, $case);
+ }
+
+
+ /**
+ * Fails a test with the given message.
+ *
+ * @param string $message
+ * @throws PHPUnit_Framework_AssertionFailedError
+ * @access public
+ * @static
+ */
+ public static function fail($message = '')
+ {
+ throw new PHPUnit_Framework_AssertionFailedError($message);
+ }
+
+ /**
+ * Returns the value of an attribute of a class or an object.
+ * This also works for attributes that are declared protected or private.
+ *
+ * @param mixed $classOrObject
+ * @param string $attributeName
+ * @return mixed
+ * @throws InvalidArgumentException
+ * @access protected
+ * @static
+ */
+ public static function readAttribute($classOrObject, $attributeName)
+ {
+ if (!is_string($attributeName)) {
+ throw new InvalidArgumentException;
+ }
+
+ if (is_string($classOrObject)) {
+ if (!class_exists($classOrObject)) {
+ throw new InvalidArgumentException;
+ }
+
+ return self::getStaticAttribute(
+ $classOrObject,
+ $attributeName
+ );
+ }
+
+ else if (is_object($classOrObject)) {
+ return self::getObjectAttribute(
+ $classOrObject,
+ $attributeName
+ );
+ }
+
+ else {
+ throw new InvalidArgumentException;
+ }
+ }
+
+ /**
+ * Returns the value of a static attribute.
+ * This also works for attributes that are declared protected or private.
+ *
+ * @param string $className
+ * @param string $attributeName
+ * @return mixed
+ * @throws InvalidArgumentException
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function getStaticAttribute($className, $attributeName)
+ {
+ if (!is_string($className) || !class_exists($className) || !is_string($attributeName)) {
+ throw new InvalidArgumentException;
+ }
+
+ $class = new ReflectionClass($className);
+ $attributes = $class->getStaticProperties();
+
+ if (isset($attributes[$attributeName])) {
+ return $attributes[$attributeName];
+ }
+
+ if (version_compare(PHP_VERSION, '5.2', '<')) {
+ $protectedName = "\0*\0" . $attributeName;
+ } else {
+ $protectedName = '*' . $attributeName;
+ }
+
+ if (isset($attributes[$protectedName])) {
+ return $attributes[$protectedName];
+ }
+
+ $classes = PHPUnit_Util_Class::getHierarchy($className);
+
+ foreach ($classes as $class) {
+ $privateName = sprintf(
+ "\0%s\0%s",
+
+ $class,
+ $attributeName
+ );
+
+ if (isset($attributes[$privateName])) {
+ return $attributes[$privateName];
+ }
+ }
+
+ throw new RuntimeException(
+ sprintf(
+ 'Attribute "%s" not found in class.',
+
+ $attributeName
+ )
+ );
+ }
+
+ /**
+ * Returns the value of an object's attribute.
+ * This also works for attributes that are declared protected or private.
+ *
+ * @param object $object
+ * @param string $attributeName
+ * @return mixed
+ * @throws InvalidArgumentException
+ * @access public
+ * @static
+ * @since Method available since Release 3.1.0
+ */
+ public static function getObjectAttribute($object, $attributeName)
+ {
+ if (!is_object($object) || !is_string($attributeName)) {
+ throw new InvalidArgumentException;
+ }
+
+ self::assertObjectHasAttribute($attributeName, $object);
+
+ if (property_exists($object, $attributeName)) {
+ return $object->$attributeName;
+ } else {
+ $array = (array) $object;
+ $protectedName = "\0*\0" . $attributeName;
+
+ if (array_key_exists($protectedName, $array)) {
+ return $array[$protectedName];
+ } else {
+ $classes = PHPUnit_Util_Class::getHierarchy(get_class($object));
+
+ foreach ($classes as $class) {
+ $privateName = sprintf(
+ "\0%s\0%s",
+
+ $class,
+ $attributeName
+ );
+
+ if (array_key_exists($privateName, $array)) {
+ return $array[$privateName];
+ }
+ }
+ }
+ }
+
+ throw new RuntimeException(
+ sprintf(
+ 'Attribute "%s" not found in object.',
+
+ $attributeName
+ )
+ );
+ }
+
+ /**
+ * Mark the test as incomplete.
+ *
+ * @param string $message
+ * @throws PHPUnit_Framework_IncompleteTestError
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function markTestIncomplete($message = '')
+ {
+ throw new PHPUnit_Framework_IncompleteTestError($message);
+ }
+
+ /**
+ * Mark the test as skipped.
+ *
+ * @param string $message
+ * @throws PHPUnit_Framework_SkippedTestError
+ * @access public
+ * @static
+ * @since Method available since Release 3.0.0
+ */
+ public static function markTestSkipped($message = '')
+ {
+ throw new PHPUnit_Framework_SkippedTestError($message);
+ }
+}
+
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Framework/AssertionFailedError.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Framework/AssertionFailedError.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Framework/AssertionFailedError.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Framework/AssertionFailedError.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,104 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: AssertionFailedError.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 2.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+if (!class_exists('PHPUnit_Framework_AssertionFailedError', FALSE)) {
+
+/**
+ * Thrown when an assertion failed.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 2.0.0
+ */
+class PHPUnit_Framework_AssertionFailedError extends Exception implements PHPUnit_Framework_SelfDescribing
+{
+ /**
+ * Returns the location where this failure occured.
+ *
+ * @return array
+ * @access public
+ * @since Method available since Release 3.0.0
+ */
+ public function getLocation()
+ {
+ foreach ($this->getTrace() as $frame) {
+ if (!isset($frame['line'])) {
+ break;
+ }
+
+ $result = array(
+ 'file' => $frame['file'],
+ 'line' => $frame['line']
+ );
+ }
+
+ return $result;
+ }
+
+ /**
+ * Wrapper for getMessage() which is declared as final.
+ *
+ * @return string
+ * @access public
+ */
+ public function toString()
+ {
+ return $this->getMessage();
+ }
+}
+
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,279 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: ComparisonFailure.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 2.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/Type.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+if (!class_exists('PHPUnit_Framework_ComparisonFailure', FALSE)) {
+
+/**
+ * Thrown when an assertion for string equality failed.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 2.0.0
+ */
+abstract class PHPUnit_Framework_ComparisonFailure extends PHPUnit_Framework_AssertionFailedError
+{
+ /**
+ * Expected value of the retrieval which does not match $actual.
+ * @var mixed
+ */
+ protected $expected;
+
+ /**
+ * Actually retrieved value which does not match $expected.
+ * @var mixed
+ */
+ protected $actual;
+
+ /**
+ * @var boolean
+ */
+ protected $identical;
+
+ /**
+ * Optional message which is placed in front of the first line
+ * returned by toString().
+ * @var string
+ */
+ protected $message;
+
+ /**
+ * @var boolean
+ */
+ protected static $hasDiff = NULL;
+
+ /**
+ * Initialises with the expected value and the actual value.
+ *
+ * @param mixed $expected Expected value retrieved.
+ * @param mixed $actual Actual value retrieved.
+ * @param boolean $identical
+ * @param string $message A string which is prefixed on all returned lines
+ * in the difference output.
+ */
+ public function __construct($expected, $actual, $identical = FALSE, $message = '')
+ {
+ $this->expected = $expected;
+ $this->actual = $actual;
+ $this->identical = $identical;
+ $this->message = $message;
+ }
+
+ public function getActual()
+ {
+ return $this->actual;
+ }
+
+ public function getExpected()
+ {
+ return $this->expected;
+ }
+
+ public function identical()
+ {
+ return $this->identical;
+ }
+
+ /**
+ * Figures out which diff class to use for the input types then
+ * instantiates that class and returns the object.
+ * @note The diff is type sensitive, if the type differs only the types
+ * are shown.
+ *
+ * @param mixed $expected Expected value retrieved.
+ * @param mixed $actual Actual value retrieved.
+ * @param string $message A string which is prefixed on all returned lines
+ * in the difference output.
+ * @return PHPUnit_Framework_ComparisonFailure
+ */
+ public static function diffIdentical($expected, $actual, $message = '')
+ {
+ if (gettype($expected) !== gettype($actual)) {
+ return new PHPUnit_Framework_ComparisonFailure_Type($expected, $actual, TRUE, $message);
+ }
+
+ elseif (is_string($expected)) {
+ return new PHPUnit_Framework_ComparisonFailure_String($expected, $actual, TRUE, $message);
+ }
+
+ elseif (is_null($expected) || is_scalar($expected)) {
+ return new PHPUnit_Framework_ComparisonFailure_Scalar($expected, $actual, TRUE, $message);
+ }
+
+ elseif (is_array($expected)) {
+ return new PHPUnit_Framework_ComparisonFailure_Array($expected, $actual, TRUE, $message);
+ }
+
+ elseif (is_object($expected)) {
+ return new PHPUnit_Framework_ComparisonFailure_Object($expected, $actual, TRUE, $message);
+ }
+ }
+
+ /**
+ * Figures out which diff class to use for the input types then
+ * instantiates that class and returns the object.
+ * @note The diff is not type sensitive, if the type differs the $actual
+ * value will be converted to the same type as the $expected.
+ *
+ * @param mixed $expected Expected value retrieved.
+ * @param mixed $actual Actual value retrieved.
+ * @param string $message 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_string($expected) && !is_object($actual)) {
+ return new PHPUnit_Framework_ComparisonFailure_String($expected, $actual, FALSE, $message);
+ }
+
+ elseif (is_null($expected) || is_scalar($expected)) {
+ return new PHPUnit_Framework_ComparisonFailure_Scalar($expected, $actual, FALSE, $message);
+ }
+
+ elseif (is_array($expected)) {
+ return new PHPUnit_Framework_ComparisonFailure_Array($expected, $actual, FALSE, $message);
+ }
+
+ elseif (is_object($expected)) {
+ return new PHPUnit_Framework_ComparisonFailure_Object($expected, $actual, FALSE, $message);
+ }
+ }
+
+ protected function diff($expected, $actual)
+ {
+ $expectedFile = tempnam('/tmp', 'expected');
+ file_put_contents($expectedFile, $expected);
+
+ $actualFile = tempnam('/tmp', 'actual');
+ file_put_contents($actualFile, $actual);
+
+ $buffer = shell_exec(
+ sprintf(
+ 'diff -u %s %s',
+ $expectedFile,
+ $actualFile
+ )
+ );
+
+ unlink($expectedFile);
+ unlink($actualFile);
+
+ if (!empty($buffer)) {
+ $buffer = explode("\n", $buffer);
+
+ $buffer[0] = "--- Expected";
+ $buffer[1] = "+++ Actual";
+
+ return implode("\n", $buffer);
+ }
+
+ return '';
+ }
+
+ public static function hasDiff()
+ {
+ if (self::$hasDiff === NULL)
+ {
+ self::$hasDiff = FALSE;
+
+ $binary = 'diff';
+
+ if (substr(php_uname('s'), 0, 7) == 'Windows')
+ {
+ $binary .= '.exe';
+ }
+
+ if (isset($_ENV['PATH'])) {
+ $paths = explode(PATH_SEPARATOR, $_ENV['PATH']);
+ }
+
+ else if (isset($_ENV['Path'])) {
+ $paths = explode(PATH_SEPARATOR, $_ENV['Path']);
+ }
+
+ else if (isset($_SERVER['PATH'])) {
+ $paths = explode(PATH_SEPARATOR, $_SERVER['PATH']);
+ }
+
+ else {
+ $paths = array();
+ }
+
+ foreach ($paths as $path) {
+ if (file_exists($path . DIRECTORY_SEPARATOR . $binary) &&
+ is_executable($path . DIRECTORY_SEPARATOR . $binary))
+ {
+ self::$hasDiff = TRUE;
+ break;
+ }
+ }
+ }
+
+ return self::$hasDiff;
+ }
+}
+
+}
+
+require_once 'PHPUnit/Framework/ComparisonFailure/Array.php';
+require_once 'PHPUnit/Framework/ComparisonFailure/Object.php';
+require_once 'PHPUnit/Framework/ComparisonFailure/Scalar.php';
+require_once 'PHPUnit/Framework/ComparisonFailure/String.php';
+require_once 'PHPUnit/Framework/ComparisonFailure/Type.php';
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Array.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Array.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Array.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Array.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,119 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Array.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Thrown when an assertion for array equality failed.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.0.0
+ */
+class PHPUnit_Framework_ComparisonFailure_Array extends PHPUnit_Framework_ComparisonFailure
+{
+ /**
+ * Returns a string describing the difference between the expected and the
+ * actual array.
+ *
+ * @note Diffing is only done for one level.
+ */
+ public function toString()
+ {
+ if ($this->hasDiff()) {
+ return $this->diff(
+ print_r($this->expected, TRUE),
+ print_r($this->actual, TRUE)
+ );
+ }
+
+ $expectedOnly = array();
+ $actualOnly = array();
+ $diff = '';
+
+ foreach($this->expected as $expectedKey => $expectedValue) {
+ if (!array_key_exists($expectedKey, $this->actual)) {
+ $expectedOnly[] = $expectedKey;
+ continue;
+ }
+
+ if ($expectedValue === $this->actual[$expectedKey]) continue;
+
+ $diffObject = PHPUnit_Framework_ComparisonFailure::diffIdentical($expectedValue, $this->actual[$expectedKey], $this->message . "array key <{$expectedKey}>: ");
+ $diff .= $diffObject->toString() . "\n";
+ }
+
+ foreach($this->actual as $actualKey => $actualValue) {
+ if (!array_key_exists($actualKey, $this->expected)) {
+ $actualOnly[] = $actualKey;
+ continue;
+ }
+ }
+
+ foreach($expectedOnly as $expectedKey) {
+ $expectedValue = $this->expected[$expectedKey];
+ $diff .= "array key <{$expectedKey}>: only in expected <{$expectedValue}>\n";
+ }
+
+ foreach($actualOnly as $actualKey) {
+ $actualValue = $this->actual[$actualKey];
+ $diff .= "array key <{$actualKey}>: only in actual <{$actualValue}>\n";
+ }
+
+ return $diff;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Object.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Object.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Object.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Object.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,144 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Object.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Thrown when an assertion for object equality failed.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.0.0
+ */
+class PHPUnit_Framework_ComparisonFailure_Object extends PHPUnit_Framework_ComparisonFailure
+{
+ /**
+ * Returns a string describing the difference between the expected and the
+ * actual object.
+ *
+ * @note Diffing is only done for one level.
+ */
+ public function toString()
+ {
+ if ($this->hasDiff()) {
+ return $this->diff(
+ print_r($this->expected, TRUE),
+ print_r($this->actual, TRUE)
+ );
+ }
+
+ $expectedClass = get_class($this->expected);
+ $actualClass = get_class($this->actual);
+
+ if ($expectedClass !== $actualClass) {
+ return sprintf(
+ "%s%sexpected class <%s>\n" .
+ '%sgot class <%s>',
+
+ $this->message,
+ ($this->message != '') ? ' ' : '',
+ $expectedClass,
+ ($this->message != '') ? str_repeat(' ', strlen($this->message) + 1) : '',
+ $actualClass
+ );
+ } else {
+ $expectedReflection = new ReflectionClass($expectedClass);
+ $actualReflection = new ReflectionClass($actualClass);
+
+ $diff = "in object of class <{$expectedClass}>:\n";
+ $i = 0;
+
+ foreach($expectedReflection->getProperties() as $expectedAttribute) {
+ if ($expectedAttribute->isPrivate() || $expectedAttribute->isProtected()) continue;
+
+ $actualAttribute = $actualReflection->getProperty($expectedAttribute->getName());
+ $expectedValue = $expectedAttribute->getValue($this->expected);
+ $actualValue = $actualAttribute->getValue($this->actual);
+
+ if ($expectedValue !== $actualValue) {
+ if ($i > 0) {
+ $diff .= "\n";
+ }
+
+ ++$i;
+
+ $expectedType = gettype($expectedValue);
+ $actualType = gettype($actualValue);
+
+ if ($expectedType !== $actualType) {
+ $diffObject = new PHPUnit_Framework_ComparisonFailure_Type($expectedValue, $actualValue, $this->message . 'attribute <' . $expectedAttribute->getName() . '>: ');
+ $diff .= $diffObject->toString();
+ }
+
+ elseif (is_object($expectedValue)) {
+ if (get_class($expectedValue) !== get_class($actualValue)) {
+ $diffObject = new PHPUnit_Framework_ComparisonFailure_Type($expectedValue, $actualValue, $this->message . 'attribute <' . $expectedAttribute->getName() . '>: ');
+ $diff .= $diffObject->toString();
+ } else {
+ $diff .= 'attribute <' . $expectedAttribute->getName() . '> contains object <' . get_class($expectedValue) . '> with different attributes';
+ }
+ } else {
+ $diffObject = PHPUnit_Framework_ComparisonFailure::diffIdentical($expectedValue, $actualValue, $this->message . 'attribute <' . $expectedAttribute->getName() . '>: ');
+ $diff .= $diffObject->toString();
+ }
+ }
+ }
+
+ return $diff;
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Scalar.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Scalar.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Scalar.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/Scalar.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,108 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Scalar.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Thrown when an assertion for scalar equality failed.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.0.0
+ */
+class PHPUnit_Framework_ComparisonFailure_Scalar extends PHPUnit_Framework_ComparisonFailure
+{
+ /**
+ * Returns a string describing the difference between the expected and the
+ * actual scalar value.
+ */
+ public function toString()
+ {
+ if (is_int($this->expected) || is_float($this->expected)) {
+ $type = gettype($this->expected);
+ $expectedString = print_r($this->expected, TRUE);
+ $actualString = print_r($this->actual, TRUE);
+ $differenceString = print_r(abs($this->actual - $this->expected), TRUE);
+
+ $expectedLen = strlen($expectedString);
+ $actualLen = strlen($actualString);
+ $differenceLen = strlen($differenceString);
+ $maxLen = max($expectedLen, $actualLen, $differenceLen);
+
+ $expectedString = str_pad($expectedString, $maxLen, ' ', STR_PAD_LEFT);
+ $differenceString = str_pad($differenceString, $maxLen, ' ', STR_PAD_LEFT);
+ $actualString = str_pad($actualString, $maxLen, ' ', STR_PAD_LEFT);
+
+ return sprintf(
+ "%s%sexpected %s <%s>\n" .
+ "%sdifference%s<%s>\n" .
+ '%sgot %s <%s>',
+
+ $this->message,
+ ($this->message != '') ? ' ' : '',
+ $type,
+ $expectedString,
+ ($this->message != '') ? str_repeat(' ', strlen($this->message) + 1) : '',
+ str_repeat(' ', strlen($type)),
+ $differenceString,
+ ($this->message != '') ? str_repeat(' ', strlen($this->message) + 1) : '',
+ $type,
+ $actualString
+ );
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/String.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/String.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/String.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Framework/ComparisonFailure/String.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,120 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: String.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Thrown when an assertion for string equality failed.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Jan Borsodi <jb...@ez.no>
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.0.0
+ */
+class PHPUnit_Framework_ComparisonFailure_String extends PHPUnit_Framework_ComparisonFailure
+{
+ /**
+ * Returns a string describing the difference between
+ * the expected and the actual string value.
+ */
+ public function toString()
+ {
+ $expected = (string)$this->expected;
+ $actual = (string)$this->actual;
+
+ if (strpos($expected, "\n") !== FALSE || strpos($actual, "\n") !== FALSE) {
+ if ($this->hasDiff()) {
+ return $this->diff($expected, $actual);
+ } else {
+ return '';
+ }
+ }
+
+ $expectedLen = strlen($expected);
+ $actualLen = strlen($actual);
+ $minLen = min($expectedLen, $actualLen);
+ $maxLen = max($expectedLen, $actualLen);
+
+ for ($i = 0; $i < $minLen; ++$i) {
+ if ($expected[$i] != $actual[$i]) break;
+ }
+
+ $startPos = $i;
+ $endPos = $minLen;
+
+ if ($minLen > 0) {
+ for ($i = $minLen - 1; $i > $startPos; --$i) {
+ if ($expected[$i] != $actual[$i]) break;
+ }
+
+ $endPos = $i + 1;
+ }
+
+ return sprintf(
+ "%s%sexpected string <%s>\n" .
+ "%sdifference <%s>\n" .
+ '%sgot string <%s>',
+
+ $this->message,
+ ($this->message != '') ? ' ' : '',
+ $expected,
+ ($this->message != '') ? str_repeat(' ', strlen($this->message) + 1) : '',
+ str_repeat(' ', $startPos) . str_repeat('x', $endPos - $startPos) . str_repeat('?', $maxLen - $minLen),
+ ($this->message != '') ? str_repeat(' ', strlen($this->message) + 1) : '',
+ $actual
+ );
+ }
+}
+?>