Skip to content

Commit 773f276

Browse files
committed
Sample tests for post(), put(), delete() actions
1 parent b11c8a3 commit 773f276

17 files changed

+226
-3
lines changed

tests/BlogTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,17 @@
1010

1111
class BlogTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"title" => "PHPShopify Test Blog",
18+
);
1319

20+
/**
21+
* @inheritDoc
22+
*/
23+
public $putArray = array(
24+
"title" => "PHPShopify Test Blog Modified",
25+
);
1426
}

tests/CarrierServiceTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,20 @@
1010

1111
class CarrierServiceTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"name" => "Shipping Rate Provider",
18+
"callback_url" => "http://shippingrateprovider.com",
19+
"service_discovery" => true
20+
);
1321

22+
/**
23+
* @inheritDoc
24+
*/
25+
public $putArray = array(
26+
"name" => "Updated Shipping Rate Provider",
27+
"active" => false,
28+
);
1429
}

tests/CountryTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,18 @@
1010

1111
class CountryTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"code" => "FR",
18+
"tax" => 0.25,
19+
);
1320

21+
/**
22+
* @inheritDoc
23+
*/
24+
public $putArray = array(
25+
"tax" => 0.01,
26+
);
1427
}

tests/CustomCollectionTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,18 @@
1010

1111
class CustomCollectionTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"title" => "Macbooks"
18+
);
1319

20+
/**
21+
* @inheritDoc
22+
*/
23+
public $putArray = array(
24+
"title" => "Updated - Macbooks",
25+
"body_html" => "<p>The best selling Macbooks ever</p>",
26+
);
1427
}

tests/CustomerSavedSearchTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,18 @@
1010

1111
class CustomerSavedSearchTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"name" => "Spent more than $50 and after 2015",
18+
"query" => "total_spent:>50 order_date:>=2015-01-01",
19+
);
1320

21+
/**
22+
* @inheritDoc
23+
*/
24+
public $putArray = array(
25+
"name" => "This Name Has Been Changed",
26+
);
1427
}

tests/CustomerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,19 @@
1010

1111
class CustomerTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"first_name" => "Steve",
18+
"last_name" => "Lastnameson",
19+
"email" => "[email protected]",
20+
);
1321

22+
/**
23+
* @inheritDoc
24+
*/
25+
public $putArray = array(
26+
"verified_email" => true,
27+
);
1428
}

tests/FulfillmentServiceTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,23 @@
1010

1111
class FulfillmentServiceTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"name" => "MarsFulfillment",
18+
"callback_url" => "http://google.com",
19+
"inventory_management" => true,
20+
"tracking_support" => true,
21+
"requires_shipping_method" => true,
22+
"format" => "json"
23+
);
24+
25+
/**
26+
* @inheritDoc
27+
*/
28+
public $putArray = array(
29+
"inventory_management" => false
30+
);
1331

1432
}

tests/MetafieldTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,21 @@
1010

1111
class MetafieldTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"namespace" => "inventory",
18+
"key" => "warehouse",
19+
"value" => 25,
20+
"value_type" => "integer",
21+
);
1322

23+
/**
24+
* @inheritDoc
25+
*/
26+
public $putArray = array(
27+
"value" => "something new",
28+
"value_type" => "string",
29+
);
1430
}

tests/PageTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,18 @@
1010

1111
class PageTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public $postArray = array(
17+
"title" => "Warranty information",
18+
"body_html" => "<h1>Warranty<\/h1>\n<p><strong>Forget it<\/strong>, we aint giving you nothing<\/p>",
19+
);
1320

21+
/**
22+
* @inheritDoc
23+
*/
24+
public $putArray = array(
25+
"title" => "Updated Warranty information"
26+
);
1427
}

tests/ProductTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
class ProductTest extends TestSimpleResource
1212
{
13+
/**
14+
* @inheritDoc
15+
*/
1316
public $postArray = array(
1417
"title" => "Burton Custom Freestlye 151",
1518
"body_html" => "<strong>Good snowboard!</strong>",
@@ -29,8 +32,14 @@ class ProductTest extends TestSimpleResource
2932
]
3033
);
3134

32-
//Posting without title, triggers an error
35+
/**
36+
* @inheritDoc
37+
* Posting without title, triggers an error
38+
*/
3339
public $errorPostArray = array("description" => "A mystery!");
3440

41+
/**
42+
* @inheritDoc
43+
*/
3544
public $putArray = array("title" => "New product title");
3645
}

0 commit comments

Comments
 (0)