aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/opencart/system/engine/EventTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/opencart/system/engine/EventTest.php')
-rw-r--r--tests/phpunit/opencart/system/engine/EventTest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/phpunit/opencart/system/engine/EventTest.php b/tests/phpunit/opencart/system/engine/EventTest.php
new file mode 100644
index 0000000..3fb8fb7
--- /dev/null
+++ b/tests/phpunit/opencart/system/engine/EventTest.php
@@ -0,0 +1,38 @@
+<?php
+
+class EventTest extends OpenCartTest {
+ public function testEventOrderedExecution() {
+ $eventMock = $this->getMockBuilder('Event')
+ ->setMethods(array('createAction'))
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $actionMock = $this->getMockBuilder('Action')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $actionMock->expects($this->exactly(3))
+ ->method('execute');
+
+ $eventMock->expects($this->at(0))
+ ->method('createAction')
+ ->with($this->equalTo('SomeExtraAction'), $this->equalTo(array()))
+ ->will($this->returnValue($actionMock));
+
+ $eventMock->expects($this->at(1))
+ ->method('createAction')
+ ->with($this->equalTo('SomeAction'), $this->equalTo(array()))
+ ->will($this->returnValue($actionMock));
+
+ $eventMock->expects($this->at(2))
+ ->method('createAction')
+ ->with($this->equalTo('SomeAnotherAction'), $this->equalTo(array()))
+ ->will($this->returnValue($actionMock));
+
+ $eventMock->register('some.event', 'SomeAction', 10);
+ $eventMock->register('some.event', 'SomeAnotherAction', 1);
+ $eventMock->register('some.event', 'SomeExtraAction', 100);
+
+ $eventMock->trigger('some.event');
+ }
+} \ No newline at end of file