cvs: pear /PHPUnit2/Framework Constraint.php SelfDescribing.php /PHPUnit2/Framework/Constraint And.php ArrayHasKey.php FileExists.php GreaterThan.php
HasProperty.php IsAnything.php IsEqual.php IsIdentical.php IsInstanceOf.php IsType.php LessThan.php Not.php Or.php PCREMatch.php StringContains.php
TraversableContains.php

From: Date: Sat, 21 Jan 2006 12:01:00 +0000
Subject: cvs: pear /PHPUnit2/Framework Constraint.php SelfDescribing.php /PHPUnit2/Framework/Constraint And.php ArrayHasKey.php FileExists.php GreaterThan.php
HasProperty.php IsAnything.php IsEqual.php IsIdentical.php IsInstanceOf.php IsType.php LessThan.php Not.php Or.php PCREMatch.php StringContains.php
TraversableContains.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-37670@lists.php.net to get a copy of this message
sebastian Sat Jan 21 12:01:00 2006 UTC Modified files: /pear/PHPUnit2/Framework Constraint.php SelfDescribing.php /pear/PHPUnit2/Framework/Constraint And.php ArrayHasKey.php FileExists.php GreaterThan.php HasProperty.php IsAnything.php IsEqual.php IsIdentical.php IsInstanceOf.php IsType.php LessThan.php Not.php Or.php PCREMatch.php StringContains.php TraversableContains.php Log: Flush.

http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint.php?r1=1.3&r2=1.4&diff_format=u Index: pear/PHPUnit2/Framework/Constraint.php diff -u pear/PHPUnit2/Framework/Constraint.php:1.3 pear/PHPUnit2/Framework/Constraint.php:1.4 --- pear/PHPUnit2/Framework/Constraint.php:1.3 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Constraint.php,v 1.3 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: Constraint.php,v 1.4 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -82,8 +82,8 @@ interface PHPUnit2_Framework_Constraint extends PHPUnit2_Framework_SelfDescribing { /** - * Evaluates the constraint for parameter $other. Returns true if the - * constraint is met, false otherwise. + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. * * @parameter mixed $other Value or object to evaluate. * @return bool @@ -94,11 +94,11 @@ * Creates the appropriate exception for the constraint which can be caught * by the unit test system. This can be called if a call to evaluate() fails. * - * @param mixed $other The value passed to evaluate() which failed the - * constraint check. - * @param string $description A string with extra description of what was - * going on while the evaluation failed. - * @throw PHPUnit2_Framework_ExpectationFailedException + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException */ public function fail($other, $description); } http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/SelfDescribing.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/SelfDescribing.php diff -u pear/PHPUnit2/Framework/SelfDescribing.php:1.2 pear/PHPUnit2/Framework/SelfDescribing.php:1.3 --- pear/PHPUnit2/Framework/SelfDescribing.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/SelfDescribing.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: SelfDescribing.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: SelfDescribing.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -70,7 +70,6 @@ * * @return string * @access public - * @since Method available since Release 3.0.0 */ public function toString(); } http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/And.php?r1=1.4&r2=1.5&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/And.php diff -u pear/PHPUnit2/Framework/Constraint/And.php:1.4 pear/PHPUnit2/Framework/Constraint/And.php:1.5 --- pear/PHPUnit2/Framework/Constraint/And.php:1.4 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/And.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: And.php,v 1.4 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: And.php,v 1.5 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -94,21 +94,13 @@ } } - public function toString() - { - $text = ''; - - foreach($this->constraints as $key => $constraint) { - if ($key > 0) { - $text .= ' and '; - } - - $text .= $constraint->toString(); - } - - return $text; - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { $this->failedConstraint = NULL; @@ -124,6 +116,13 @@ return TRUE; } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { if ($this->failedConstraint !== NULL) { @@ -144,6 +143,27 @@ ); } } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + $text = ''; + + foreach($this->constraints as $key => $constraint) { + if ($key > 0) { + $text .= ' and '; + } + + $text .= $constraint->toString(); + } + + return $text; + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/ArrayHasKey.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/ArrayHasKey.php diff -u pear/PHPUnit2/Framework/Constraint/ArrayHasKey.php:1.2 pear/PHPUnit2/Framework/Constraint/ArrayHasKey.php:1.3 --- pear/PHPUnit2/Framework/Constraint/ArrayHasKey.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/ArrayHasKey.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: ArrayHasKey.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: ArrayHasKey.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -86,21 +86,25 @@ $this->key = $key; } - public function toString() - { - return sprintf( - 'has key <%s:%s>', - - gettype($this->key), - var_export($this->key, TRUE) - ); - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { return array_key_exists($this->key, $other); } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { throw new PHPUnit2_Framework_ExpectationFailedException( @@ -114,6 +118,22 @@ ) ); } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + return sprintf( + 'has key <%s:%s>', + + gettype($this->key), + var_export($this->key, TRUE) + ); + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/FileExists.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/FileExists.php diff -u pear/PHPUnit2/Framework/Constraint/FileExists.php:1.2 pear/PHPUnit2/Framework/Constraint/FileExists.php:1.3 --- pear/PHPUnit2/Framework/Constraint/FileExists.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/FileExists.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: FileExists.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: FileExists.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -76,16 +76,25 @@ */ class PHPUnit2_Framework_Constraint_FileExists implements PHPUnit2_Framework_Constraint { - public function toString() - { - return 'file exists'; - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { return file_exists($other); } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { throw new PHPUnit2_Framework_ExpectationFailedException( @@ -97,6 +106,17 @@ ) ); } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + return 'file exists'; + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/GreaterThan.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/GreaterThan.php diff -u pear/PHPUnit2/Framework/Constraint/GreaterThan.php:1.2 pear/PHPUnit2/Framework/Constraint/GreaterThan.php:1.3 --- pear/PHPUnit2/Framework/Constraint/GreaterThan.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/GreaterThan.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: GreaterThan.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: GreaterThan.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -83,6 +83,39 @@ $this->value = $value; } + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ + public function evaluate($other) + { + return $this->value < $other; + } + + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ + public function fail($other, $description) + { + throw new PHPUnit2_Framework_ExpectationFailedException( + $description, + PHPUnit2_Framework_ComparisonFailure::diffIdentical($this->value, $other) + ); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ public function toString() { $type = ''; @@ -97,19 +130,6 @@ $type . var_export($this->value, TRUE) ); } - - public function evaluate($other) - { - return $this->value < $other; - } - - public function fail($other, $description) - { - throw new PHPUnit2_Framework_ExpectationFailedException( - $description, - PHPUnit2_Framework_ComparisonFailure::diffIdentical($this->value, $other) - ); - } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/HasProperty.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/HasProperty.php diff -u pear/PHPUnit2/Framework/Constraint/HasProperty.php:1.2 pear/PHPUnit2/Framework/Constraint/HasProperty.php:1.3 --- pear/PHPUnit2/Framework/Constraint/HasProperty.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/HasProperty.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: HasProperty.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: HasProperty.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -102,17 +102,13 @@ return $this; } - public function toString() - { - $text = 'contains property <' . var_export($this->property, TRUE) . '>'; - - if ($this->valueConstraint !== NULL) { - $text .= ' that ' . $this->valueConstraint->toString(); - } - - return $text; - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { if (!is_object($other)) { @@ -140,6 +136,13 @@ return TRUE; } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { if ($this->valueConstraintFailed) { @@ -165,6 +168,23 @@ ); } } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + $text = 'contains property <' . var_export($this->property, TRUE) . '>'; + + if ($this->valueConstraint !== NULL) { + $text .= ' that ' . $this->valueConstraint->toString(); + } + + return $text; + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/IsAnything.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/IsAnything.php diff -u pear/PHPUnit2/Framework/Constraint/IsAnything.php:1.2 pear/PHPUnit2/Framework/Constraint/IsAnything.php:1.3 --- pear/PHPUnit2/Framework/Constraint/IsAnything.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/IsAnything.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: IsAnything.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: IsAnything.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -73,19 +73,38 @@ */ class PHPUnit2_Framework_Constraint_IsAnything implements PHPUnit2_Framework_Constraint { - public function toString() - { - return 'can be anything'; - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { return TRUE; } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + */ public function fail($other, $description) { } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + return 'can be anything'; + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/IsEqual.php?r1=1.4&r2=1.5&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/IsEqual.php diff -u pear/PHPUnit2/Framework/Constraint/IsEqual.php:1.4 pear/PHPUnit2/Framework/Constraint/IsEqual.php:1.5 --- pear/PHPUnit2/Framework/Constraint/IsEqual.php:1.4 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/IsEqual.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: IsEqual.php,v 1.4 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: IsEqual.php,v 1.5 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -89,31 +89,13 @@ $this->delta = $delta; } - public function toString() - { - $delta = ''; - $type = ''; - - if ($this->delta != 0) { - $delta = sprintf( - ' with delta <%d>', - - $this->delta - ); - } - - if (!is_null($this->value)) { - $type = gettype($this->value) . ':'; - } - - return sprintf( - 'is equal to <%s>%s', - - $type . var_export($this->value, TRUE), - $delta - ); - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { $equal = FALSE; @@ -141,6 +123,13 @@ return $equal; } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { throw new PHPUnit2_Framework_ExpectationFailedException( @@ -168,6 +157,37 @@ return $array; } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + $delta = ''; + $type = ''; + + if ($this->delta != 0) { + $delta = sprintf( + ' with delta <%d>', + + $this->delta + ); + } + + if (!is_null($this->value)) { + $type = gettype($this->value) . ':'; + } + + return sprintf( + 'is equal to <%s>%s', + + $type . var_export($this->value, TRUE), + $delta + ); + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/IsIdentical.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/IsIdentical.php diff -u pear/PHPUnit2/Framework/Constraint/IsIdentical.php:1.2 pear/PHPUnit2/Framework/Constraint/IsIdentical.php:1.3 --- pear/PHPUnit2/Framework/Constraint/IsIdentical.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/IsIdentical.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: IsIdentical.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: IsIdentical.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -88,6 +88,39 @@ $this->value = $value; } + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ + public function evaluate($other) + { + return $this->value === $other; + } + + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ + public function fail( $other, $description ) + { + throw new PHPUnit2_Framework_ExpectationFailedException( + $description, + PHPUnit2_Framework_ComparisonFailure::diffIdentical($this->value, $other) + ); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ public function toString() { $type = ''; @@ -103,19 +136,6 @@ var_export($this->value, TRUE) ); } - - public function evaluate($other) - { - return $this->value === $other; - } - - public function fail( $other, $description ) - { - throw new PHPUnit2_Framework_ExpectationFailedException( - $description, - PHPUnit2_Framework_ComparisonFailure::diffIdentical($this->value, $other) - ); - } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/IsInstanceOf.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/IsInstanceOf.php diff -u pear/PHPUnit2/Framework/Constraint/IsInstanceOf.php:1.2 pear/PHPUnit2/Framework/Constraint/IsInstanceOf.php:1.3 --- pear/PHPUnit2/Framework/Constraint/IsInstanceOf.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/IsInstanceOf.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: IsInstanceOf.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: IsInstanceOf.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -83,20 +83,25 @@ $this->className = $className; } - public function toString() - { - return sprintf( - 'is instance of <%s>', - - $this->className - ); - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { return ($other instanceof $this->className); } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { if (!is_object($other)) { @@ -122,6 +127,21 @@ ); } } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + return sprintf( + 'is instance of <%s>', + + $this->className + ); + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/IsType.php?r1=1.3&r2=1.4&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/IsType.php diff -u pear/PHPUnit2/Framework/Constraint/IsType.php:1.3 pear/PHPUnit2/Framework/Constraint/IsType.php:1.4 --- pear/PHPUnit2/Framework/Constraint/IsType.php:1.3 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/IsType.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: IsType.php,v 1.3 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: IsType.php,v 1.4 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -108,15 +108,13 @@ $this->type = $type; } - public function toString() - { - return sprintf( - 'is type <%s>', - - $this->type - ); - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { switch ($this->type) { @@ -152,6 +150,13 @@ } } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { switch ($this->type) { @@ -198,6 +203,21 @@ new PHPUnit2_Framework_ComparisonFailure_Type($expected, $other) ); } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + return sprintf( + 'is type <%s>', + + $this->type + ); + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/LessThan.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/LessThan.php diff -u pear/PHPUnit2/Framework/Constraint/LessThan.php:1.2 pear/PHPUnit2/Framework/Constraint/LessThan.php:1.3 --- pear/PHPUnit2/Framework/Constraint/LessThan.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/LessThan.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: LessThan.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: LessThan.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -84,6 +84,39 @@ $this->value = $value; } + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ + public function evaluate($other) + { + return $this->value > $other; + } + + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ + public function fail($other, $description) + { + throw new PHPUnit2_Framework_ExpectationFailedException( + $description, + PHPUnit2_Framework_ComparisonFailure::diffIdentical($this->value, $other) + ); + } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ public function toString() { $type = ''; @@ -98,19 +131,6 @@ $type . var_export($this->value, TRUE) ); } - - public function evaluate($other) - { - return $this->value > $other; - } - - public function fail($other, $description) - { - throw new PHPUnit2_Framework_ExpectationFailedException( - $description, - PHPUnit2_Framework_ComparisonFailure::diffIdentical($this->value, $other) - ); - } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/Not.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/Not.php diff -u pear/PHPUnit2/Framework/Constraint/Not.php:1.2 pear/PHPUnit2/Framework/Constraint/Not.php:1.3 --- pear/PHPUnit2/Framework/Constraint/Not.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/Not.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Not.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: Not.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -91,20 +91,40 @@ $this->constraint = $constraint; } - public function toString() - { - return 'not ' . $this->constraint->toString(); - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { return !$this->constraint->evaluate($other); } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { $this->constraint->fail($other, $description); } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + return 'not ' . $this->constraint->toString(); + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/Or.php?r1=1.3&r2=1.4&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/Or.php diff -u pear/PHPUnit2/Framework/Constraint/Or.php:1.3 pear/PHPUnit2/Framework/Constraint/Or.php:1.4 --- pear/PHPUnit2/Framework/Constraint/Or.php:1.3 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/Or.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Or.php,v 1.3 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: Or.php,v 1.4 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -93,21 +93,13 @@ } } - public function toString() - { - $text = ''; - - foreach($this->constraints as $key => $constraint) { - if ($key > 0) { - $text .= ' or '; - } - - $text .= $constraint->toString(); - } - - return $text; - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { foreach($this->constraints as $key => $constraint) { @@ -119,6 +111,13 @@ return FALSE; } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { throw new PHPUnit2_Framework_ExpectationFailedException( @@ -131,6 +130,27 @@ ) ); } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + $text = ''; + + foreach($this->constraints as $key => $constraint) { + if ($key > 0) { + $text .= ' or '; + } + + $text .= $constraint->toString(); + } + + return $text; + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/PCREMatch.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/PCREMatch.php diff -u pear/PHPUnit2/Framework/Constraint/PCREMatch.php:1.2 pear/PHPUnit2/Framework/Constraint/PCREMatch.php:1.3 --- pear/PHPUnit2/Framework/Constraint/PCREMatch.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/PCREMatch.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: PCREMatch.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: PCREMatch.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -86,20 +86,25 @@ $this->pattern = $pattern; } - public function toString() - { - return sprintf( - 'matches PCRE pattern <%s>', - - var_export($this->pattern, TRUE) - ); - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { return preg_match($this->pattern, $other); } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { throw new PHPUnit2_Framework_ExpectationFailedException( @@ -113,6 +118,21 @@ ) ); } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + return sprintf( + 'matches PCRE pattern <%s>', + + var_export($this->pattern, TRUE) + ); + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/StringContains.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/StringContains.php diff -u pear/PHPUnit2/Framework/Constraint/StringContains.php:1.2 pear/PHPUnit2/Framework/Constraint/StringContains.php:1.3 --- pear/PHPUnit2/Framework/Constraint/StringContains.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/StringContains.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: StringContains.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: StringContains.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -89,21 +89,13 @@ $this->case = $case; } - public function toString() - { - if ($this->case) { - $string = var_export($this->string, TRUE); - } else { - $string = var_export(strtolower($this->string), TRUE); - } - - return sprintf( - 'contains string <%s>', - - $string - ); - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { if ($this->case) { @@ -113,6 +105,13 @@ } } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { if ($this->case) { @@ -133,6 +132,27 @@ ) ); } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + if ($this->case) { + $string = var_export($this->string, TRUE); + } else { + $string = var_export(strtolower($this->string), TRUE); + } + + return sprintf( + 'contains string <%s>', + + $string + ); + } } /* http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/Framework/Constraint/TraversableContains.php?r1=1.2&r2=1.3&diff_format=u Index: pear/PHPUnit2/Framework/Constraint/TraversableContains.php diff -u pear/PHPUnit2/Framework/Constraint/TraversableContains.php:1.2 pear/PHPUnit2/Framework/Constraint/TraversableContains.php:1.3 --- pear/PHPUnit2/Framework/Constraint/TraversableContains.php:1.2 Wed Jan 4 07:04:51 2006 +++ pear/PHPUnit2/Framework/Constraint/TraversableContains.php Sat Jan 21 12:01:00 2006 @@ -42,7 +42,7 @@ * Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TraversableContains.php,v 1.2 2006/01/04 07:04:51 sebastian Exp $ + * @version CVS: $Id: TraversableContains.php,v 1.3 2006/01/21 12:01:00 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 3.0.0 */ @@ -80,16 +80,13 @@ $this->value = $value; } - public function toString() - { - return sprintf( - 'contains value <%s:%s>', - - gettype($this->value), - var_export($this->value, TRUE) - ); - } - + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @parameter mixed $other Value or object to evaluate. + * @return bool + */ public function evaluate($other) { $found = FALSE; @@ -104,6 +101,13 @@ return $found; } + /** + * @param mixed $other The value passed to evaluate() which failed the + * constraint check. + * @param string $description A string with extra description of what was + * going on while the evaluation failed. + * @throws PHPUnit2_Framework_ExpectationFailedException + */ public function fail($other, $description) { throw new PHPUnit2_Framework_ExpectationFailedException( @@ -117,6 +121,22 @@ ) ); } + + /** + * Returns a string representation of the constraint. + * + * @return string + * @access public + */ + public function toString() + { + return sprintf( + 'contains value <%s:%s>', + + gettype($this->value), + var_export($this->value, TRUE) + ); + } } /*
« previous php.pear.cvs (#37670) next »