예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function modifyData(array $data)
 {
     $model = $this->locator->getProduct();
     $data[$model->getId()][self::DATA_SOURCE_DEFAULT]['links_title'] = $this->linksData->getLinksTitle();
     $data[$model->getId()][self::DATA_SOURCE_DEFAULT]['links_purchased_separately'] = $this->linksData->isProductLinksCanBePurchasedSeparately() ? '1' : '0';
     $data[$model->getId()]['downloadable']['link'] = $this->linksData->getLinksData();
     return $data;
 }
예제 #2
0
 /**
  * @param int|null $id
  * @param string $typeId
  * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectedGetTitle
  * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectedGetValue
  * @return void
  * @dataProvider getLinksTitleDataProvider
  */
 public function testGetLinksTitle($id, $typeId, $expectedGetTitle, $expectedGetValue)
 {
     $title = 'My Title';
     $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
     $this->productMock->expects($this->once())->method('getId')->willReturn($id);
     $this->productMock->expects($this->any())->method('getTypeId')->willReturn($typeId);
     $this->productMock->expects($expectedGetTitle)->method('getLinksTitle')->willReturn($title);
     $this->scopeConfigMock->expects($expectedGetValue)->method('getValue')->willReturn($title);
     $this->assertEquals($title, $this->links->getLinksTitle());
 }
 /**
  * @param bool $isPurchasedSeparatelyBool
  * @param string $isPurchasedSeparatelyStr
  * @return void
  * @dataProvider modifyDataDataProvider
  */
 public function testModifyData($isPurchasedSeparatelyBool, $isPurchasedSeparatelyStr)
 {
     $productId = 1;
     $linksTitle = 'Link Title';
     $linksData = 'Some data';
     $resultData = [$productId => [Links::DATA_SOURCE_DEFAULT => ['links_title' => $linksTitle, 'links_purchased_separately' => $isPurchasedSeparatelyStr], 'downloadable' => ['link' => $linksData]]];
     $this->locatorMock->expects($this->once())->method('getProduct')->willReturn($this->productMock);
     $this->productMock->expects($this->any())->method('getId')->willReturn($productId);
     $this->linksDataMock->expects($this->once())->method('getLinksTitle')->willReturn($linksTitle);
     $this->linksDataMock->expects($this->once())->method('isProductLinksCanBePurchasedSeparately')->willReturn($isPurchasedSeparatelyBool);
     $this->linksDataMock->expects($this->once())->method('getLinksData')->willReturn($linksData);
     $this->assertEquals($resultData, $this->links->modifyData([]));
 }