-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
670 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace OhMyBrew\BasicShopifyResource\Test\Models; | ||
|
||
use OhMyBrew\BasicShopifyResource\Models\Product; | ||
use OhMyBrew\BasicShopifyResource\Test\TestCase; | ||
use Tightenco\Collect\Support\Collection; | ||
|
||
class ProducteTest extends TestCase | ||
{ | ||
public function testSetup() | ||
{ | ||
$props = $this->getResourceProperties(new Product()); | ||
|
||
$this->assertEquals('products', $props->resourcePath); | ||
$this->assertEquals('product', $props->resourceName); | ||
$this->assertEquals('products', $props->resourceNamePlural); | ||
$this->assertEquals('id', $props->resourcePk); | ||
} | ||
|
||
public function testFinders() | ||
{ | ||
$connection = $this->createConnection(['models/product', 'models/products']); | ||
$product = $this->invokeMethod(Product::class, 'find', [632910392]); | ||
|
||
$this->assertEquals( | ||
'/admin/products/632910392.json', | ||
$this->getLastPathCalled($connection) | ||
); | ||
$this->assertInstanceOf(Product::class, $product); | ||
|
||
$products = $this->invokeMethod(Product::class, 'all'); | ||
|
||
$this->assertEquals( | ||
'/admin/products.json', | ||
$this->getLastPathCalled($connection) | ||
); | ||
$this->assertInstanceOf(Collection::class, $products); | ||
} | ||
|
||
public function testRelationships() | ||
{ | ||
$connection = $this->createConnection(['models/product', 'models/custom_collections', 'models/collects']); | ||
$product = $this->invokeMethod(Product::class, 'find', [632910392]); | ||
|
||
// Variants (no API call) | ||
$variants = $product->variants; | ||
$this->assertInstanceOf(Collection::class, $variants); | ||
$this->assertTrue($variants->count() > 0); | ||
|
||
// Images (no API call) | ||
$images = $product->images; | ||
$this->assertInstanceOf(Collection::class, $images); | ||
$this->assertTrue($images->count() > 0); | ||
|
||
// Custom collections (API call) | ||
$collections = $product->collections; | ||
$this->assertInstanceOf(Collection::class, $collections); | ||
$this->assertTrue($collections->count() > 0); | ||
|
||
// Collect (API call) | ||
$collects = $product->collects; | ||
$this->assertInstanceOf(Collection::class, $collects); | ||
$this->assertTrue($collects->count() > 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"collect": { | ||
"id": 841564295, | ||
"collection_id": 841564295, | ||
"product_id": 632910392, | ||
"featured": false, | ||
"created_at": null, | ||
"updated_at": null, | ||
"position": 1, | ||
"sort_value": "0000000001" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"collects": [ | ||
{ | ||
"id": 395646240, | ||
"collection_id": 395646240, | ||
"product_id": 632910392, | ||
"featured": false, | ||
"created_at": null, | ||
"updated_at": null, | ||
"position": 1, | ||
"sort_value": "0000000001" | ||
}, | ||
{ | ||
"id": 841564295, | ||
"collection_id": 841564295, | ||
"product_id": 632910392, | ||
"featured": false, | ||
"created_at": null, | ||
"updated_at": null, | ||
"position": 1, | ||
"sort_value": "0000000001" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"custom_collection": { | ||
"id": 1063001463, | ||
"handle": "macbooks", | ||
"title": "Macbooks", | ||
"updated_at": "2016-03-17T16:58:37-04:00", | ||
"body_html": null, | ||
"published_at": "2016-03-17T16:58:37-04:00", | ||
"sort_order": "alpha-asc", | ||
"template_suffix": null, | ||
"published_scope": "global", | ||
"image": { | ||
"created_at": "2016-03-17T16:58:37-04:00", | ||
"src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/collections\/fd43f2c8883f6e9b680e3295fd990d2c.gif?v=1458248317" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"custom_collections": [ | ||
{ | ||
"id": 841564295, | ||
"handle": "ipods", | ||
"title": "IPods", | ||
"updated_at": "2008-02-01T19:00:00-05:00", | ||
"body_html": "<p>The best selling ipod ever</p>", | ||
"published_at": "2008-02-01T19:00:00-05:00", | ||
"sort_order": "manual", | ||
"template_suffix": null, | ||
"published_scope": "web", | ||
"admin_graphql_api_id": "gid://shopify/Collection/841564295", | ||
"image": { | ||
"created_at": "2018-09-25T15:15:37-04:00", | ||
"alt": "iPod Nano 8gb", | ||
"width": 123, | ||
"height": 456, | ||
"src": "https://cdn.shopify.com/s/files/1/0006/9093/3842/collections/ipod_nano_8gb.jpg?v=1537902937" | ||
} | ||
}, | ||
{ | ||
"id": 395646240, | ||
"handle": "ipods_two", | ||
"title": "IPods Two", | ||
"updated_at": "2008-02-01T19:00:00-05:00", | ||
"body_html": "<p>The best selling ipod ever. Again</p>", | ||
"published_at": "2008-02-01T19:00:00-05:00", | ||
"sort_order": "manual", | ||
"template_suffix": null, | ||
"published_scope": "web", | ||
"admin_graphql_api_id": "gid://shopify/Collection/395646240" | ||
}, | ||
{ | ||
"id": 691652237, | ||
"handle": "non-ipods", | ||
"title": "Non Ipods", | ||
"updated_at": "2013-02-01T19:00:00-05:00", | ||
"body_html": "<p>No ipods here</p>", | ||
"published_at": "2013-02-01T19:00:00-05:00", | ||
"sort_order": "manual", | ||
"template_suffix": null, | ||
"published_scope": "web", | ||
"admin_graphql_api_id": "gid://shopify/Collection/691652237" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"images": [ | ||
{ | ||
"created_at": "2014-01-17T16:11:52-05:00", | ||
"id": 850703190, | ||
"position": 1, | ||
"product_id": 632910392, | ||
"updated_at": "2014-01-17T16:11:52-05:00", | ||
"src": "http://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1389993112" | ||
}, | ||
{ | ||
"created_at": "2014-01-17T16:11:52-05:00", | ||
"id": 562641783, | ||
"position": 2, | ||
"product_id": 632910392, | ||
"updated_at": "2014-01-17T16:11:52-05:00", | ||
"src": "http://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano-2.png?v=1389993112" | ||
} | ||
] | ||
} |
Oops, something went wrong.