1: <?php
2: namespace Cake\TestSuite\Constraint;
3:
4: if (class_exists('PHPUnit_Runner_Version', false)
5: && !class_exists('PHPUnit\Framework\Constraint\Constraint', false)
6: ) {
7: class_alias('PHPUnit_Framework_Constraint', 'PHPUnit\Framework\Constraint\Constraint');
8: }
9: if (class_exists('PHPUnit_Runner_Version', false)
10: && !class_exists('PHPUnit\Framework\AssertionFailedError', false)
11: ) {
12: class_alias('PHPUnit_Framework_AssertionFailedError', 'PHPUnit\Framework\AssertionFailedError');
13: }
14:
15: use PHPUnit\Framework\AssertionFailedError;
16: use PHPUnit\Framework\Constraint\Constraint;
17:
18: 19: 20:
21: class EventFired extends Constraint
22: {
23: 24: 25: 26: 27:
28: protected $_eventManager;
29:
30: 31: 32: 33: 34:
35: public function __construct($eventManager)
36: {
37: parent::__construct();
38: $this->_eventManager = $eventManager;
39:
40: if ($this->_eventManager->getEventList() === null) {
41: throw new AssertionFailedError('The event manager you are asserting against is not configured to track events.');
42: }
43: }
44:
45: 46: 47: 48: 49: 50:
51: public function matches($other)
52: {
53: return $this->_eventManager->getEventList()->hasEvent($other);
54: }
55:
56: 57: 58: 59: 60:
61: public function toString()
62: {
63: return 'was fired';
64: }
65: }
66: