createMock(\Magento\Framework\ObjectManagerInterface::class); $wrapperFactory = new WrapperFactory($objectManagerMock); $arguments = ['argument' => 'value', 'data' => 'data']; $observerInstanceMock = $this->createMock($expectedInstance); $objectManagerMock->expects($this->once()) ->method('create') ->with($expectedInstance, $arguments) ->will($this->returnValue($observerInstanceMock)); $this->assertInstanceOf($expectedInstance, $wrapperFactory->create($arguments)); } }