Ejemplo n.º 1
0
 public function testAddSalesRuleNameToOrder()
 {
     $observer = $this->getMock('Magento\\Framework\\Event\\Observer', ['getOrder'], [], '', false);
     $rule = $this->getMock('Magento\\SalesRule\\Model\\Rule', ['load', 'getName', '__wakeup'], [], '', false);
     $order = $this->getMock('Magento\\Sales\\Model\\Order', ['setCouponRuleName', 'getCouponCode', '__wakeup'], [], '', false);
     $couponCode = 'coupon code';
     $ruleId = 1;
     $observer->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $order->expects($this->once())->method('getCouponCode')->will($this->returnValue($couponCode));
     $this->couponMock->expects($this->once())->method('getRuleId')->will($this->returnValue($ruleId));
     $this->ruleFactory->expects($this->once())->method('create')->will($this->returnValue($rule));
     $rule->expects($this->once())->method('load')->with($ruleId)->will($this->returnSelf());
     $order->expects($this->once())->method('setCouponRuleName');
     $this->assertEquals($this->model, $this->model->addSalesRuleNameToOrder($observer));
 }