@@ -46,26 +46,20 @@ public function setUp()
4646
4747 public function tearDown ()
4848 {
49- Client::configure (array ('username ' => '' , 'api_key ' => '' , 'store_url ' => '' ));
49+ Client::configure (array ('client_id ' => '' , 'auth_token ' => '' , 'store_hash ' => '' ));
5050 unset($ this ->connection );
5151 }
5252
53- public function testConfigureRequiresStoreUrl ()
53+ public function testConfigureRequiresAuthToken ()
5454 {
55- $ this ->setExpectedException ('\\Exception ' , "'store_url ' must be provided " );
56- Client::configure (array ('username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
55+ $ this ->setExpectedException ('\\Exception ' , "'auth_token ' must be provided " );
56+ Client::configure (array ('client_id ' => 'whatever ' , 'store_hash ' => 'whatever ' ));
5757 }
5858
59- public function testConfigureRequiresUsername ()
59+ public function testConfigureRequiresStoreHash ()
6060 {
61- $ this ->setExpectedException ('\\Exception ' , "'username' must be provided " );
62- Client::configure (array ('store_url ' => 'whatever ' , 'api_key ' => 'whatever ' ));
63- }
64-
65- public function testConfigureRequiresApiKey ()
66- {
67- $ this ->setExpectedException ('\\Exception ' , "'api_key' must be provided " );
68- Client::configure (array ('username ' => 'whatever ' , 'store_url ' => 'whatever ' ));
61+ $ this ->setExpectedException ('\\Exception ' , "'store_hash' must be provided " );
62+ Client::configure (array ('client_id ' => 'whatever ' , 'auth_token ' => 'whatever ' ));
6963 }
7064
7165 public function testFailOnErrorPassesThroughToConnection ()
@@ -122,10 +116,14 @@ public function testGetResourceReturnsSpecifiedType()
122116 {
123117 $ this ->connection ->expects ($ this ->once ())
124118 ->method ('get ' )
125- ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , false )
119+ ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , false )
126120 ->will ($ this ->returnValue (array (array ())));
127121
128- Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
122+ Client::configure (array (
123+ 'store_hash ' => 'hash ' ,
124+ 'client_id ' => 'whatever ' ,
125+ 'auth_token ' => 'whatever '
126+ ));
129127 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
130128 $ resource = Client::getResource ('/whatever ' );
131129 $ this ->assertInstanceOf ('Bigcommerce \\Api \\Resource ' , $ resource );
@@ -135,10 +133,14 @@ public function testGetCountReturnsSpecifiedCount()
135133 {
136134 $ this ->connection ->expects ($ this ->once ())
137135 ->method ('get ' )
138- ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , false )
136+ ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , false )
139137 ->will ($ this ->returnValue ((object )array ('count ' => 5 )));
140138
141- Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
139+ Client::configure (array (
140+ 'store_hash ' => 'hash ' ,
141+ 'client_id ' => 'whatever ' ,
142+ 'auth_token ' => 'whatever '
143+ ));
142144 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
143145 $ count = Client::getCount ('/whatever ' );
144146 $ this ->assertSame (5 , $ count );
@@ -148,10 +150,14 @@ public function testGetCollectionReturnsCollectionOfSpecifiedTypes()
148150 {
149151 $ this ->connection ->expects ($ this ->once ())
150152 ->method ('get ' )
151- ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , false )
153+ ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , false )
152154 ->will ($ this ->returnValue (array (array (), array ())));
153155
154- Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
156+ Client::configure (array (
157+ 'store_hash ' => 'hash ' ,
158+ 'client_id ' => 'whatever ' ,
159+ 'auth_token ' => 'whatever '
160+ ));
155161 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
156162 $ resources = Client::getCollection ('/whatever ' );
157163 $ this ->assertInternalType ('array ' , $ resources );
@@ -165,10 +171,14 @@ public function testCreateResourcePostsToTheRightPlace()
165171 $ new = array (rand () => rand ());
166172 $ this ->connection ->expects ($ this ->once ())
167173 ->method ('post ' )
168- ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , (object )$ new )
174+ ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , (object )$ new )
169175 ->will ($ this ->returnValue ($ new ));
170176
171- Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
177+ Client::configure (array (
178+ 'store_hash ' => 'hash ' ,
179+ 'client_id ' => 'whatever ' ,
180+ 'auth_token ' => 'whatever '
181+ ));
172182 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
173183 $ result = Client::createResource ('/whatever ' , $ new );
174184 $ this ->assertSame ($ new , $ result );
@@ -179,10 +189,14 @@ public function testUpdateResourcePutsToTheRightPlace()
179189 $ update = array (rand () => rand ());
180190 $ this ->connection ->expects ($ this ->once ())
181191 ->method ('put ' )
182- ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , (object )$ update )
192+ ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , (object )$ update )
183193 ->will ($ this ->returnValue ($ update ));
184194
185- Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
195+ Client::configure (array (
196+ 'store_hash ' => 'hash ' ,
197+ 'client_id ' => 'whatever ' ,
198+ 'auth_token ' => 'whatever '
199+ ));
186200 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
187201 $ result = Client::updateResource ('/whatever ' , $ update );
188202 $ this ->assertSame ($ update , $ result );
@@ -192,10 +206,14 @@ public function testDeleteResourceDeletesToTheRightPlace()
192206 {
193207 $ this ->connection ->expects ($ this ->once ())
194208 ->method ('delete ' )
195- ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' )
209+ ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' )
196210 ->will ($ this ->returnValue ("Successfully deleted " ));
197211
198- Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
212+ Client::configure (array (
213+ 'store_hash ' => 'hash ' ,
214+ 'client_id ' => 'whatever ' ,
215+ 'auth_token ' => 'whatever '
216+ ));
199217 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
200218 $ result = Client::deleteResource ('/whatever ' );
201219 $ this ->assertSame ("Successfully deleted " , $ result );
@@ -249,18 +267,18 @@ public function testGetRequestsRemainingRequestsTimeWhenNoValueAvailable()
249267 public function collections ()
250268 {
251269 return array (
252- // path function classname
253- array ('products ' , 'getProducts ' , 'Product ' ),
254- array ('brands ' , 'getBrands ' , 'Brand ' ),
255- array ('orders ' , 'getOrders ' , 'Order ' ),
256- array ('customers ' , 'getCustomers ' , 'Customer ' ),
257- array ('coupons ' , 'getCoupons ' , 'Coupon ' ),
270+ // path function classname
271+ array ('products ' , 'getProducts ' , 'Product ' ),
272+ array ('brands ' , 'getBrands ' , 'Brand ' ),
273+ array ('orders ' , 'getOrders ' , 'Order ' ),
274+ array ('customers ' , 'getCustomers ' , 'Customer ' ),
275+ array ('coupons ' , 'getCoupons ' , 'Coupon ' ),
258276 array ('order_statuses ' , 'getOrderStatuses ' , 'OrderStatus ' ),
259- array ('categories ' , 'getCategories ' , 'Category ' ),
260- array ('options ' , 'getOptions ' , 'Option ' ),
261- array ('optionsets ' , 'getOptionSets ' , 'OptionSet ' ),
262- array ('products/skus ' , 'getSkus ' , 'Sku ' ),
263- array ('requestlogs ' , 'getRequestLogs ' , 'RequestLog ' ),
277+ array ('categories ' , 'getCategories ' , 'Category ' ),
278+ array ('options ' , 'getOptions ' , 'Option ' ),
279+ array ('optionsets ' , 'getOptionSets ' , 'OptionSet ' ),
280+ array ('products/skus ' , 'getSkus ' , 'Sku ' ),
281+ array ('requestlogs ' , 'getRequestLogs ' , 'RequestLog ' ),
264282 );
265283 }
266284
@@ -303,15 +321,15 @@ public function testGettingTheCountOfACollectionReturnsThatCollectionsCount($pat
303321 public function resources ()
304322 {
305323 return array (
306- // path function classname
307- array ('products ' , '%sProduct ' , 'Product ' ),
308- array ('brands ' , '%sBrand ' , 'Brand ' ),
309- array ('orders ' , '%sOrder ' , 'Order ' ),
310- array ('customers ' , '%sCustomer ' , 'Customer ' ),
311- array ('categories ' , '%sCategory ' , 'Category ' ),
312- array ('options ' , '%sOption ' , 'Option ' ),
313- array ('optionsets ' , '%sOptionSet ' , 'OptionSet ' ),
314- array ('coupons ' , '%sCoupon ' , 'Coupon ' ),
324+ // path function classname
325+ array ('products ' , '%sProduct ' , 'Product ' ),
326+ array ('brands ' , '%sBrand ' , 'Brand ' ),
327+ array ('orders ' , '%sOrder ' , 'Order ' ),
328+ array ('customers ' , '%sCustomer ' , 'Customer ' ),
329+ array ('categories ' , '%sCategory ' , 'Category ' ),
330+ array ('options ' , '%sOption ' , 'Option ' ),
331+ array ('optionsets ' , '%sOptionSet ' , 'OptionSet ' ),
332+ array ('coupons ' , '%sCoupon ' , 'Coupon ' ),
315333 );
316334 }
317335
0 commit comments