Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ArrayBackendTest.php
Go to the documentation of this file.
1 <?php
7 
8 class ArrayBackendTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_model;
14 
18  protected $_attribute;
19 
20  protected function setUp()
21  {
22  $this->_attribute = $this->createPartialMock(
23  \Magento\Eav\Model\Entity\Attribute::class,
24  ['getAttributeCode', '__wakeup']
25  );
26  $logger = $this->createMock(\Psr\Log\LoggerInterface::class);
27  $this->_model = new \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend($logger);
28  $this->_model->setAttribute($this->_attribute);
29  }
30 
34  public function testValidate($data)
35  {
36  $this->_attribute->expects($this->atLeastOnce())->method('getAttributeCode')->will($this->returnValue('code'));
37  $product = new \Magento\Framework\DataObject(['code' => $data, 'empty' => '']);
38  $this->_model->validate($product);
39  $this->assertEquals('1,2,3', $product->getCode());
40  $this->assertEquals(null, $product->getEmpty());
41  }
42 
46  public static function attributeValueDataProvider()
47  {
48  return [[[1, 2, 3]], ['1,2,3']];
49  }
50 }
$logger