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_ExceptionCode extends PHPUnit_Framework_Constraint
19 protected $expectedCode;
22 * @param int $expected
24 public function __construct($expected)
26 parent::__construct();
27 $this->expectedCode = $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 (string) $other->getCode() == (string) $this->expectedCode;
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 '%s is equal to expected exception code %s',
57 $this->exporter->export($other->getCode()),
58 $this->exporter->export($this->expectedCode)
65 public function toString()
67 return 'exception code is ';