21 private $taxRuleRegistry;
26 private $taxRuleModelFactoryMock;
31 private $taxRuleModelMock;
38 $this->taxRuleModelFactoryMock = $this->getMockBuilder(\
Magento\Tax\Model\Calculation\RuleFactory::class)
39 ->setMethods([
'create'])
40 ->disableOriginalConstructor()
43 \
Magento\Tax\Model\Calculation\TaxRuleRegistry::class,
44 [
'taxRuleModelFactory' => $this->taxRuleModelFactoryMock]
46 $this->taxRuleModelMock = $this->getMockBuilder(\
Magento\Tax\Model\Calculation\Rule::class)
47 ->disableOriginalConstructor()
53 $this->taxRuleModelMock->expects($this->any())
55 ->with(self::TAX_RULE_ID)
56 ->will($this->returnValue($this->taxRuleModelMock));
58 $this->taxRuleModelMock->expects($this->any())
60 ->will($this->onConsecutiveCalls(self::TAX_RULE_ID,
null));
62 $this->taxRuleModelFactoryMock->expects($this->any())
64 ->will($this->returnValue($this->taxRuleModelMock));
65 $this->taxRuleRegistry->registerTaxRule($this->taxRuleModelMock);
66 $expected = $this->taxRuleRegistry->retrieveTaxRule(self::TAX_RULE_ID);
67 $this->assertEquals($this->taxRuleModelMock, $expected);
70 $this->taxRuleRegistry->removeTaxRule(self::TAX_RULE_ID);
74 $this->taxRuleRegistry->retrieveTaxRule(self::TAX_RULE_ID);
75 $this->fail(
'NoSuchEntityException was not thrown as expected');
78 'fieldName' =>
'taxRuleId',