Skip to content

Commit 13915b7

Browse files
committed
fixing broken unit tests, mostly resolving around use of base API path being missing from mocking expectations. should not cause brokenness in live code. ALSO renamed createOptionsets_Options to match PSR2
1 parent 0a6e2df commit 13915b7

21 files changed

Lines changed: 148 additions & 120 deletions

src/Bigcommerce/Api/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ public static function createOptionsets($object)
979979
* @param $id
980980
* @return mixed
981981
*/
982-
public static function createOptionsets_Options($object, $id)
982+
public static function createOptionsetsOptions($object, $id)
983983
{
984984
return self::createResource('/optionsets/' . $id . '/options', $object);
985985
}

test/Unit/Api/ClientTest.php

Lines changed: 71 additions & 59 deletions
Large diffs are not rendered by default.

test/Unit/Api/Resources/BrandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testCreatePassesThroughToConnection()
1111
$brand = new Brand();
1212
$this->connection->expects($this->once())
1313
->method('post')
14-
->with('/brands', $brand->getCreateFields());
14+
->with($this->basePath . '/brands', $brand->getCreateFields());
1515

1616
$brand->create();
1717
}
@@ -21,7 +21,7 @@ public function testUpdatePassesThroughToConnection()
2121
$brand = new Brand((object)(array('id' => 1)));
2222
$this->connection->expects($this->once())
2323
->method('put')
24-
->with('/brands/1', $brand->getUpdateFields());
24+
->with($this->basePath . '/brands/1', $brand->getUpdateFields());
2525

2626
$brand->update();
2727
}

test/Unit/Api/Resources/CategoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testCreatePassesThroughToConnection()
1111
$category = new Category();
1212
$this->connection->expects($this->once())
1313
->method('post')
14-
->with('/categories', $category->getCreateFields());
14+
->with($this->basePath . '/categories', $category->getCreateFields());
1515

1616
$category->create();
1717
}
@@ -21,7 +21,7 @@ public function testUpdatePassesThroughToConnection()
2121
$category = new Category((object)(array('id' => 1)));
2222
$this->connection->expects($this->once())
2323
->method('put')
24-
->with('/categories/1', $category->getUpdateFields());
24+
->with($this->basePath . '/categories/1', $category->getUpdateFields());
2525

2626
$category->update();
2727
}

test/Unit/Api/Resources/CouponTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testCreatePassesThroughToConnection()
1111
$coupon = new Coupon();
1212
$this->connection->expects($this->once())
1313
->method('post')
14-
->with('/coupons', $coupon->getCreateFields());
14+
->with($this->basePath . '/coupons', $coupon->getCreateFields());
1515

1616
$coupon->create();
1717
}
@@ -21,7 +21,7 @@ public function testUpdatePassesThroughToConnection()
2121
$coupon = new Coupon((object)(array('id' => 1)));
2222
$this->connection->expects($this->once())
2323
->method('put')
24-
->with('/coupons/1', $coupon->getUpdateFields());
24+
->with($this->basePath . '/coupons/1', $coupon->getUpdateFields());
2525

2626
$coupon->update();
2727
}

test/Unit/Api/Resources/CustomerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testAddressesPassesThroughToConnection()
1111
$customer = new Customer((object)array('addresses' => (object)array('resource' => '/customers/1/addresses')));
1212
$this->connection->expects($this->once())
1313
->method('get')
14-
->with('/customers/1/addresses')
14+
->with($this->basePath . '/customers/1/addresses')
1515
->will($this->returnValue(array(array(), array())));
1616

1717
foreach ($customer->addresses as $address) {
@@ -24,7 +24,7 @@ public function testCreatePassesThroughToConnection()
2424
$customer = new Customer();
2525
$this->connection->expects($this->once())
2626
->method('post')
27-
->with('/customers', $customer->getCreateFields());
27+
->with($this->basePath . '/customers', $customer->getCreateFields());
2828

2929
$customer->create();
3030
}
@@ -34,7 +34,7 @@ public function testUpdatePassesThroughToConnection()
3434
$customer = new Customer((object)(array('id' => 1)));
3535
$this->connection->expects($this->once())
3636
->method('put')
37-
->with('/customers/1', $customer->getUpdateFields());
37+
->with($this->basePath . '/customers/1', $customer->getUpdateFields());
3838

3939
$customer->update();
4040
}
@@ -44,7 +44,7 @@ public function testDeletePassesThroughToConnection()
4444
$customer = new Customer((object)(array('id' => 1)));
4545
$this->connection->expects($this->once())
4646
->method('delete')
47-
->with('/customers/1');
47+
->with($this->basePath . '/customers/1');
4848

4949
$customer->delete();
5050
}

test/Unit/Api/Resources/OptionSetOptionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testOptionPassesThroughToConnection()
1111
$optionsetoption = new OptionSetOption((object)array('option' => (object)array('resource' => '/options/1')));
1212
$this->connection->expects($this->once())
1313
->method('get')
14-
->with('/options/1')
14+
->with($this->basePath . '/options/1')
1515
->will($this->returnValue(array(array())));
1616

1717
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\Option', $optionsetoption->option);
@@ -22,7 +22,7 @@ public function testCreatePassesThroughToConnection()
2222
$optionsetoption = new OptionSetOption();
2323
$this->connection->expects($this->once())
2424
->method('post')
25-
->with('/optionsets/options', $optionsetoption->getCreateFields());
25+
->with($this->basePath . '/optionsets/options', $optionsetoption->getCreateFields());
2626

2727
$optionsetoption->create();
2828
}
@@ -32,7 +32,7 @@ public function testUpdatePassesThroughToConnection()
3232
$optionsetoption = new OptionSetOption((object)(array('id' => 1)));
3333
$this->connection->expects($this->once())
3434
->method('put')
35-
->with('/optionsets/options/1', $optionsetoption->getUpdateFields());
35+
->with($this->basePath . '/optionsets/options/1', $optionsetoption->getUpdateFields());
3636

3737
$optionsetoption->update();
3838
}

test/Unit/Api/Resources/OptionSetTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testOptionsPassesThroughToConnection()
1111
$optionset = new OptionSet((object)array('options' => (object)array('resource' => '/optionsets/1/options')));
1212
$this->connection->expects($this->once())
1313
->method('get')
14-
->with('/optionsets/1/options')
14+
->with($this->basePath . '/optionsets/1/options')
1515
->will($this->returnValue(array(array(), array())));
1616

1717
foreach ($optionset->options as $value) {
@@ -24,7 +24,7 @@ public function testCreatePassesThroughToConnection()
2424
$optionset = new OptionSet();
2525
$this->connection->expects($this->once())
2626
->method('post')
27-
->with('/optionsets', $optionset->getCreateFields());
27+
->with($this->basePath . '/optionsets', $optionset->getCreateFields());
2828

2929
$optionset->create();
3030
}
@@ -34,7 +34,7 @@ public function testUpdatePassesThroughToConnection()
3434
$optionset = new OptionSet((object)array('id' => 1));
3535
$this->connection->expects($this->once())
3636
->method('put')
37-
->with('/optionsets/1', $optionset->getUpdateFields());
37+
->with($this->basePath . '/optionsets/1', $optionset->getUpdateFields());
3838

3939
$optionset->update();
4040
}

test/Unit/Api/Resources/OptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testValuesPassesThroughToConnection()
1111
$option = new Option((object)array('values' => (object)array('resource' => '/options/1/values')));
1212
$this->connection->expects($this->once())
1313
->method('get')
14-
->with('/options/1/values')
14+
->with($this->basePath . '/options/1/values')
1515
->will($this->returnValue(array(array(), array())));
1616

1717
foreach ($option->values as $value) {

test/Unit/Api/Resources/OptionValueTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function testOptionPassesThroughToConnection()
1111
$optionvalue = new OptionValue((object)array('option_id' => 1));
1212
$this->connection->expects($this->once())
1313
->method('get')
14-
->with('/options/1')
14+
->with($this->basePath . '/options/1')
1515
->will($this->returnValue(array(array())));
1616

1717
$this->assertInstanceOf('Bigcommerce\\Api\\Resources\\Option', $optionvalue->option);
@@ -23,7 +23,7 @@ public function testCreatePassesThroughToConnection()
2323
$optionvalue = new OptionValue((object)array('option_id' => 1));
2424
$this->connection->expects($this->once())
2525
->method('post')
26-
->with('/options/1/values', $optionvalue->getCreateFields());
26+
->with($this->basePath . '/options/1/values', $optionvalue->getCreateFields());
2727

2828
$optionvalue->create();
2929
}
@@ -34,7 +34,7 @@ public function testUpdatePassesThroughToConnection()
3434
$optionvalue = new OptionValue((object)array('id' => 1, 'option_id' => 1));
3535
$this->connection->expects($this->once())
3636
->method('put')
37-
->with('/options/1/values/1', $optionvalue->getUpdateFields());
37+
->with($this->basePath . '/options/1/values/1', $optionvalue->getUpdateFields());
3838

3939
$optionvalue->update();
4040
}

0 commit comments

Comments
 (0)