示例#1
0
 public function testGetTotalModelsSortingSubroutine()
 {
     $total = $this->getMockForAbstractClass('Magento\\Sales\\Model\\Order\\Total\\AbstractTotal');
     $this->salesConfig->expects($this->once())->method('getGroupTotals')->will($this->returnValue(['some_code' => ['instance' => 'Magento\\Sales\\Model\\Order\\Total\\AbstractTotal', 'sort_order' => 1903], 'other_code' => ['instance' => 'Magento\\Sales\\Model\\Order\\Total\\AbstractTotal', 'sort_order' => 1112], 'equal_order' => ['instance' => 'Magento\\Sales\\Model\\Order\\Total\\AbstractTotal', 'sort_order' => 1112], 'big_order' => ['instance' => 'Magento\\Sales\\Model\\Order\\Total\\AbstractTotal', 'sort_order' => 3000], 'no_order' => ['instance' => 'Magento\\Sales\\Model\\Order\\Total\\AbstractTotal']]));
     $this->orderTotalFactory->expects($this->any())->method('create')->with('Magento\\Sales\\Model\\Order\\Total\\AbstractTotal')->will($this->returnValue($total));
     $this->assertSame(['no_order' => $total, 'equal_order' => $total, 'other_code' => $total, 'some_code' => $total, 'big_order' => $total], $this->object->getTotalModels());
 }
示例#2
0
 /**
  * @param string $itemKey
  * @param string $type
  * @param int $calledTimes
  * @dataProvider applySalableProductTypesFilterDataProvider
  */
 public function testApplySalableProductTypesFilter($itemKey, $type, $calledTimes)
 {
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productMock->expects($this->any())->method('getTypeId')->will($this->returnValue($type));
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->setMethods(['__wakeup', 'getProductType'])->getMock();
     $orderMock->expects($this->any())->method('getProductType')->will($this->returnValue($type));
     $quoteMock = $this->getMockBuilder('Magento\\Sales\\Model\\Quote\\Item')->disableOriginalConstructor()->getMock();
     $quoteMock->expects($this->any())->method('getProductType')->will($this->returnValue($type));
     $items = ['product' => $productMock, 'order' => $orderMock, 'quote' => $quoteMock, 'other' => 'other'];
     $collectionMock = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Db\\Collection\\AbstractCollection')->disableOriginalConstructor()->getMock();
     $collectionMock->expects($this->any())->method('getItems')->will($this->returnValue([$items[$itemKey]]));
     $collectionMock->expects($this->exactly($calledTimes))->method('removeItemByKey');
     $this->salesConfigMock->expects($this->any())->method('getAvailableProductTypes')->will($this->returnValue(['validProductType']));
     $this->adminHelper->applySalableProductTypesFilter($collectionMock);
 }