Skip to content

Commit a93883c

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-52030' into PR-4
2 parents 018345d + 7eae298 commit a93883c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

app/code/Magento/Downloadable/Model/Product/Type.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,11 @@ public function getLinks($product)
164164
*/
165165
public function hasLinks($product)
166166
{
167-
if ($product->hasData('links_exist')) {
168-
return $product->getData('links_exist');
167+
$hasLinks = $product->getData('links_exist');
168+
if (null === $hasLinks) {
169+
$hasLinks = (count($this->getLinks($product)) > 0);
169170
}
170-
return count($this->getLinks($product)) > 0;
171+
return $hasLinks;
171172
}
172173

173174
/**

app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
1717
* @var \Magento\Downloadable\Model\Product\Type
1818
*/
1919
private $target;
20+
2021
/**
2122
* @var TypeHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
2223
*/
@@ -83,6 +84,7 @@ protected function setUp()
8384
'getDownloadableData',
8485
'setTypeHasOptions',
8586
'setLinksExist',
87+
'getDownloadableLinks',
8688
'__wakeup',
8789
],
8890
[],
@@ -144,4 +146,12 @@ public function testBeforeSave()
144146
{
145147
$this->target->beforeSave($this->product);
146148
}
149+
150+
public function testHasLinks()
151+
{
152+
$this->product->expects($this->exactly(2))
153+
->method('getDownloadableLinks')
154+
->willReturn(['link1', 'link2']);
155+
$this->assertTrue($this->target->hasLinks($this->product));
156+
}
147157
}

0 commit comments

Comments
 (0)