37 $this->_observerFactoryMock = $this->createMock(\
Magento\Framework\
Event\ObserverFactory::class);
38 $this->_observerMock = $this->createMock(\
Magento\Framework\
Event\Observer::class);
39 $this->_listenerMock = $this->createPartialMock(
40 \
Magento\Framework\
Event\Test\Unit\Invoker\ObserverExample::class,
43 $this->_appStateMock = $this->createMock(\
Magento\Framework\
App\State::class);
45 $this->_invokerDefault = new \Magento\Framework\Event\Invoker\InvokerDefault(
46 $this->_observerFactoryMock,
53 $this->_observerFactoryMock->expects($this->never())->method(
'get');
54 $this->_observerFactoryMock->expects($this->never())->method(
'create');
56 $this->_invokerDefault->dispatch([
'disabled' =>
true], $this->_observerMock);
61 $this->_listenerMock->expects($this->once())->method(
'execute');
62 $this->_observerFactoryMock->expects($this->never())->method(
'get');
63 $this->_observerFactoryMock->expects(
70 $this->returnValue($this->_listenerMock)
73 $this->_invokerDefault->dispatch(
74 [
'shared' =>
false,
'instance' =>
'class_name',
'name' =>
'observer'],
81 $this->_listenerMock->expects($this->once())->method(
'execute');
82 $this->_observerFactoryMock->expects($this->never())->method(
'create');
83 $this->_observerFactoryMock->expects(
90 $this->returnValue($this->_listenerMock)
93 $this->_invokerDefault->dispatch(
94 [
'shared' =>
true,
'instance' =>
'class_name',
'method' =>
'method_name',
'name' =>
'observer'],
106 $notObserver = $this->getMockBuilder(
'NotObserver')->getMock();
107 $this->_observerFactoryMock->expects(
114 $this->returnValue($notObserver)
116 $this->_observerFactoryMock->expects(
123 $this->returnValue($notObserver)
125 $this->_appStateMock->expects(
130 $this->returnValue(\
Magento\Framework\
App\State::MODE_DEVELOPER)
133 $this->_invokerDefault->dispatch(
136 'instance' =>
'class_name',
137 'name' =>
'observer',
149 $notObserver = $this->getMockBuilder(
'NotObserver')->getMock();
150 $this->_observerFactoryMock->expects(
157 $this->returnValue($notObserver)
159 $this->_observerFactoryMock->expects(
166 $this->returnValue($notObserver)
168 $this->_appStateMock->expects(
173 $this->returnValue(\
Magento\Framework\
App\State::MODE_PRODUCTION)
176 $this->_invokerDefault->dispatch(
179 'instance' =>
'class_name',
180 'method' =>
'unknown_method_name',
181 'name' =>
'observer',
192 return [
'shared' => [
true],
'non shared' => [
false]];
testWrongInterfaceCallWithEnabledDeveloperMode($shared)
dataProviderForMethodIsNotDefined()
testDispatchWithSharedInstance()
testDispatchWithDisabledObserver()
testDispatchWithNonSharedInstance()
testWrongInterfaceCallWithDisabledDeveloperMode($shared)