From 17f49a9bc71d88c9b3e2f31a161f3689c136ac16 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 1 Dec 2006 12:28:55 +0000 Subject: merge from 3.0 branch till 1531. --- tests/test_tools/simpletest/expectation.php | 114 ++++++++++++++-------------- 1 file changed, 57 insertions(+), 57 deletions(-) (limited to 'tests/test_tools/simpletest/expectation.php') diff --git a/tests/test_tools/simpletest/expectation.php b/tests/test_tools/simpletest/expectation.php index 9c514119..a27149ff 100644 --- a/tests/test_tools/simpletest/expectation.php +++ b/tests/test_tools/simpletest/expectation.php @@ -5,14 +5,14 @@ * @subpackage UnitTester * @version $Id$ */ - + /**#@+ * include other SimpleTest class files */ require_once(dirname(__FILE__) . '/dumper.php'); require_once(dirname(__FILE__) . '/compatibility.php'); /**#@-*/ - + /** * Assertion that can display failure information. * Also includes various helper methods. @@ -23,7 +23,7 @@ class SimpleExpectation { protected $_dumper; protected $_message; - + /** * Creates a dumper for displaying values and sets * the test message. @@ -33,7 +33,7 @@ $this->_dumper = new SimpleDumper(); $this->_message = $message; } - + /** * Tests the expectation. True if correct. * @param mixed $compare Comparison value. @@ -43,7 +43,7 @@ */ function test($compare) { } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. @@ -54,7 +54,7 @@ */ function testMessage($compare) { } - + /** * Overlays the generated message onto the stored user * message. An additional message can be interjected. @@ -66,7 +66,7 @@ function overlayMessage($compare) { return sprintf($this->_message, $this->testMessage($compare)); } - + /** * Accessor for the dumper. * @return SimpleDumper Current value dumper. @@ -75,7 +75,7 @@ function &_getDumper() { return $this->_dumper; } - + /** * Test to see if a value is an expectation object. * A useful utility method. @@ -86,12 +86,12 @@ * @access public * @static */ - function isExpectation($expectation) { + static function isExpectation($expectation) { return is_object($expectation) && SimpleTestCompatibility::isA($expectation, 'SimpleExpectation'); } } - + /** * Test for equality. * @package SimpleTest @@ -99,7 +99,7 @@ */ class EqualExpectation extends SimpleExpectation { protected $_value; - + /** * Sets the value to compare against. * @param mixed $value Test value to match. @@ -110,7 +110,7 @@ $this->SimpleExpectation($message); $this->_value = $value; } - + /** * Tests the expectation. True if it matches the * held value. @@ -121,7 +121,7 @@ function test($compare) { return (($this->_value == $compare) && ($compare == $this->_value)); } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. @@ -147,14 +147,14 @@ return $this->_value; } } - + /** * Test for inequality. * @package SimpleTest * @subpackage UnitTester */ class NotEqualExpectation extends EqualExpectation { - + /** * Sets the value to compare against. * @param mixed $value Test value to match. @@ -164,7 +164,7 @@ function NotEqualExpectation($value, $message = '%s') { $this->EqualExpectation($value, $message); } - + /** * Tests the expectation. True if it differs from the * held value. @@ -175,7 +175,7 @@ function test($compare) { return ! parent::test($compare); } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. @@ -195,7 +195,7 @@ } } } - + /** * Test for being within a range. * @package SimpleTest @@ -204,7 +204,7 @@ class WithinMarginExpectation extends SimpleExpectation { protected $_upper; protected $_lower; - + /** * Sets the value to compare against and the fuzziness of * the match. Used for comparing floating point values. @@ -218,7 +218,7 @@ $this->_upper = $value + $margin; $this->_lower = $value - $margin; } - + /** * Tests the expectation. True if it matches the * held value. @@ -229,7 +229,7 @@ function test($compare) { return (($compare <= $this->_upper) && ($compare >= $this->_lower)); } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. @@ -244,7 +244,7 @@ return $this->_outsideMessage($compare); } } - + /** * Creates a the message for being within the range. * @param mixed $compare Value being tested. @@ -254,7 +254,7 @@ return "Within expectation [" . $this->_dumper->describeValue($this->_lower) . "] and [" . $this->_dumper->describeValue($this->_upper) . "]"; } - + /** * Creates a the message for being within the range. * @param mixed $compare Value being tested. @@ -270,14 +270,14 @@ } } } - + /** * Test for being outside of a range. * @package SimpleTest * @subpackage UnitTester */ class OutsideMarginExpectation extends WithinMarginExpectation { - + /** * Sets the value to compare against and the fuzziness of * the match. Used for comparing floating point values. @@ -289,7 +289,7 @@ function OutsideMarginExpectation($value, $margin, $message = '%s') { $this->WithinMarginExpectation($value, $margin, $message); } - + /** * Tests the expectation. True if it matches the * held value. @@ -300,7 +300,7 @@ function test($compare) { return ! parent::test($compare); } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. @@ -316,14 +316,14 @@ } } } - + /** * Test for identity. * @package SimpleTest * @subpackage UnitTester */ class IdenticalExpectation extends EqualExpectation { - + /** * Sets the value to compare against. * @param mixed $value Test value to match. @@ -333,7 +333,7 @@ function IdenticalExpectation($value, $message = '%s') { $this->EqualExpectation($value, $message); } - + /** * Tests the expectation. True if it exactly * matches the held value. @@ -344,7 +344,7 @@ function test($compare) { return SimpleTestCompatibility::isIdentical($this->_getValue(), $compare); } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. @@ -364,14 +364,14 @@ } } } - + /** * Test for non-identity. * @package SimpleTest * @subpackage UnitTester */ class NotIdenticalExpectation extends IdenticalExpectation { - + /** * Sets the value to compare against. * @param mixed $value Test value to match. @@ -381,7 +381,7 @@ function NotIdenticalExpectation($value, $message = '%s') { $this->IdenticalExpectation($value, $message); } - + /** * Tests the expectation. True if it differs from the * held value. @@ -392,7 +392,7 @@ function test($compare) { return ! parent::test($compare); } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. @@ -410,7 +410,7 @@ } } } - + /** * Test for a pattern using Perl regex rules. * @package SimpleTest @@ -418,7 +418,7 @@ */ class PatternExpectation extends SimpleExpectation { protected $_pattern; - + /** * Sets the value to compare against. * @param string $pattern Pattern to search for. @@ -429,7 +429,7 @@ $this->SimpleExpectation($message); $this->_pattern = $pattern; } - + /** * Accessor for the pattern. * @return string Perl regex as string. @@ -438,7 +438,7 @@ function _getPattern() { return $this->_pattern; } - + /** * Tests the expectation. True if the Perl regex * matches the comparison value. @@ -449,7 +449,7 @@ function test($compare) { return (boolean)preg_match($this->_getPattern(), $compare); } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. @@ -467,7 +467,7 @@ $dumper->describeValue($compare) . "]"; } } - + /** * Describes a pattern match including the string * found and it's position. @@ -487,13 +487,13 @@ $dumper->clipString($subject, 100, $position) . "]"; } } - + /** * @deprecated */ class WantedPatternExpectation extends PatternExpectation { } - + /** * Fail if a pattern is detected within the * comparison. @@ -501,7 +501,7 @@ * @subpackage UnitTester */ class NoPatternExpectation extends PatternExpectation { - + /** * Sets the reject pattern * @param string $pattern Pattern to search for. @@ -511,7 +511,7 @@ function NoPatternExpectation($pattern, $message = '%s') { $this->PatternExpectation($pattern, $message); } - + /** * Tests the expectation. False if the Perl regex * matches the comparison value. @@ -522,7 +522,7 @@ function test($compare) { return ! parent::test($compare); } - + /** * Returns a human readable test message. * @param string $compare Comparison value. @@ -541,7 +541,7 @@ } } } - + /** * @package SimpleTest * @subpackage UnitTester @@ -549,7 +549,7 @@ */ class UnwantedPatternExpectation extends NoPatternExpectation { } - + /** * Tests either type or class name if it's an object. * @package SimpleTest @@ -557,7 +557,7 @@ */ class IsAExpectation extends SimpleExpectation { protected $_type; - + /** * Sets the type to compare with. * @param string $type Type or class name. @@ -568,7 +568,7 @@ $this->SimpleExpectation($message); $this->_type = $type; } - + /** * Accessor for type to check against. * @return string Type or class name. @@ -577,7 +577,7 @@ function _getType() { return $this->_type; } - + /** * Tests the expectation. True if the type or * class matches the string value. @@ -625,7 +625,7 @@ "] should be type [" . $this->_type . "]"; } } - + /** * Tests either type or class name if it's an object. * Will succeed if the type does not match. @@ -634,7 +634,7 @@ */ class NotAExpectation extends IsAExpectation { protected $_type; - + /** * Sets the type to compare with. * @param string $type Type or class name. @@ -644,7 +644,7 @@ function NotAExpectation($type, $message = '%s') { $this->IsAExpectation($type, $message); } - + /** * Tests the expectation. False if the type or * class matches the string value. @@ -677,7 +677,7 @@ */ class MethodExistsExpectation extends SimpleExpectation { protected $_method; - + /** * Sets the value to compare against. * @param string $method Method to check. @@ -689,7 +689,7 @@ $this->SimpleExpectation($message); $this->_method = $method; } - + /** * Tests the expectation. True if the method exists in the test object. * @param string $compare Comparison method name. @@ -699,7 +699,7 @@ function test($compare) { return (boolean)(is_object($compare) && method_exists($compare, $this->_method)); } - + /** * Returns a human readable test message. * @param mixed $compare Comparison value. -- cgit v1.2.3