WWW::Shopify::Test - A subclass of WWW::Shopify which represents a testing environment.
A WWW::Shopify object that instead of making calls to a particular URL uses a database to represent an instance of a shopify store.
In addition to providing a method to access the database, the test subclass also provides a method to generate entries in the database for testing purposes using the generate method.
Should be used as WWW::Shopify as a normal store. Prior to doing this, the object must be 'associated' with a particular store on our fake database.
It can be done like the following:
my $db = WWW::Shopify::Model::DBIx::Schema->connect('dbi:SQLite:dbname=' . tmpnam(), { RaiseError => 1, AutoCommit => 1 }); $db->generate([WWW::Shopify::Model::Shop]); my $sa = new WWW::Shopify::Test($db); $sa->associate_randomly();
A bunch of methods are unique to the WWW::Shopify::Test, and not part of the normal WWW::Shopify, namely the associate methods and the generate method; they are listed here.
Takes in a Model::DBIx::Model::Shop. Associate this object with the shop, meaning that every call you make on this object will target that particular shop.
This must be called (directly or indirectly) before any calls can be made to the shop.
Calls associate with a random shop from the database.
Calls associate with a shop that is NOT in the list of urls that you pass into this function.
$SA->associate_unlinked('hostname1', 'hostname2');
Calls associate with a shop that is in the list of urls that you pass in to this function.
$SA->associate_linked('hostname1', 'hostname2');
As of now, there's only one generation function. These functions generate objects for the underlying database.
The generate method. Generates a whole ton of stuff for your database. Doesn't have to be associate with a shop; generates shops as well.
Essentially, what you want to do when you call this is pass in a list of class names (WWW::Shopify::Model:: style, not the DBIx ones) in an array, and this funciton will generate them, and if necessary their dependencies.
It'll generate 50*(:: count - 2)^2 of the class (so WWW::Shopify::Model::Product'll get 50, but there'll be 200 WWW::Shopify::Model::Product::Variants)
WWW::Shopify::Model::Shop is a special case, that's set to 6, basically for lulz.
Calls go like so:
$SA->generate(['WWW::Shopify::Model::Shop', 'WWW::Shopify::Model::Product']);
Note, this can take a while, depending on the speed of your computer/virtual machine. Once it's finished, you should have a nice little database full of bogus data of the proper type.
When the shop doesn't have an access_token, this is what you should be redirecting your client to. Inputs should be your scope, as an array, and the url you want to redirect to.
When you have a temporary code, which you should get from authorize_url's redirect and you want to exchange it for a token, you call this.
WWW::Shopify
Adam Harrison
See LICENSE in the main directory.
To install WWW::Shopify, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Shopify
CPAN shell
perl -MCPAN -e shell install WWW::Shopify
For more information on module installation, please visit the detailed CPAN module installation guide.