File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
app/code/Magento/Downloadable Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -164,10 +164,11 @@ public function getLinks($product)
164
164
*/
165
165
public function hasLinks ($ product )
166
166
{
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 );
169
170
}
170
- return count ( $ this -> getLinks ( $ product )) > 0 ;
171
+ return $ hasLinks ;
171
172
}
172
173
173
174
/**
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
17
17
* @var \Magento\Downloadable\Model\Product\Type
18
18
*/
19
19
private $ target ;
20
+
20
21
/**
21
22
* @var TypeHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
22
23
*/
@@ -83,6 +84,7 @@ protected function setUp()
83
84
'getDownloadableData ' ,
84
85
'setTypeHasOptions ' ,
85
86
'setLinksExist ' ,
87
+ 'getDownloadableLinks ' ,
86
88
'__wakeup ' ,
87
89
],
88
90
[],
@@ -144,4 +146,12 @@ public function testBeforeSave()
144
146
{
145
147
$ this ->target ->beforeSave ($ this ->product );
146
148
}
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
+ }
147
157
}
You can’t perform that action at this time.
0 commit comments