Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continue of code and finalized tests
- Loading branch information
Showing
11 changed files
with
265 additions
and
23 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
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
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,56 @@ | ||
<?php | ||
|
||
namespace OhMyBrew\BasicShopifyResource\Test\Models; | ||
|
||
use OhMyBrew\BasicShopifyResource\Test\TestCase; | ||
use OhMyBrew\BasicShopifyResource\Models\Collect; | ||
use OhMyBrew\BasicShopifyResource\Models\CustomCollection; | ||
use OhMyBrew\BasicShopifyResource\Models\Product; | ||
use Tightenco\Collect\Support\Collection; | ||
|
||
class CollectTest extends TestCase | ||
{ | ||
public function testSetup() | ||
{ | ||
$props = $this->getResourceProperties(new Collect()); | ||
|
||
$this->assertEquals('collects', $props->resourcePath); | ||
$this->assertEquals('collect', $props->resourceName); | ||
$this->assertEquals('collects', $props->resourceNamePlural); | ||
$this->assertEquals('id', $props->resourcePk); | ||
} | ||
|
||
public function testFinders() | ||
{ | ||
$connection = $this->createConnection(['models/collect', 'models/collects']); | ||
$collect = $this->invokeMethod(Collect::class, 'find', [841564295]); | ||
|
||
$this->assertEquals( | ||
'/admin/collects/841564295.json', | ||
$this->getLastPathCalled($connection) | ||
); | ||
$this->assertInstanceOf(Collect::class, $collect); | ||
|
||
$collects = $this->invokeMethod(Collect::class, 'all'); | ||
|
||
$this->assertEquals( | ||
'/admin/collects.json', | ||
$this->getLastPathCalled($connection) | ||
); | ||
$this->assertInstanceOf(Collection::class, $collects); | ||
} | ||
|
||
public function testRelationships() | ||
{ | ||
$connection = $this->createConnection(['models/collect', 'models/products', 'models/custom_collections']); | ||
$collect = $this->invokeMethod(Collect::class, 'find', [841564295]); | ||
|
||
// Product (API call) | ||
$product = $collect->product; | ||
$this->assertInstanceOf(Product::class, $product); | ||
|
||
// Collection (API call) | ||
$collection = $collect->collection; | ||
$this->assertInstanceOf(CustomCollection::class, $collection); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
namespace OhMyBrew\BasicShopifyResource\Test\Models; | ||
|
||
use OhMyBrew\BasicShopifyResource\Models\Product; | ||
use OhMyBrew\BasicShopifyResource\Models\Image; | ||
use OhMyBrew\BasicShopifyResource\Test\TestCase; | ||
use Tightenco\Collect\Support\Collection; | ||
|
||
class CustomCollectionTest extends TestCase | ||
{ | ||
public function testSetup() | ||
{ | ||
$props = $this->getResourceProperties(new CustomCollection()); | ||
|
||
$this->assertEquals('custom_collections', $props->resourcePath); | ||
$this->assertEquals('custom_collection', $props->resourceName); | ||
$this->assertEquals('custom_collections', $props->resourceNamePlural); | ||
$this->assertEquals('id', $props->resourcePk); | ||
} | ||
|
||
public function testFinders() | ||
{ | ||
$connection = $this->createConnection(['models/custom_collection', 'models/custom_collections']); | ||
$collection = $this->invokeMethod(CustomCollection::class, 'find', [1063001463]); | ||
|
||
$this->assertEquals( | ||
'/admin/custom_collections/1063001463.json', | ||
$this->getLastPathCalled($connection) | ||
); | ||
$this->assertInstanceOf(CustomCollection::class, $collection); | ||
|
||
$collections = $this->invokeMethod(Collection::class, 'all'); | ||
|
||
$this->assertEquals( | ||
'/admin/custom_collections.json', | ||
$this->getLastPathCalled($connection) | ||
); | ||
$this->assertInstanceOf(Collection::class, $collections); | ||
} | ||
|
||
public function testRelationships() | ||
{ | ||
$connection = $this->createConnection(['models/custom_collection', 'models/collects']); | ||
$collection = $this->invokeMethod(CustomCollection::class, 'find', [1063001463]); | ||
|
||
// Collects (API call) | ||
$collects = $collection->collects; | ||
$this->assertInstanceOf(Collection::class, $collects); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
|
||
namespace OhMyBrew\BasicShopifyResource\Test\Models; | ||
|
||
use OhMyBrew\BasicShopifyResource\Models\Product; | ||
use OhMyBrew\BasicShopifyResource\Models\Image; | ||
use OhMyBrew\BasicShopifyResource\Test\TestCase; | ||
use Tightenco\Collect\Support\Collection; | ||
|
||
class ImageTest extends TestCase | ||
{ | ||
public function testSetup() | ||
{ | ||
$props = $this->getResourceProperties(new Image()); | ||
|
||
$this->assertEquals('images', $props->resourcePath); | ||
$this->assertEquals('image', $props->resourceName); | ||
$this->assertEquals('images', $props->resourceNamePlural); | ||
$this->assertEquals('id', $props->resourcePk); | ||
} | ||
|
||
public function testFinders() | ||
{ | ||
$connection = $this->createConnection(['models/image', 'models/images']); | ||
$image = $this->invokeMethod(Image::class, 'find', [850703190]); | ||
|
||
$this->assertEquals( | ||
'/admin/images/850703190.json', | ||
$this->getLastPathCalled($connection) | ||
); | ||
$this->assertInstanceOf(Image::class, $image); | ||
|
||
$images = $this->invokeMethod(Image::class, 'all'); | ||
|
||
$this->assertEquals( | ||
'/admin/images.json', | ||
$this->getLastPathCalled($connection) | ||
); | ||
$this->assertInstanceOf(Collection::class, $images); | ||
} | ||
|
||
public function testRelationships() | ||
{ | ||
$connection = $this->createConnection(['models/image', 'models/products']); | ||
$image = $this->invokeMethod(Image::class, 'find', [850703190]); | ||
|
||
// Product (API call) | ||
$product = $image->product; | ||
$this->assertInstanceOf(Product::class, $product); | ||
} | ||
} |
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