diff --git a/tests/Unit/CrmClientV2CustomerTest.php b/tests/Unit/CrmClientV2CustomerTest.php index 1d1252d..ba94555 100644 --- a/tests/Unit/CrmClientV2CustomerTest.php +++ b/tests/Unit/CrmClientV2CustomerTest.php @@ -87,9 +87,9 @@ class CrmClientV2CustomerTest extends CrmClientTester 'phone' => '0673891630', 'address' => 'string', 'address2' => 'string', - 'city' => 'string', + 'city' => 18, 'postcode' => 'string', - 'country' => Country::afghanistan()->value, + 'country' => Country::afghanistan(), 'optin' => true, 'status' => true, ]; @@ -145,21 +145,6 @@ class CrmClientV2CustomerTest extends CrmClientTester $this->assertTrue($customer->activate()); } - public function testCustomerToggleOptin() - { - $api = new CrmApiV2(); - $customer = $api->getCustomerOrNew(static::$info->hashcode); - - $this->assertTrue($customer->toggleOptin()); - $this->assertTrue($customer->opt_in); - - $this->assertTrue($customer->toggleOptin()); - $this->assertFalse($customer->opt_in); - - $this->assertTrue($customer->toggleOptin()); - $this->assertTrue($customer->opt_in); - } - public function testCustomerUpdateProps() { $api = new CrmApiV2(); @@ -171,10 +156,70 @@ class CrmClientV2CustomerTest extends CrmClientTester $customer = $api->getCustomerOrNew(static::$info->hashcode); $this->assertEquals('toto', $customer->firstname); + $customer->lastname = 'pouet'; + $this->assertTrue($customer->save()); + + $customer = $api->getCustomerOrNew(static::$info->hashcode); + $this->assertEquals('pouet', $customer->lastname); + $customer->country = Country::angola(); $customer->save(); $customer = $api->getCustomerOrNew(static::$info->hashcode); $this->assertEquals(Country::angola(), $customer->country); + + $customer->email = 'pouet@gmail.com'; + $customer->birth_date = '1992-03-08'; + $customer->phone = '0388977213'; + $customer->address = '30 rue des toto'; + $customer->address2 = 'batiment c'; + $customer->city = 'toto ville'; + $customer->postcode = '83160'; + $this->assertTrue($customer->save()); + + $customer = $api->getCustomerOrNew(static::$info->hashcode); + $this->assertEquals('pouet@gmail.com', $customer->email); + $this->assertEquals('1992-03-08', $customer->birth_date); + $this->assertEquals('0388977213', $customer->phone); + $this->assertEquals('30 rue des toto', $customer->address); + $this->assertEquals('batiment c', $customer->address2); + $this->assertEquals('toto ville', $customer->city); + $this->assertEquals('83160', $customer->postcode); } + + public function testCustomerToggleOptin() + { + $api = new CrmApiV2(); + $customer = $api->getCustomerOrNew(static::$info->hashcode); + + $customer->opt_in = false; + $this->assertTrue($customer->save()); + + $this->assertTrue($customer->toggleOptin()); + $this->assertTrue($customer->opt_in); + + $this->assertTrue($customer->toggleOptin()); + $this->assertFalse($customer->opt_in); + + $this->assertTrue($customer->toggleOptin()); + $this->assertTrue($customer->opt_in); + } + + // public function testCustomerStoreProps() + // { + // $api = new CrmApiV2(); + // $customer = $api->getCustomerOrNew(static::$info->hashcode); + + // $customer->firstname = 'toto'; + // $this->assertTrue($customer->save()); + + // $customer = $api->getCustomerOrNew(static::$info->hashcode); + // $this->assertEquals('toto', $customer->firstname); + + // $customer->country = Country::angola(); + // $customer->save(); + + // $customer = $api->getCustomerOrNew(static::$info->hashcode); + // $this->assertEquals(Country::angola(), $customer->country); + // } }