aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/opencart/system/engine/EventTest.php
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-08-18 21:14:58 -0500
committerJesús <heckyel@hyperbola.info>2019-08-18 21:14:58 -0500
commit2eed7b082f83630301e51f57ca8394de228a8605 (patch)
tree1d19962d22d30f99317d9276e4bae7744fc93fc2 /tests/phpunit/opencart/system/engine/EventTest.php
downloadlibrecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.lz
librecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.xz
librecart-2eed7b082f83630301e51f57ca8394de228a8605.zip
first commit
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