public function testGetInvisibleOnFrontStatuses() { $statuses = [new \Magento\Framework\Object(['status' => 'canceled', 'is_default' => 1, 'visible_on_front' => 1]), new \Magento\Framework\Object(['status' => 'complete', 'is_default' => 1, 'visible_on_front' => 0]), new \Magento\Framework\Object(['status' => 'processing', 'is_default' => 1, 'visible_on_front' => 1]), new \Magento\Framework\Object(['status' => 'pending_payment', 'is_default' => 1, 'visible_on_front' => 0])]; $expectedResult = ['complete', 'pending_payment']; $collectionMock = $this->getMock('Magento\\Sales\\Model\\Resource\\Order\\Status\\Collection', ['create', 'joinStates'], [], '', false, false); $this->orderStatusCollectionFactoryMock->expects($this->once())->method('create')->will($this->returnValue($collectionMock)); $collectionMock->expects($this->once())->method('joinStates')->will($this->returnValue($statuses)); $result = $this->salesConfig->getInvisibleOnFrontStatuses(); $this->assertSame($expectedResult, $result); }
/** * Get last order ID from session, fetch it and check whether it can be viewed, printed etc * * @return void */ protected function _prepareLastOrder() { $orderId = $this->_checkoutSession->getLastOrderId(); if ($orderId) { $order = $this->_orderFactory->create()->load($orderId); if ($order->getId()) { $isVisible = !in_array($order->getStatus(), $this->_orderConfig->getInvisibleOnFrontStatuses()); $canView = $this->httpContext->getValue(Context::CONTEXT_AUTH) && $isVisible; $this->addData(['is_order_visible' => $isVisible, 'view_order_url' => $this->getUrl('sales/order/view/', ['order_id' => $orderId]), 'print_url' => $this->getUrl('sales/order/print', ['order_id' => $orderId]), 'can_print_order' => $isVisible, 'can_view_order' => $canView, 'order_id' => $order->getIncrementId()]); } } }
/** * Is order visible * * @param Order $order * @return bool */ protected function isVisible(Order $order) { return !in_array($order->getStatus(), $this->_orderConfig->getInvisibleOnFrontStatuses()); }