Exemple #1
0
 public function testConstructMethod()
 {
     $data = [];
     $customerId = 25;
     $this->customerSession->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId));
     $statuses = ['pending', 'processing', 'comlete'];
     $this->orderConfig->expects($this->once())->method('getVisibleOnFrontStatuses')->will($this->returnValue($statuses));
     $orderCollection = $this->getMock('Magento\\Sales\\Model\\Resource\\Order\\Collection', ['addFieldToSelect', 'addFieldToFilter', 'setOrder'], [], '', false, false);
     $orderCollection->expects($this->at(0))->method('addFieldToSelect')->with($this->equalTo('*'))->will($this->returnSelf());
     $orderCollection->expects($this->at(1))->method('addFieldToFilter')->with('customer_id', $this->equalTo($customerId))->will($this->returnSelf());
     $orderCollection->expects($this->at(2))->method('addFieldToFilter')->with('status', $this->equalTo(['in' => $statuses]))->will($this->returnSelf());
     $orderCollection->expects($this->at(3))->method('setOrder')->with('created_at', 'desc')->will($this->returnSelf());
     $this->orderCollectionFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($orderCollection));
     $this->model = new \Magento\Sales\Block\Order\History($this->context, $this->orderCollectionFactory, $this->customerSession, $this->orderConfig, $this->pageConfig, $data);
     $this->assertEquals($orderCollection, $this->model->getOrders());
 }
Exemple #2
0
 public function testConstructMethod()
 {
     $data = [];
     $attribute = ['customer_id', 'status'];
     $customerId = 25;
     $layout = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false, false);
     $this->context->expects($this->once())->method('getLayout')->will($this->returnValue($layout));
     $this->customerSession->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId));
     $statuses = ['pending', 'processing', 'complete'];
     $this->orderConfig->expects($this->once())->method('getVisibleOnFrontStatuses')->will($this->returnValue($statuses));
     $orderCollection = $this->getMock('Magento\\Sales\\Model\\Resource\\Order\\Collection', ['addAttributeToSelect', 'addFieldToFilter', 'addAttributeToFilter', 'addAttributeToSort', 'setPageSize', 'load'], [], '', false, false);
     $this->orderCollectionFactory->expects($this->once())->method('create')->will($this->returnValue($orderCollection));
     $orderCollection->expects($this->at(0))->method('addAttributeToSelect')->with($this->equalTo('*'))->will($this->returnSelf());
     $orderCollection->expects($this->at(1))->method('addAttributeToFilter')->with($attribute[0], $this->equalTo($customerId))->willReturnSelf();
     $orderCollection->expects($this->at(2))->method('addAttributeToFilter')->with($attribute[1], $this->equalTo(['in' => $statuses]))->will($this->returnSelf());
     $orderCollection->expects($this->at(3))->method('addAttributeToSort')->with('created_at', 'desc')->will($this->returnSelf());
     $orderCollection->expects($this->at(4))->method('setPageSize')->with('5')->will($this->returnSelf());
     $orderCollection->expects($this->at(5))->method('load')->will($this->returnSelf());
     $this->block = new \Magento\Sales\Block\Order\Recent($this->context, $this->orderCollectionFactory, $this->customerSession, $this->orderConfig, $data);
     $this->assertEquals($orderCollection, $this->block->getOrders());
 }
Exemple #3
0
 public function testInitOrders()
 {
     $customerId = 25;
     $attribute = ['customer_id', 'status'];
     $this->httpContext->expects($this->once())->method('getValue')->with($this->equalTo(Context::CONTEXT_AUTH))->will($this->returnValue(true));
     $this->customerSession->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId));
     $statuses = ['pending', 'processing', 'complete'];
     $this->orderConfig->expects($this->once())->method('getVisibleOnFrontStatuses')->will($this->returnValue($statuses));
     $this->orderCollection->expects($this->at(0))->method('addAttributeToFilter')->with($attribute[0], $this->equalTo($customerId))->will($this->returnSelf());
     $this->orderCollection->expects($this->at(1))->method('addAttributeToFilter')->with($attribute[1], $this->equalTo(['in' => $statuses]))->will($this->returnSelf());
     $this->orderCollection->expects($this->at(2))->method('addAttributeToSort')->with('created_at', 'desc')->will($this->returnSelf());
     $this->orderCollection->expects($this->at(3))->method('setPage')->with($this->equalTo(1), $this->equalTo(1))->will($this->returnSelf());
     $this->orderCollectionFactory->expects($this->atLeastOnce())->method('create')->will($this->returnValue($this->orderCollection));
     $this->createBlockObject();
     $this->assertEquals($this->orderCollection, $this->block->getOrders());
 }