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.
15
* @subpackage Framework_Constraint
16
* @author Sebastian Bergmann <sebastian@phpunit.de>
17
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
18
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
19
* @link http://www.phpunit.de/
20
* @since Class available since Release 3.6.6
22
class PHPUnit_Framework_Constraint_ExceptionMessage extends PHPUnit_Framework_Constraint
27
protected $expectedMessage;
30
* @param string $expected
32
public function __construct($expected)
34
parent::__construct();
35
$this->expectedMessage = $expected;
39
* Evaluates the constraint for parameter $other. Returns true if the
40
* constraint is met, false otherwise.
42
* @param Exception $other
45
protected function matches($other)
47
return strpos($other->getMessage(), $this->expectedMessage) !== false;
51
* Returns the description of the failure
53
* The beginning of failure messages is "Failed asserting that" in most
54
* cases. This method should return the second part of that sentence.
56
* @param mixed $other Evaluated value or object.
59
protected function failureDescription($other)
62
"exception message '%s' contains '%s'",
64
$this->expectedMessage
71
public function toString()
73
return 'exception message contains ';