From d65d1015c83fbd4c3bf834ab00463655975fd3fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 5 Oct 2023 15:03:18 +0200 Subject: [PATCH] Fix customer test --- tests/Client/CrmClientV2CustomerTest.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/Client/CrmClientV2CustomerTest.php b/tests/Client/CrmClientV2CustomerTest.php index e800bda..e20d0ed 100644 --- a/tests/Client/CrmClientV2CustomerTest.php +++ b/tests/Client/CrmClientV2CustomerTest.php @@ -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; }