/**
  * @inheritdoc
  */
 public function getConfig()
 {
     if (!$this->isExist()) {
         file_put_contents($this->path, '<?php return ' . var_export($this->providers->getConfig(), true) . ';' . "\n");
     }
     return require_once $this->path;
 }
Example #2
0
 /**
  * @covers \Magento\Catalog\Service\V1\Product\Link\Data\ProductLink\CollectionProvider::getCollection
  * @covers \Magento\Catalog\Service\V1\Product\Link\Data\ProductLink\CollectionProvider::__construct
  */
 public function testGetCollection()
 {
     $productA = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getId', '__wakeup'], [], '', false);
     $productA->expects($this->once())->method('getId')->will($this->returnValue('resultA'));
     $providerA = $this->getMock('\\Magento\\Catalog\\Service\\V1\\Product\\Link\\Data\\ProductLink\\CollectionProviderInterface');
     $providerA->expects($this->once())->method('getLinkedProducts')->with($this->productMock)->will($this->returnValue([$productA]));
     $resultA = ['resultA' => $productA];
     $productB = $this->getMock('\\Magento\\Catalog\\Model\\Product', ['getId', '__wakeup'], [], '', false);
     $productB->expects($this->once())->method('getId')->will($this->returnValue('resultB'));
     $providerB = $this->getMock('\\Magento\\Catalog\\Service\\V1\\Product\\Link\\Data\\ProductLink\\CollectionProviderInterface');
     $providerB->expects($this->once())->method('getLinkedProducts')->with($this->productMock)->will($this->returnValue([$productB]));
     $resultB = ['resultB' => $productB];
     $this->converterPoolMock->expects($this->any())->method('getConverter')->will($this->returnValue($this->converterMock));
     $this->converterMock->expects($this->any())->method('convert')->will($this->returnArgument(0));
     $provider = new CollectionProvider($this->converterPoolMock, ['typeA' => $providerA, 'typeB' => $providerB]);
     $this->assertEquals($resultA, $provider->getCollection($this->productMock, 'typeA'));
     $this->assertEquals($resultB, $provider->getCollection($this->productMock, 'typeB'));
 }