Skip to content

Commit 24fb1f2

Browse files
authored
LYNX-175: Add a query to know if cancellation is enabled / disabled (#140)
1 parent e797820 commit 24fb1f2

File tree

8 files changed

+124
-0
lines changed

8 files changed

+124
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Magento_OrderCancellationGraphQl module
2+
3+
The **OrderCancellationGraphQl** module provides a GraphQl endpoint
4+
to cancel an order and specify the order cancellation reason.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "magento/module-order-cancellation-graph-ql",
3+
"description": "N/A",
4+
"config": {
5+
"sort-packages": true
6+
},
7+
"require": {
8+
"php": "~8.1.0||~8.2.0",
9+
"magento/framework": "*"
10+
},
11+
"type": "magento2-module",
12+
"license": [
13+
"OSL-3.0",
14+
"AFL-3.0"
15+
],
16+
"autoload": {
17+
"files": [
18+
"registration.php"
19+
],
20+
"psr-4": {
21+
"Magento\\OrderCancellationGraphQl\\": ""
22+
}
23+
}
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
10+
<arguments>
11+
<argument name="extendedConfigData" xsi:type="array">
12+
<item name="order_cancellation_enabled" xsi:type="string">sales/cancellation/enabled</item>
13+
</argument>
14+
</arguments>
15+
</type>
16+
</config>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_OrderCancellationGraphQl"/>
10+
</config>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright © Magento, Inc. All rights reserved.
2+
# See COPYING.txt for license details.
3+
type StoreConfig {
4+
order_cancellation_enabled: Boolean @doc(description: "Indicates whether orders can be cancelled by customers or not.")
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
use Magento\Framework\Component\ComponentRegistrar;
10+
11+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_OrderCancellationGraphQl', __DIR__);

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@
252252
"magento/module-offline-payments": "*",
253253
"magento/module-offline-shipping": "*",
254254
"magento/module-order-cancellation": "*",
255+
"magento/module-order-cancellation-graph-ql": "*",
255256
"magento/module-page-cache": "*",
256257
"magento/module-payment": "*",
257258
"magento/module-payment-graph-ql": "*",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
namespace Magento\GraphQl\OrderCancellation;
9+
10+
use Magento\Store\Test\Fixture\Store;
11+
use Magento\TestFramework\Fixture\DataFixture;
12+
use Magento\TestFramework\Fixture\Config;
13+
use Magento\TestFramework\TestCase\GraphQlAbstract;
14+
15+
/**
16+
* Test coverage for order cancellation settings in the store config
17+
*/
18+
#[
19+
DataFixture(Store::class)
20+
]
21+
class OrderCancellationEnabledTest extends GraphQlAbstract
22+
{
23+
private const STORE_CONFIG_QUERY = <<<QUERY
24+
{
25+
storeConfig {
26+
code
27+
order_cancellation_enabled
28+
}
29+
}
30+
QUERY;
31+
32+
#[
33+
Config('sales/cancellation/enabled', 1)
34+
]
35+
public function testOrderCancellationEnabledConfig()
36+
{
37+
$response = $this->graphQlQuery(self::STORE_CONFIG_QUERY);
38+
39+
self::assertArrayHasKey('order_cancellation_enabled', $response['storeConfig']);
40+
self::assertEquals(true, $response['storeConfig']['order_cancellation_enabled']);
41+
}
42+
43+
#[
44+
Config('sales/cancellation/enabled', 0)
45+
]
46+
public function testOrderCancellationDisabledConfig()
47+
{
48+
$response = $this->graphQlQuery(self::STORE_CONFIG_QUERY);
49+
50+
self::assertArrayHasKey('order_cancellation_enabled', $response['storeConfig']);
51+
self::assertEquals(false, $response['storeConfig']['order_cancellation_enabled']);
52+
}
53+
}

0 commit comments

Comments
 (0)