aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/opencart/system/engine/EventTest.php
blob: 3fb8fb716554f15cd94914b28f5c2ae5f61201b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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');
	}
}