예제 #1
1
 /**
  * @covers \Magento\SalesRule\Model\Rule\Action\Discount\CartFixed::calculate
  */
 public function testCalculate()
 {
     $this->rule->setData(['id' => 1, 'discount_amount' => 10.0]);
     $this->address->expects($this->any())->method('getCartFixedRules')->will($this->returnValue([]));
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $this->priceCurrency->expects($this->atLeastOnce())->method('convert')->will($this->returnArgument(0));
     $this->priceCurrency->expects($this->atLeastOnce())->method('round')->will($this->returnArgument(0));
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($store));
     /** validators data */
     $this->validator->expects($this->once())->method('getItemPrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemBasePrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemOriginalPrice')->with($this->item)->will($this->returnValue(100));
     $this->validator->expects($this->once())->method('getItemBaseOriginalPrice')->with($this->item)->will($this->returnValue(100));
     $this->address->expects($this->once())->method('setCartFixedRules')->with([1 => 0.0]);
     $this->model->calculate($this->rule, $this->item, 1);
     $this->assertEquals($this->data->getAmount(), 10);
     $this->assertEquals($this->data->getBaseAmount(), 10);
     $this->assertEquals($this->data->getOriginalAmount(), 10);
     $this->assertEquals($this->data->getBaseOriginalAmount(), 100);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function setData($key, $value = null)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setData');
     if (!$pluginInfo) {
         return parent::setData($key, $value);
     } else {
         return $this->___callPlugins('setData', func_get_args(), $pluginInfo);
     }
 }