Skip to content

Commit e5479dd

Browse files
author
Cody Nguyen
committed
Add function test
1 parent 0fc3630 commit e5479dd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogInventory/ProductOnlyXLeftInStockTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,29 @@ public function testQueryProductOnlyXLeftInStockEnabled()
6363
$this->assertArrayHasKey('only_x_left_in_stock', $response['products']['items'][0]);
6464
$this->assertEquals(100, $response['products']['items'][0]['only_x_left_in_stock']);
6565
}
66+
67+
/**
68+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php
69+
* @magentoConfigFixture default_store cataloginventory/options/show_out_of_stock 1
70+
*/
71+
public function testQueryProductOnlyXLeftInStockOutstock()
72+
{
73+
$productSku = 'simple-out-of-stock';
74+
75+
$query = <<<QUERY
76+
{
77+
products(filter: {sku: {eq: "{$productSku}"}})
78+
{
79+
items {
80+
only_x_left_in_stock
81+
}
82+
}
83+
}
84+
QUERY;
85+
$response = $this->graphQlQuery($query);
86+
87+
$this->assertArrayHasKey(0, $response['products']['items']);
88+
$this->assertArrayHasKey('only_x_left_in_stock', $response['products']['items'][0]);
89+
$this->assertEquals(0, $response['products']['items'][0]['only_x_left_in_stock']);
90+
}
6691
}

0 commit comments

Comments
 (0)