Esempio n. 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());
 }
Esempio n. 2
0
 /**
  * Init model class by configuration
  *
  * @param string $class
  * @param string $totalCode
  * @param array $totalConfig
  * @return \Magento\Sales\Model\Order\Total\AbstractTotal
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _initModelInstance($class, $totalCode, $totalConfig)
 {
     $model = $this->_orderTotalFactory->create($class);
     if (!$model instanceof \Magento\Sales\Model\Order\Total\AbstractTotal) {
         throw new \Magento\Framework\Model\Exception(__('The total model should be extended from \\Magento\\Sales\\Model\\Order\\Total\\AbstractTotal.'));
     }
     $model->setCode($totalCode);
     $model->setTotalConfigNode($totalConfig);
     $this->_modelsConfig[$totalCode] = $this->_prepareConfigArray($totalCode, $totalConfig);
     $this->_modelsConfig[$totalCode] = $model->processConfigArray($this->_modelsConfig[$totalCode]);
     return $model;
 }