Skip to content

Commit

Permalink
Merge pull request #131 from aligent/release/1.8.1
Browse files Browse the repository at this point in the history
Release/1.8.1
  • Loading branch information
jswift authored May 19, 2022
2 parents d6e1e7e + 9439793 commit b2c1627
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### New Features
### Fixes

- Fixes _Undefined index within customer getByEmail method_ (thanks @dniccum)

- Implement V2 Order Products API
- Implement V2 Order Shipping Addresses API (read-only)



Expand Down
2 changes: 1 addition & 1 deletion src/BigCommerce/Api/Customers/CustomersApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getByEmail(string $email): ?Customer
{
$customers = $this->getAll([self::FILTER__EMAIL_IN => $email])->getCustomers();

if (!$customers[0]) {
if (count($customers) === 0) {
return null;
} elseif (count($customers) > 1) {
throw new UnexpectedValueException("There are more than one customer with the email address $email");
Expand Down
8 changes: 8 additions & 0 deletions tests/BigCommerce/Api/Customers/CustomersApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public function testCanGetCustomerByEmail()
$this->assertEquals('John', $customer->first_name);
}

public function testUnknownCustomerReturnsEmptyResult()
{
$this->setReturnData('customers__get_all_no_results.json');
$customer = $this->getApi()->customers()->getByEmail('[email protected]');

$this->assertNull($customer);
}

public function testCanGetCustomerById()
{
$this->setReturnData('customers__get_all.json');
Expand Down

0 comments on commit b2c1627

Please sign in to comment.