@@ -110,19 +110,27 @@ public function testSaveTypeSpecificData()
110
110
$ sampleFactory = $ objectManager ->create ('Magento\Downloadable\Api\Data\SampleInterfaceFactory ' );
111
111
$ linkFactory = $ objectManager ->create ('Magento\Downloadable\Api\Data\LinkInterfaceFactory ' );
112
112
$ extension = $ product ->getExtensionAttributes ();
113
+ $ expectedLink = [
114
+ 'is_shareable ' => '2 ' ,
115
+ 'link_type ' => 'file ' ,
116
+ 'link_file ' => '/j/e/jellyfish_2_4.jpg ' ,
117
+ 'number_of_downloads ' => '15 ' ,
118
+ 'price ' => '15.0000 ' ,
119
+ 'sample_type ' => 'file ' ,
120
+ 'sort_order ' => '1 ' ,
121
+ 'title ' => 'Updated downloadable link #1 ' ,
122
+ ];
113
123
$ links = [];
114
124
foreach ($ downloadableData ['link ' ] as $ linkData ) {
115
125
if (!$ linkData || (isset ($ linkData ['is_delete ' ]) && (bool )$ linkData ['is_delete ' ])) {
116
126
continue ;
117
127
} else {
118
128
$ link = $ linkFactory ->create (['data ' => $ linkData ]);
119
- $ link ->setId (null );
120
- if (isset ($ linkData ['link_id ' ])) {
121
- $ link ->setId ($ linkData ['link_id ' ]);
122
- }
129
+ $ link ->setId ($ linkData ['link_id ' ]);
123
130
if (isset ($ linkData ['sample ' ])) {
124
131
$ link ->setSampleType ($ linkData ['sample ' ]['type ' ]);
125
132
$ link ->setSampleFileData ($ linkData ['sample ' ]['file ' ]);
133
+ $ expectedLink ['sample_file ' ] = $ linkData ['sample ' ]['file ' ];
126
134
$ link ->setSampleUrl ($ linkData ['sample ' ]['url ' ]);
127
135
}
128
136
$ link ->setLinkType ($ linkData ['type ' ]);
@@ -150,9 +158,8 @@ public function testSaveTypeSpecificData()
150
158
if (!$ sampleData || (isset ($ sampleData ['is_delete ' ]) && (bool )$ sampleData ['is_delete ' ])) {
151
159
continue ;
152
160
} else {
153
- unset($ sampleData ['sample_id ' ]);
154
161
$ sample = $ sampleFactory ->create (['data ' => $ sampleData ]);
155
- $ sample ->setId (null );
162
+ $ sample ->setId ($ sampleData [ ' sample_id ' ] );
156
163
$ sample ->setStoreId ($ product ->getStoreId ());
157
164
$ sample ->setSampleType ($ sampleData ['type ' ]);
158
165
$ sample ->setSampleUrl ($ sampleData ['sample_url ' ]);
@@ -172,26 +179,13 @@ public function testSaveTypeSpecificData()
172
179
$ product ->setTypeHasRequiredOptions (false )->setRequiredOptions (false );
173
180
}
174
181
175
-
176
-
177
182
$ product ->save ();
178
183
/** @var \Magento\Catalog\Model\Product $product */
179
184
$ product = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
180
185
'Magento\Catalog\Model\Product '
181
186
);
182
187
$ product ->load (1 );
183
188
184
- $ expectedLink = [
185
- 'is_shareable ' => '2 ' ,
186
- 'link_type ' => 'file ' ,
187
- 'link_file ' => '/j/e/jellyfish_2_4.jpg ' ,
188
- 'number_of_downloads ' => '15 ' ,
189
- 'price ' => '15.0000 ' ,
190
- 'sample_file ' => '/n/d/jellyfish_1_3.jpg ' ,
191
- 'sample_type ' => 'file ' ,
192
- 'sort_order ' => '1 ' ,
193
- 'title ' => 'Updated downloadable link #1 ' ,
194
- ];
195
189
$ links = $ product ->getExtensionAttributes ()->getDownloadableProductLinks ();
196
190
197
191
$ this ->assertNotEmpty ($ links );
0 commit comments