-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENGCOM-6042: Extend test coverage for CustomerDownloadableGraphQl #990
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ration/testsuite/Magento/Downloadable/_files/product_downloadable_with_download_limit.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Magento\Catalog\Api\Data\ProductInterface; | ||
use Magento\Catalog\Api\ProductRepositoryInterface; | ||
use Magento\Catalog\Model\Product\Attribute\Source\Status; | ||
use Magento\Catalog\Model\Product\Visibility; | ||
use Magento\Downloadable\Api\Data\LinkInterface; | ||
use Magento\Downloadable\Api\LinkRepositoryInterface; | ||
use Magento\Downloadable\Helper\Download; | ||
use Magento\Downloadable\Model\Link; | ||
use Magento\Downloadable\Model\Product\Type; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
/** @var ProductRepositoryInterface $productRepository */ | ||
$productRepository = Bootstrap::getObjectManager() | ||
->get(ProductRepositoryInterface::class); | ||
/** @var LinkRepositoryInterface $linkRepository */ | ||
$linkRepository = Bootstrap::getObjectManager() | ||
->create(LinkRepositoryInterface::class); | ||
/** @var ProductInterface $product */ | ||
$product = Bootstrap::getObjectManager() | ||
->create(ProductInterface::class); | ||
/** @var LinkInterface $downloadableProductLink */ | ||
$downloadableProductLink = Bootstrap::getObjectManager() | ||
->create(LinkInterface::class); | ||
|
||
$downloadableProductLink | ||
// ->setId(null) | ||
->setLinkType(Download::LINK_TYPE_URL) | ||
->setTitle('Downloadable Product Link') | ||
->setIsShareable(Link::LINK_SHAREABLE_CONFIG) | ||
->setLinkUrl('http://example.com/downloadable.txt') | ||
->setNumberOfDownloads(100) | ||
->setSortOrder(1) | ||
->setPrice(0); | ||
|
||
$downloadableProductLinks[] = $downloadableProductLink; | ||
|
||
$product | ||
->setId(1) | ||
->setTypeId(Type::TYPE_DOWNLOADABLE) | ||
->setExtensionAttributes( | ||
$product->getExtensionAttributes() | ||
->setDownloadableProductLinks($downloadableProductLinks) | ||
) | ||
->setSku('downloadable-product') | ||
->setAttributeSetId(4) | ||
->setWebsiteIds([1]) | ||
->setName('Downloadable Product Limited') | ||
->setPrice(10) | ||
->setVisibility(Visibility::VISIBILITY_BOTH) | ||
->setStatus(Status::STATUS_ENABLED) | ||
->setLinksPurchasedSeparately(true) | ||
->setStockData( | ||
[ | ||
'qty' => 100, | ||
'is_in_stock' => 1, | ||
'manage_stock' => 1, | ||
] | ||
); | ||
|
||
$productRepository->save($product); |
8 changes: 8 additions & 0 deletions
8
...stsuite/Magento/Downloadable/_files/product_downloadable_with_download_limit_rollback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
require __DIR__ . '/product_downloadable_rollback.php'; |