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.6.6
14 class PHPUnit_Framework_Constraint_Exception extends PHPUnit_Framework_Constraint
22 * @param string $className
24 public function __construct($className)
26 parent::__construct();
27 $this->className = $className;
31 * Evaluates the constraint for parameter $other. Returns true if the
32 * constraint is met, false otherwise.
34 * @param mixed $other Value or object to evaluate.
38 protected function matches($other)
40 return $other instanceof $this->className;
44 * Returns the description of the failure
46 * The beginning of failure messages is "Failed asserting that" in most
47 * cases. This method should return the second part of that sentence.
49 * @param mixed $other Evaluated value or object.
53 protected function failureDescription($other)
55 if ($other !== null) {
57 if ($other instanceof Exception) {
58 $message = '. Message was: "' . $other->getMessage() . '" at'
59 . "\n" . $other->getTraceAsString();
63 'exception of type "%s" matches expected exception "%s"%s',
71 'exception of type "%s" is thrown',
77 * Returns a string representation of the constraint.
81 public function toString()
84 'exception of type "%s"',