Skip to content

Commit 9833953

Browse files
authored
Merge pull request #6021 from magento-tsg/2.4-develop-com-pr15
[TSG-Commerce] Tests for 2.4 (pr15)
2 parents a360c06 + 6d76a4a commit 9833953

26 files changed

+2330
-714
lines changed

dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php renamed to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/Type/File/ValidatorFileMock.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\Checkout\_files;
8+
namespace Magento\TestFramework\Catalog\Model\Product\Option\Type\File;
99

1010
use Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile;
11+
use PHPUnit\Framework\MockObject\MockObject;
12+
use PHPUnit\Framework\TestCase;
1113

1214
/**
1315
* Creates mock for ValidatorFile to replace real instance in fixtures.
1416
*/
15-
class ValidatorFileMock extends \PHPUnit\Framework\TestCase
17+
class ValidatorFileMock extends TestCase
1618
{
1719
/**
1820
* Returns mock.
21+
*
1922
* @param array|null $fileData
20-
* @return ValidatorFile|\PHPUnit_Framework_MockObject_MockObject
23+
* @return ValidatorFile|MockObject
2124
*/
2225
public function getInstance($fileData = null)
2326
{

dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_multiselect_attribute_with_source_model.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
99

1010
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/multiselect_attribute_with_source_model.php');
11-
Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/ValidatorFileMock.php');
1211

1312
/** Create product with options and multiselect attribute */
1413

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
10+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
11+
use Magento\Catalog\Model\Product\Type;
12+
use Magento\Catalog\Model\Product\Visibility;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
15+
$objectManager = Bootstrap::getObjectManager();
16+
/** @var ProductInterfaceFactory ProductInterfaceFactory */
17+
$productFactory = $objectManager->get(ProductInterfaceFactory::class);
18+
/** @var ProductRepositoryInterface $productRepositoryFactory */
19+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
20+
$productRepository->cleanCache();
21+
22+
$product = $productFactory->create();
23+
$product->setTypeId(Type::TYPE_SIMPLE)
24+
->setStatus(Status::STATUS_ENABLED)
25+
->setAttributeSetId($product->getDefaultAttributeSetId())
26+
->setWebsiteIds([1])
27+
->setName('Simple Product min and max sale qty')
28+
->setSku('simple_product_min_max_sale_qty')
29+
->setPrice(10)
30+
->setWeight(1)
31+
->setVisibility(Visibility::VISIBILITY_BOTH)
32+
->setStockData(
33+
[
34+
'use_config_manage_stock' => 1,
35+
'qty' => 100,
36+
'is_qty_decimal' => 0,
37+
'is_in_stock' => 1,
38+
'min_sale_qty' => 5,
39+
'max_sale_qty' => 20,
40+
]
41+
)
42+
->setCanSaveCustomOptions(true)
43+
->setHasOptions(true);
44+
$productRepository->save($product);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Framework\Exception\NoSuchEntityException;
10+
use Magento\Framework\Registry;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
$objectManager = Bootstrap::getObjectManager();
14+
/** @var Registry $registry */
15+
$registry = $objectManager->get(Registry::class);
16+
/** @var ProductRepositoryInterface $productRepository */
17+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
18+
19+
$registry->unregister('isSecureArea');
20+
$registry->register('isSecureArea', true);
21+
22+
try {
23+
$productRepository->deleteById('simple_product_min_max_sale_qty');
24+
} catch (NoSuchEntityException $e) {
25+
//product already deleted
26+
}
27+
28+
$registry->unregister('isSecureArea');
29+
$registry->register('isSecureArea', false);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
10+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
11+
use Magento\Catalog\Model\Product\Type;
12+
use Magento\Catalog\Model\Product\Visibility;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
15+
$objectManager = Bootstrap::getObjectManager();
16+
/** @var ProductInterfaceFactory ProductInterfaceFactory */
17+
$productFactory = $objectManager->get(ProductInterfaceFactory::class);
18+
/** @var ProductRepositoryInterface $productRepositoryFactory */
19+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
20+
$productRepository->cleanCache();
21+
22+
$product = $productFactory->create();
23+
$product->setTypeId(Type::TYPE_SIMPLE)
24+
->setStatus(Status::STATUS_ENABLED)
25+
->setAttributeSetId($product->getDefaultAttributeSetId())
26+
->setWebsiteIds([1])
27+
->setName('Simple Product with qty increments')
28+
->setSku('simple_product_with_qty_increments')
29+
->setPrice(10)
30+
->setWeight(1)
31+
->setVisibility(Visibility::VISIBILITY_BOTH)
32+
->setStockData(
33+
[
34+
'use_config_manage_stock' => 1,
35+
'qty' => 100,
36+
'is_qty_decimal' => 0,
37+
'is_in_stock' => 1,
38+
'enable_qty_increments' => 1,
39+
'qty_increments' => 3,
40+
]
41+
)
42+
->setCanSaveCustomOptions(true)
43+
->setHasOptions(true);
44+
$productRepository->save($product);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Framework\Exception\NoSuchEntityException;
10+
use Magento\Framework\Registry;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
$objectManager = Bootstrap::getObjectManager();
14+
/** @var Registry $registry */
15+
$registry = $objectManager->get(Registry::class);
16+
/** @var ProductRepositoryInterface $productRepository */
17+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
18+
19+
$registry->unregister('isSecureArea');
20+
$registry->register('isSecureArea', true);
21+
22+
try {
23+
$productRepository->deleteById('simple_product_with_qty_increments');
24+
} catch (NoSuchEntityException $e) {
25+
//product already deleted
26+
}
27+
28+
$registry->unregister('isSecureArea');
29+
$registry->register('isSecureArea', false);

0 commit comments

Comments
 (0)