@@ -46,20 +46,26 @@ public function setUp()
4646
4747 public function tearDown ()
4848 {
49- Client::configure (array ('client_id ' => '' , 'auth_token ' => '' , 'store_hash ' => '' ));
49+ Client::configure (array ('username ' => '' , 'api_key ' => '' , 'store_url ' => '' ));
5050 unset($ this ->connection );
5151 }
5252
53- public function testConfigureRequiresAuthToken ()
53+ public function testConfigureRequiresStoreUrl ()
5454 {
55- $ this ->setExpectedException ('\\Exception ' , "'auth_token ' must be provided " );
56- Client::configure (array ('client_id ' => 'whatever ' , 'store_hash ' => 'whatever ' ));
55+ $ this ->setExpectedException ('\\Exception ' , "'store_url ' must be provided " );
56+ Client::configure (array ('username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
5757 }
5858
59- public function testConfigureRequiresStoreHash ()
59+ public function testConfigureRequiresUsername ()
6060 {
61- $ this ->setExpectedException ('\\Exception ' , "'store_hash' must be provided " );
62- Client::configure (array ('client_id ' => 'whatever ' , 'auth_token ' => 'whatever ' ));
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 ' ));
6369 }
6470
6571 public function testFailOnErrorPassesThroughToConnection ()
@@ -116,14 +122,10 @@ public function testGetResourceReturnsSpecifiedType()
116122 {
117123 $ this ->connection ->expects ($ this ->once ())
118124 ->method ('get ' )
119- ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , false )
125+ ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , false )
120126 ->will ($ this ->returnValue (array (array ())));
121127
122- Client::configure (array (
123- 'store_hash ' => 'hash ' ,
124- 'client_id ' => 'whatever ' ,
125- 'auth_token ' => 'whatever '
126- ));
128+ Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
127129 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
128130 $ resource = Client::getResource ('/whatever ' );
129131 $ this ->assertInstanceOf ('Bigcommerce \\Api \\Resource ' , $ resource );
@@ -133,14 +135,10 @@ public function testGetCountReturnsSpecifiedCount()
133135 {
134136 $ this ->connection ->expects ($ this ->once ())
135137 ->method ('get ' )
136- ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , false )
138+ ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , false )
137139 ->will ($ this ->returnValue ((object )array ('count ' => 5 )));
138140
139- Client::configure (array (
140- 'store_hash ' => 'hash ' ,
141- 'client_id ' => 'whatever ' ,
142- 'auth_token ' => 'whatever '
143- ));
141+ Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
144142 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
145143 $ count = Client::getCount ('/whatever ' );
146144 $ this ->assertSame (5 , $ count );
@@ -150,14 +148,10 @@ public function testGetCollectionReturnsCollectionOfSpecifiedTypes()
150148 {
151149 $ this ->connection ->expects ($ this ->once ())
152150 ->method ('get ' )
153- ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , false )
151+ ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , false )
154152 ->will ($ this ->returnValue (array (array (), array ())));
155153
156- Client::configure (array (
157- 'store_hash ' => 'hash ' ,
158- 'client_id ' => 'whatever ' ,
159- 'auth_token ' => 'whatever '
160- ));
154+ Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
161155 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
162156 $ resources = Client::getCollection ('/whatever ' );
163157 $ this ->assertInternalType ('array ' , $ resources );
@@ -171,14 +165,10 @@ public function testCreateResourcePostsToTheRightPlace()
171165 $ new = array (rand () => rand ());
172166 $ this ->connection ->expects ($ this ->once ())
173167 ->method ('post ' )
174- ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , (object )$ new )
168+ ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , (object )$ new )
175169 ->will ($ this ->returnValue ($ new ));
176170
177- Client::configure (array (
178- 'store_hash ' => 'hash ' ,
179- 'client_id ' => 'whatever ' ,
180- 'auth_token ' => 'whatever '
181- ));
171+ Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
182172 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
183173 $ result = Client::createResource ('/whatever ' , $ new );
184174 $ this ->assertSame ($ new , $ result );
@@ -189,14 +179,10 @@ public function testUpdateResourcePutsToTheRightPlace()
189179 $ update = array (rand () => rand ());
190180 $ this ->connection ->expects ($ this ->once ())
191181 ->method ('put ' )
192- ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' , (object )$ update )
182+ ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' , (object )$ update )
193183 ->will ($ this ->returnValue ($ update ));
194184
195- Client::configure (array (
196- 'store_hash ' => 'hash ' ,
197- 'client_id ' => 'whatever ' ,
198- 'auth_token ' => 'whatever '
199- ));
185+ Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
200186 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
201187 $ result = Client::updateResource ('/whatever ' , $ update );
202188 $ this ->assertSame ($ update , $ result );
@@ -206,14 +192,10 @@ public function testDeleteResourceDeletesToTheRightPlace()
206192 {
207193 $ this ->connection ->expects ($ this ->once ())
208194 ->method ('delete ' )
209- ->with ('https ://api.bigcommerce.com/stores/hash/v2 /whatever ' )
195+ ->with ('http ://storeurl ' . $ this -> basePath . ' /whatever ' )
210196 ->will ($ this ->returnValue ("Successfully deleted " ));
211197
212- Client::configure (array (
213- 'store_hash ' => 'hash ' ,
214- 'client_id ' => 'whatever ' ,
215- 'auth_token ' => 'whatever '
216- ));
198+ Client::configure (array ('store_url ' => 'http://storeurl ' , 'username ' => 'whatever ' , 'api_key ' => 'whatever ' ));
217199 Client::setConnection ($ this ->connection ); // re-set the connection since Client::configure unsets it
218200 $ result = Client::deleteResource ('/whatever ' );
219201 $ this ->assertSame ("Successfully deleted " , $ result );
@@ -267,18 +249,18 @@ public function testGetRequestsRemainingRequestsTimeWhenNoValueAvailable()
267249 public function collections ()
268250 {
269251 return array (
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 ' ),
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 ' ),
276258 array ('order_statuses ' , 'getOrderStatuses ' , 'OrderStatus ' ),
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 ' ),
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 ' ),
282264 );
283265 }
284266
@@ -321,15 +303,15 @@ public function testGettingTheCountOfACollectionReturnsThatCollectionsCount($pat
321303 public function resources ()
322304 {
323305 return array (
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 ' ),
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 ' ),
333315 );
334316 }
335317
0 commit comments