Ejemplo n.º 1
0
 protected function setUp()
 {
     $this->helper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->rulesApplier = $this->getMock('Magento\\SalesRule\\Model\\RulesApplier', ['setAppliedRuleIds', 'applyRules', 'addDiscountDescription', '__wakeup'], [], '', false);
     /** @var \Magento\Sales\Model\Quote\Item\AbstractItem|\PHPUnit_Framework_MockObject_MockObject $item */
     $this->item = $this->getMock('Magento\\Sales\\Model\\Quote\\Item', ['__wakeup'], [], '', false);
     $context = $this->getMock('Magento\\Framework\\Model\\Context', [], [], '', false);
     $registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->catalogData = $this->getMock('Magento\\Catalog\\Helper\\Data', [], [], '', false);
     $this->utility = $this->getMock('Magento\\SalesRule\\Model\\Utility', [], [], '', false);
     $this->validators = $this->getMock('Magento\\SalesRule\\Model\\Validator\\Pool', ['getValidators'], [], '', false);
     $this->messageManager = $this->getMock('\\Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->ruleCollection = $this->getMockBuilder('Magento\\SalesRule\\Model\\Resource\\Rule\\Collection')->disableOriginalConstructor()->getMock();
     $ruleCollectionFactoryMock = $this->prepareRuleCollectionMock($this->ruleCollection);
     /** @var \Magento\SalesRule\Model\Validator|\PHPUnit_Framework_MockObject_MockObject $validator */
     $this->model = $this->helper->getObject('Magento\\SalesRule\\Model\\Validator', ['context' => $context, 'registry' => $registry, 'collectionFactory' => $ruleCollectionFactoryMock, 'catalogData' => $this->catalogData, 'utility' => $this->utility, 'rulesApplier' => $this->rulesApplier, 'validators' => $this->validators, 'messageManager' => $this->messageManager]);
     $this->model->setWebsiteId(1);
     $this->model->setCustomerGroupId(2);
     $this->model->setCouponCode('code');
     $this->ruleCollection->expects($this->at(0))->method('setValidationFilter')->with($this->model->getWebsiteId(), $this->model->getCustomerGroupId(), $this->model->getCouponCode())->willReturnSelf();
 }