Skip to content
Permalink
Browse files

Throwing assertion error if no event list is configured

  • Loading branch information...
jeremyharris committed Jun 15, 2016
1 parent 8de073a commit 92d871e2ff9ee16ec0da93fa3fffbd49c533ffaf
@@ -2,6 +2,7 @@
namespace Cake\TestSuite\Constraint;
use Cake\Event\EventManager;
use PHPUnit_Framework_AssertionFailedError;
use PHPUnit_Framework_Constraint;
/**
@@ -25,6 +26,10 @@ public function __construct($eventManager)
{
parent::__construct();
$this->_eventManager = $eventManager;
if ($this->_eventManager->getEventList() === null) {
throw new PHPUnit_Framework_AssertionFailedError('The event manager you are asserting against is not configured to track events.');
}
}
/**
@@ -47,6 +47,10 @@ public function __construct($eventManager, $dataKey, $dataValue)
$this->_eventManager = $eventManager;
$this->_dataKey = $dataKey;
$this->_dataValue = $dataValue;
if ($this->_eventManager->getEventList() === null) {
throw new PHPUnit_Framework_AssertionFailedError('The event manager you are asserting against is not configured to track events.');
}
}
/**
@@ -48,6 +48,28 @@ public static function defaultConnectionName()
class TestCaseTest extends TestCase
{
/**
* tests trying to assertEventFired without configuring an event list
*
* @expectedException \PHPUnit_Framework_AssertionFailedError
*/
public function testEventFiredMisconfiguredEventList()
{
$manager = EventManager::instance();
$this->assertEventFired('my.event', $manager);
}
/**
* tests trying to assertEventFired without configuring an event list
*
* @expectedException \PHPUnit_Framework_AssertionFailedError
*/
public function testEventFiredWithMisconfiguredEventList()
{
$manager = EventManager::instance();
$this->assertEventFiredWith('my.event', 'some', 'data', $manager);
}
/**
* tests assertEventFiredWith
*

0 comments on commit 92d871e

Please sign in to comment.
You can’t perform that action at this time.