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_ExceptionMessage extends PHPUnit_Framework_Constraint
19 protected $expectedMessage;
22 * @param string $expected
24 public function __construct($expected)
26 parent::__construct();
27 $this->expectedMessage = $expected;
31 * Evaluates the constraint for parameter $other. Returns true if the
32 * constraint is met, false otherwise.
34 * @param Exception $other
38 protected function matches($other)
40 return strpos($other->getMessage(), $this->expectedMessage) !== false;
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)
56 "exception message '%s' contains '%s'",
58 $this->expectedMessage
65 public function toString()
67 return 'exception message contains ';