36 protected function setUp()
38 $this->couponParameters = [
44 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
45 $className = \Magento\SalesRule\Helper\Coupon::class;
48 [
'couponParameters' => $this->couponParameters]
52 $this->scopeConfig =
$context->getScopeConfig();
59 $this->assertArrayHasKey(
60 $helper::COUPON_FORMAT_ALPHABETICAL,
62 'The returned list should contain COUPON_FORMAT_ALPHABETICAL constant value as a key' 64 $this->assertArrayHasKey(
65 $helper::COUPON_FORMAT_ALPHANUMERIC,
67 'The returned list should contain COUPON_FORMAT_ALPHANUMERIC constant value as a key' 69 $this->assertArrayHasKey(
70 $helper::COUPON_FORMAT_NUMERIC,
72 'The returned list should contain COUPON_FORMAT_NUMERIC constant value as a key' 80 $this->scopeConfig->expects($this->once())
82 ->with($helper::XML_PATH_SALES_RULE_COUPON_LENGTH, \
Magento\Store\Model\ScopeInterface::SCOPE_STORE)
83 ->will($this->returnValue($defaultLength));
85 $this->assertEquals($defaultLength,
$helper->getDefaultLength());
91 $defaultFormat =
'format';
92 $this->scopeConfig->expects($this->once())
94 ->with($helper::XML_PATH_SALES_RULE_COUPON_FORMAT, \
Magento\Store\Model\ScopeInterface::SCOPE_STORE)
95 ->will($this->returnValue($defaultFormat));
97 $this->assertEquals($defaultFormat,
$helper->getDefaultFormat());
103 $defaultPrefix =
'prefix';
104 $this->scopeConfig->expects($this->once())
106 ->with($helper::XML_PATH_SALES_RULE_COUPON_PREFIX, \
Magento\Store\Model\ScopeInterface::SCOPE_STORE)
107 ->will($this->returnValue($defaultPrefix));
109 $this->assertEquals($defaultPrefix,
$helper->getDefaultPrefix());
115 $defaultSuffix =
'suffix';
116 $this->scopeConfig->expects($this->once())
118 ->with($helper::XML_PATH_SALES_RULE_COUPON_SUFFIX, \
Magento\Store\Model\ScopeInterface::SCOPE_STORE)
119 ->will($this->returnValue($defaultSuffix));
121 $this->assertEquals($defaultSuffix,
$helper->getDefaultSuffix());
127 $defaultDashInterval = 4;
128 $this->scopeConfig->expects($this->once())
130 ->with($helper::XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL, \
Magento\Store\Model\ScopeInterface::SCOPE_STORE)
131 ->will($this->returnValue($defaultDashInterval));
133 $this->assertEquals($defaultDashInterval,
$helper->getDefaultDashInterval());
139 $expected = [
'a',
'b',
'c'];
141 $this->assertEquals($expected, $this->helper->getCharset(
$format));
146 $this->assertEquals($this->separator, $this->helper->getCodeSeparator());
testGetDefaultDashInterval()