Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
QuoteConfigProductAttributesTest.php
Go to the documentation of this file.
1 <?php
8 
9 class QuoteConfigProductAttributesTest extends \PHPUnit\Framework\TestCase
10 {
14  protected $plugin;
15 
19  protected $ruleResource;
20 
21  protected function setUp()
22  {
23  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
24  $this->ruleResource = $this->createMock(\Magento\SalesRule\Model\ResourceModel\Rule::class);
25 
26  $this->plugin = $objectManager->getObject(
27  \Magento\SalesRule\Model\Plugin\QuoteConfigProductAttributes::class,
28  [
29  'ruleResource' => $this->ruleResource
30  ]
31  );
32  }
33 
35  {
36  $subject = $this->createMock(\Magento\Quote\Model\Quote\Config::class);
37  $attributeCode = 'code of the attribute';
38  $expected = [0 => $attributeCode];
39 
40  $this->ruleResource->expects($this->once())
41  ->method('getActiveAttributes')
42  ->will(
43  $this->returnValue(
44  [
45  ['attribute_code' => $attributeCode, 'enabled' => true],
46  ]
47  )
48  );
49 
50  $this->assertEquals($expected, $this->plugin->afterGetProductAttributes($subject, []));
51  }
52 }
$objectManager
Definition: bootstrap.php:17
$attributeCode
Definition: extend.phtml:12