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