12 use PHPUnit_Framework_MockObject_MockObject as MockObject;
35 private $emulatedAdminhtmlProcessorArea;
39 $this->scopeMock = $this->getMockBuilder(ScopeInterface::class)
40 ->getMockForAbstractClass();
41 $this->stateMock = $this->getMockBuilder(State::class)
42 ->disableOriginalConstructor()
43 ->setMethods([
'emulateAreaCode'])
54 $currentScope =
'currentScope';
55 $callback =
function () {
57 $this->scopeMock->expects($this->once())
58 ->method(
'getCurrentScope')
59 ->willReturn($currentScope);
61 $this->scopeMock->expects($this->once())
62 ->method(
'setCurrentScope')
63 ->with($currentScope);
65 $this->stateMock->expects($this->once())
66 ->method(
'emulateAreaCode')
68 ->willReturn(
'result');
70 $this->assertEquals(
'result', $this->emulatedAdminhtmlProcessorArea->process($callback));
79 $currentScope =
'currentScope';
80 $this->scopeMock->expects($this->once())
81 ->method(
'getCurrentScope')
82 ->willReturn($currentScope);
84 $this->scopeMock->expects($this->once())
85 ->method(
'setCurrentScope')
86 ->with($currentScope);
88 $this->stateMock->expects($this->once())
89 ->method(
'emulateAreaCode')
90 ->willThrowException(
new \Exception(
'Some Message'));
92 $this->emulatedAdminhtmlProcessorArea->process(
function () {
testProcessWithException()