Fix customer test
This commit is contained in:
parent
85228f1bb6
commit
d65d1015c8
1 changed files with 12 additions and 6 deletions
|
|
@ -310,6 +310,12 @@ class CrmClientV2CustomerTest extends CrmClientTester
|
|||
$customer = $api->getCustomerOrNew(static::$info->hashcode);
|
||||
$this->assertEquals(Country::belgium(), $customer->country);
|
||||
|
||||
$customer->country = Country::france();
|
||||
$customer->save();
|
||||
|
||||
$customer = $api->getCustomerOrNew(static::$info->hashcode);
|
||||
$this->assertEquals(Country::france(), $customer->country);
|
||||
|
||||
$customer->email = 'pouet@gmail.com';
|
||||
$customer->birth_date = '1992-03-08';
|
||||
$customer->phone = '0388977213';
|
||||
|
|
@ -499,18 +505,18 @@ class CrmClientV2CustomerTest extends CrmClientTester
|
|||
private function createNewCustomer(array $data, Brand $brand)
|
||||
{
|
||||
$customer = \App\Models\Customer::whereEmail($data['email'])
|
||||
->whereHas('brands', function ($q) use ($brand) {
|
||||
$q->where('brands.id', '=', $brand->id);
|
||||
})->firstOrNew();
|
||||
->whereHas('brands', function ($q) use ($brand) {
|
||||
$q->where('brands.id', '=', $brand->id);
|
||||
})->firstOrNew();
|
||||
$customer->fill($data);
|
||||
$saved = $customer->save();
|
||||
|
||||
// * Delete Single optin if exists.
|
||||
/** @var \App\Models\SingleOptin|null $singleOptin */
|
||||
$singleOptin = SingleOptin::query()->where('email', $data['email'])
|
||||
->whereHas('brand', function ($q) use ($brand) {
|
||||
$q->where('brands.id', '=', $brand->id);
|
||||
})->first();
|
||||
->whereHas('brand', function ($q) use ($brand) {
|
||||
$q->where('brands.id', '=', $brand->id);
|
||||
})->first();
|
||||
if ($singleOptin) {
|
||||
$saved = $singleOptin->delete() && $saved;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue