public function testOrder() { $cartId = 123; $quoteService = $this->getMock('Magento\\Sales\\Model\\Service\\Quote', [], [], '', false); $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteServiceFactory->expects($this->once())->method('create')->with(['quote' => $this->quoteMock])->will($this->returnValue($quoteService)); $orderMock = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false); $orderMock->expects($this->any())->method('getId')->will($this->returnValue(5)); $quoteService->expects($this->once())->method('submitOrderWithDataObject')->will($this->returnValue($orderMock)); $this->assertEquals(5, $this->service->order($cartId)); }