objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = new \Magento\Framework\Mview\ActionFactory($this->objectManagerMock); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage NotAction doesn't implement \Magento\Framework\Mview\ActionInterface */ public function testGetWithException() { $notActionInterfaceMock = $this->getMockBuilder('Action')->getMock(); $this->objectManagerMock->expects( $this->once() )->method( 'get' )->with( 'NotAction' )->will( $this->returnValue($notActionInterfaceMock) ); $this->model->get('NotAction'); } public function testGet() { $actionInterfaceMock = $this->getMockForAbstractClass( \Magento\Framework\Mview\ActionInterface::class, [], '', false ); $this->objectManagerMock->expects( $this->once() )->method( 'get' )->with( \Magento\Framework\Mview\ActionInterface::class )->will( $this->returnValue($actionInterfaceMock) ); $this->model->get(\Magento\Framework\Mview\ActionInterface::class); $this->assertInstanceOf(\Magento\Framework\Mview\ActionInterface::class, $actionInterfaceMock); } }