|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright © Magento, Inc. All rights reserved. |
4 |
| - * See COPYING.txt for license details. |
| 3 | + * Copyright 2019 Adobe |
| 4 | + * All Rights Reserved. |
5 | 5 | */
|
6 | 6 | declare(strict_types=1);
|
7 | 7 |
|
@@ -50,6 +50,44 @@ public function testQueryRelatedProducts()
|
50 | 50 | self::assertRelatedProducts($relatedProducts);
|
51 | 51 | }
|
52 | 52 |
|
| 53 | + /** |
| 54 | + * @magentoApiDataFixture Magento/Catalog/_files/products_related_disabled.php |
| 55 | + * @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1 |
| 56 | + * @magentoConfigFixture current_store catalog/magento_catalogpermissions/enabled 1 |
| 57 | + * @magentoConfigFixture current_store catalog/magento_catalogpermissions/grant_catalog_category_view 1 |
| 58 | + * @magentoConfigFixture current_store catalog/magento_catalogpermissions/grant_catalog_product_price 1 |
| 59 | + * @magentoConfigFixture current_store catalog/magento_catalogpermissions/grant_checkout_items 1 |
| 60 | + */ |
| 61 | + public function testQueryDisableRelatedProductWithShowOutOfStock() |
| 62 | + { |
| 63 | + $productSku = 'simple_with_cross'; |
| 64 | + |
| 65 | + $query = <<<QUERY |
| 66 | +{ |
| 67 | + products(filter: {sku: {eq: "{$productSku}"}}) |
| 68 | + { |
| 69 | + items { |
| 70 | + related_products |
| 71 | + { |
| 72 | + sku |
| 73 | + name |
| 74 | + url_key |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | +QUERY; |
| 80 | + $response = $this->graphQlQuery($query); |
| 81 | + |
| 82 | + self::assertArrayHasKey('products', $response); |
| 83 | + self::assertArrayHasKey('items', $response['products']); |
| 84 | + self::assertCount(1, $response['products']['items']); |
| 85 | + self::assertArrayHasKey(0, $response['products']['items']); |
| 86 | + self::assertArrayHasKey('related_products', $response['products']['items'][0]); |
| 87 | + $relatedProducts = $response['products']['items'][0]['related_products']; |
| 88 | + self::assertCount(0, $relatedProducts); |
| 89 | + } |
| 90 | + |
53 | 91 | /**
|
54 | 92 | * @magentoApiDataFixture Magento/Catalog/_files/products_related_disabled.php
|
55 | 93 | */
|
|
0 commit comments