3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * @since Class available since Release 3.1.0
14 abstract class PHPUnit_Framework_Constraint_Composite extends PHPUnit_Framework_Constraint
17 * @var PHPUnit_Framework_Constraint
19 protected $innerConstraint;
22 * @param PHPUnit_Framework_Constraint $innerConstraint
24 public function __construct(PHPUnit_Framework_Constraint $innerConstraint)
26 parent::__construct();
27 $this->innerConstraint = $innerConstraint;
31 * Evaluates the constraint for parameter $other
33 * If $returnResult is set to false (the default), an exception is thrown
34 * in case of a failure. null is returned otherwise.
36 * If $returnResult is true, the result of the evaluation is returned as
37 * a boolean value instead: true in case of success, false in case of a
40 * @param mixed $other Value or object to evaluate.
41 * @param string $description Additional information about the test
42 * @param bool $returnResult Whether to return a result or throw an exception
46 * @throws PHPUnit_Framework_ExpectationFailedException
48 public function evaluate($other, $description = '', $returnResult = false)
51 return $this->innerConstraint->evaluate(
56 } catch (PHPUnit_Framework_ExpectationFailedException $e) {
57 $this->fail($other, $description);
62 * Counts the number of constraint elements.
66 public function count()
68 return count($this->innerConstraint);