9 use Magento\Catalog\Model\ProductLink\LinkFactory;
24 private $relationProcessor;
29 private $objectManager;
48 $this->linkFactory = $this->getMockBuilder(LinkFactory::class)
49 ->setMethods([
'create'])
50 ->disableOriginalConstructor()
53 $this->relationProcessor = $this->getMockBuilder(Relation::class)
54 ->disableOriginalConstructor()
57 $this->link = $this->getMockBuilder(Link::class)
58 ->setMethods([
'getLinkTypeId',
'getProductId',
'getLinkedProductId'])
59 ->disableOriginalConstructor()
62 $this->linkFactory->expects($this->any())->method(
'create')->willReturn($this->link);
64 $this->subject = $this->getMockBuilder(LinkResourceModel::class)
65 ->disableOriginalConstructor()
68 $this->
object = $this->objectManager->getObject(
69 RelationPersister::class,
71 'relationProcessor' => $this->relationProcessor,
72 'linkFactory' => $this->linkFactory
79 $this->relationProcessor->expects($this->once())->method(
'addRelation')->with(2, 10);
80 $this->assertEquals($this->subject, $this->object->afterSaveProductLinks(
84 [[
'product_id' => 10]],
92 ->disableOriginalConstructor()
94 $subject->expects($this->any())->method(
'getIdFieldName')->willReturn(
'id');
95 $subject->expects($this->once())->method(
'load')->with($this->link, 155,
'id');
97 $this->link->expects($this->any())
98 ->method(
'getLinkTypeId')
100 $this->link->expects($this->any())
101 ->method(
'getProductId')
103 $this->link->expects($this->any())
104 ->method(
'getLinkedProductId')
107 $this->relationProcessor->expects($this->once())->method(
'removeRelations')->with(12, 13);
110 $this->object->aroundDeleteProductLink(
testAroundDeleteProductLink()
testAfterSaveProductLinks()