Skip to content

Commit a6b22e4

Browse files
authored
Merge pull request #254 from anikghosh256/master
Test case added for GraphQL Query
2 parents 32ec82a + fa79086 commit a6b22e4

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ $config = array(
4040
'ShopUrl' => 'yourshop.myshopify.com',
4141
'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
4242
'Password' => '***YOUR-PRIVATE-API-PASSWORD***',
43+
'AccessToken' => '***YOUR-PRIVATE-API-PASSWORD***', // optional but needed if you want to use graphql
4344
);
4445

4546
PHPShopify\ShopifySDK::config($config);

Diff for: tests/GraphQLTest.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace PHPShopify;
4+
5+
class GraphQLTest extends TestResource
6+
{
7+
/**
8+
* GraphQLTest constructor.
9+
*/
10+
public function __construct()
11+
{
12+
parent::__construct();
13+
}
14+
15+
16+
/**
17+
* GraphQL Query Test
18+
*/
19+
public function testQuery()
20+
{
21+
$graphQL = <<<Query
22+
query {
23+
shop {
24+
name
25+
primaryDomain {
26+
url
27+
host
28+
}
29+
}
30+
}
31+
Query;
32+
33+
$return = static::$shopify->GraphQL->post($graphQL);
34+
35+
$this->assertNotEmpty($return['data']['shop']);
36+
}
37+
38+
39+
}

Diff for: tests/TestResource.php

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static function setUpBeforeClass()
2323
'ShopUrl' => getenv('SHOPIFY_SHOP_URL'), //Your shop URL
2424
'ApiKey' => getenv('SHOPIFY_API_KEY'), //Your Private API Key
2525
'Password' => getenv('SHOPIFY_API_PASSWORD'), //Your Private API Password
26+
'AccessToken' => getenv('SHOPIFY_API_PASSWORD'), //Your Access Token(Private API Password)
2627
);
2728

2829
self::$shopify = ShopifySDK::config($config);

0 commit comments

Comments
 (0)