Beispiel #1
0
 /**
  * @dataProvider getItemAttributesDataProvider
  */
 public function testGetItemAttributes($type, $typeId)
 {
     $attributes = [['code' => 'test_code_1', 'type' => 'test_type_1']];
     $expectedResult = [['attribute_code' => $attributes[0]['code'], 'value' => $attributes[0]['type']]];
     $objectMock = $this->getMock('\\Magento\\Framework\\Object', ['create'], [], '', false);
     $objectMock->expects($this->once())->method('create')->willReturn(['attribute_code' => $attributes[0]['code'], 'value' => $attributes[0]['type']]);
     $linkMock = $this->getMock('\\Magento\\Catalog\\Model\\Product\\Link', ['getAttributes'], [], '', false);
     $linkMock->expects($this->once())->method('getAttributes')->willReturn($attributes);
     $this->linkFactoryMock->expects($this->once())->method('create')->with($typeId)->willReturn($linkMock);
     $this->linkAttributeBuilderMock->expects($this->once())->method('populateWithArray')->willReturn($objectMock);
     $this->assertEquals($expectedResult, $this->model->getItemAttributes($type));
 }
 /**
  * @dataProvider getItemAttributesDataProvider
  */
 public function testGetItemAttributes($type, $typeId)
 {
     $attributes = [['code' => 'test_code_1', 'type' => 'test_type_1']];
     $linkAttributeMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductLinkAttributeInterface');
     $linkAttributeMock->expects($this->once())->method('setCode')->with($attributes[0]['code'])->willReturnSelf();
     $linkAttributeMock->expects($this->once())->method('setType')->with($attributes[0]['type'])->willReturnSelf();
     $expectedResult = [$linkAttributeMock];
     $linkMock = $this->getMock('\\Magento\\Catalog\\Model\\Product\\Link', ['getAttributes'], [], '', false);
     $linkMock->expects($this->once())->method('getAttributes')->willReturn($attributes);
     $this->linkFactoryMock->expects($this->once())->method('create')->with($typeId)->willReturn($linkMock);
     $this->linkAttributeFactoryMock->expects($this->once())->method('create')->willReturn($linkAttributeMock);
     $this->assertEquals($expectedResult, $this->model->getItemAttributes($type));
 }