public function testGetOrder() { $orderId = 100000041; $this->creditmemo->setOrderId($orderId); $entityName = 'creditmemo'; $order = $this->getMock('Magento\\Sales\\Model\\Order', ['load', 'setHistoryEntityName', '__wakeUp'], [], '', false); $this->creditmemo->setOrderId($orderId); $order->expects($this->atLeastOnce())->method('setHistoryEntityName')->with($entityName)->will($this->returnSelf()); $order->expects($this->atLeastOnce())->method('load')->with($orderId)->will($this->returnValue($order)); $this->orderFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($order)); $this->assertEquals($order, $this->creditmemo->getOrder()); }