File tree Expand file tree Collapse file tree 4 files changed +62
-7
lines changed
dev/tests/integration/testsuite/Magento Expand file tree Collapse file tree 4 files changed +62
-7
lines changed Original file line number Diff line number Diff line change 35
35
true
36
36
)->setStockData (
37
37
[
38
- 'qty ' => 0 ,
39
- 'is_in_stock ' => 0
38
+ 'qty ' => 100 ,
39
+ 'is_in_stock ' => 1
40
40
]
41
- );
41
+ )-> setHasOptions ( true ) ;
42
42
43
43
$ options = [
44
44
[
204
204
$ customOptions [] = $ customOption ;
205
205
}
206
206
207
- $ product ->setOptions ($ customOptions )->save ();
207
+ $ product ->setOptions ($ customOptions );
208
+
209
+ /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepositoryFactory */
210
+ $ productRepository = $ objectManager ->create (\Magento \Catalog \Api \ProductRepositoryInterface::class);
211
+ $ productRepository ->save ($ product );
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ namespace Magento \Checkout \_files ;
7
+
8
+ use Magento \Catalog \Model \Product \Option \Type \File \ValidatorFile ;
9
+
10
+ /**
11
+ * Creates mock for ValidatorFile to replace real instance in fixtures.
12
+ */
13
+ class ValidatorFileMock extends \PHPUnit_Framework_TestCase
14
+ {
15
+ /**
16
+ * Returns mock.
17
+ *
18
+ * @return ValidatorFile|\PHPUnit_Framework_MockObject_MockObject
19
+ */
20
+ public function getInstance ()
21
+ {
22
+ $ userValue = [
23
+ 'type ' => 'image/jpeg ' ,
24
+ 'title ' => "test.jpg " ,
25
+ 'quote_path ' => "custom_options/quote/s/t/4624d2.jpg " ,
26
+ 'order_path ' => "custom_options/order/s/t/89d25b4624d2.jpg " ,
27
+ "fullpath " => "pub/media/custom_options/quote/s/t/e47389d25b4624d2.jpg " ,
28
+ "size " => "71901 " ,
29
+ "width " => 5 ,
30
+ "height " => 5 ,
31
+ "secret_key " => "10839ec1631b77e5e473 " ,
32
+ ];
33
+ $ instance = $ this ->getMockBuilder (ValidatorFile::class)
34
+ ->disableOriginalConstructor ()
35
+ ->getMock ();
36
+ $ instance ->method ('SetProduct ' )->willReturnSelf ();
37
+ $ instance ->method ('validate ' )->willReturn ($ userValue );
38
+
39
+ return $ instance ;
40
+ }
41
+ }
Original file line number Diff line number Diff line change 4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
+ use Magento \Checkout \_files \ValidatorFileMock ;
8
+
7
9
require __DIR__ . '/../../Checkout/_files/quote_with_address.php ' ;
8
- require __DIR__ . '/../../Catalog/_files/product_simple.php ' ;
10
+ require __DIR__ . '/../../Catalog/_files/product_with_options.php ' ;
11
+ require __DIR__ . '/../../Checkout/_files/ValidatorFileMock.php ' ;
9
12
10
13
$ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
11
14
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
22
25
case \Magento \Catalog \Api \Data \ProductCustomOptionInterface::OPTION_GROUP_SELECT :
23
26
$ value = key ($ option ->getValues ());
24
27
break ;
28
+ case \Magento \Catalog \Api \Data \ProductCustomOptionInterface::OPTION_GROUP_FILE :
29
+ $ value = 'test.jpg ' ;
30
+ break ;
25
31
default :
26
32
$ value = 'test ' ;
27
33
break ;
30
36
}
31
37
32
38
$ requestInfo = new \Magento \Framework \DataObject (['qty ' => 1 , 'options ' => $ options ]);
39
+ $ validatorFile = (new ValidatorFileMock ())->getInstance ();
40
+ $ objectManager ->addSharedInstance ($ validatorFile , \Magento \Catalog \Model \Product \Option \Type \File \ValidatorFile::class);
41
+
33
42
34
- $ quote ->setReservedOrderId ('test_order_item_with_items_and_custom_options ' )
35
- ->addProduct ($ product , $ requestInfo );
43
+ $ quote ->setReservedOrderId ('test_order_item_with_items_and_custom_options ' );
44
+ $ quote ->addProduct ($ product , $ requestInfo );
36
45
$ quote ->collectTotals ();
37
46
$ objectManager ->get (\Magento \Quote \Model \QuoteRepository::class)->save ($ quote );
38
47
Original file line number Diff line number Diff line change 4
4
* See COPYING.txt for license details.
5
5
*/
6
6
$ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
7
+ $ objectManager ->removeSharedInstance (\Magento \Catalog \Model \Product \Option \Type \File \ValidatorFile::class);
7
8
8
9
/** @var \Magento\Quote\Model\Quote $quote */
9
10
$ quote = $ objectManager ->create (\Magento \Quote \Model \Quote::class);
You can’t perform that action at this time.
0 commit comments