public function testAfterGetProductAttributes()
 {
     $subject = $this->getMock('Magento\\Quote\\Model\\Quote\\Config', [], [], '', false);
     $attributeCode = 'code of the attribute';
     $expected = [0 => $attributeCode];
     $this->ruleResource->expects($this->once())->method('getActiveAttributes')->will($this->returnValue([['attribute_code' => $attributeCode, 'enabled' => true]]));
     $this->assertEquals($expected, $this->plugin->afterGetProductAttributes($subject, []));
 }
 public function testExecuteWithString()
 {
     $customers = '1,2';
     $websites = '3,4,5';
     $entityData = ['row_id' => 1, 'rule_id' => 1, 'website_ids' => $websites, 'customer_group_ids' => $customers];
     $className = '\\Magento\\Framework\\EntityManager\\EntityMetadata';
     $metadata = $this->getMock($className, [], [], '', false);
     $metadata->expects($this->once())->method('getLinkField')->willReturn('rule_id');
     $this->metadataPool->expects($this->once())->method('getMetadata')->willReturn($metadata);
     $this->ruleResource->expects($this->any())->method('bindRuleToEntity')->withConsecutive([1, [3, 4, 5]], [1, [1, 2]]);
     $result = $this->model->execute(RuleInterface::class, $entityData);
     $this->assertEquals($entityData, $result);
 }
 /**
  * test Execute
  */
 public function testExecute()
 {
     $entityData = ['row_id' => 2, 'rule_id' => 1];
     $customers = [1, 2];
     $websites = [3, 4, 5];
     $className = '\\Magento\\Framework\\Model\\Entity\\EntityMetadata';
     $metadata = $this->getMock($className, [], [], '', false);
     $metadata->expects($this->once())->method('getLinkField')->willReturn('rule_id');
     $this->metadataPool->expects($this->once())->method('getMetadata')->willReturn($metadata);
     $this->ruleResource->expects($this->once())->method('getCustomerGroupIds')->willReturn($customers);
     $this->ruleResource->expects($this->once())->method('getWebsiteIds')->willReturn($websites);
     $result = $this->model->execute(RuleInterface::class, $entityData);
     $expected = ['row_id' => 2, 'rule_id' => 1, 'customer_group_ids' => [1, 2], 'website_ids' => [3, 4, 5]];
     $this->assertEquals($expected, $result);
 }