File tree 3 files changed +12
-4
lines changed
src/BigCommerce/Api/Customers
tests/BigCommerce/Api/Customers
3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
- ### New Features
1
+ ### Fixes
2
+
3
+ - Fixes _ Undefined index within customer getByEmail method_ (thanks @dniccum )
2
4
3
- - Implement V2 Order Products API
4
- - Implement V2 Order Shipping Addresses API (read-only)
5
5
6
6
7
7
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function getByEmail(string $email): ?Customer
33
33
{
34
34
$ customers = $ this ->getAll ([self ::FILTER__EMAIL_IN => $ email ])->getCustomers ();
35
35
36
- if (! $ customers[ 0 ] ) {
36
+ if (count ( $ customers) === 0 ) {
37
37
return null ;
38
38
} elseif (count ($ customers ) > 1 ) {
39
39
throw new UnexpectedValueException ("There are more than one customer with the email address $ email " );
Original file line number Diff line number Diff line change @@ -38,6 +38,14 @@ public function testCanGetCustomerByEmail()
38
38
$ this ->assertEquals ('John ' , $ customer ->first_name );
39
39
}
40
40
41
+ public function testUnknownCustomerReturnsEmptyResult ()
42
+ {
43
+ $ this ->setReturnData ('customers__get_all_no_results.json ' );
44
+ $ customer =
$ this ->
getApi ()->
customers ()->
getByEmail (
'[email protected] ' );
45
+
46
+ $ this ->assertNull ($ customer );
47
+ }
48
+
41
49
public function testCanGetCustomerById ()
42
50
{
43
51
$ this ->setReturnData ('customers__get_all.json ' );
You can’t perform that action at this time.
0 commit comments