ldc-crm/tests/Unit/CrmClientV2CustomerTest.php

98 lines
2.5 KiB
PHP
Raw Normal View History

<?php
namespace Tests\Unit;
use Illuminate\Support\Str;
use LDC\LDCCRM\Enums\Country;
use LDC\LDCCRM\Models\Customer;
use TypeError;
class CrmClientV2CustomerTest extends CrmClientTester
{
public function testGetter()
{
$this->expectNotToPerformAssertions();
$client = new Customer();
$client->email;
}
public function testSetter()
{
$this->expectNotToPerformAssertions();
$client = new Customer();
$client->firstname = 'toto';
$client->firstname;
}
public function testSetterFailWrongType()
{
$this->expectException(TypeError::class);
$client = new Customer();
$client->optin = 'toto';
}
public function testSetterFailWrongTypeCountry()
{
$this->expectException(TypeError::class);
$client = new Customer();
$client->country = 'toto';
}
public function testPropsAllSetOk()
{
$this->expectNotToPerformAssertions();
$client = new Customer();
$propTypes = [
'hashcode' => (string)Str::uuid(),
'email' => 'toto@gmail.com',
'firstname' => 'string',
'lastname' => 'string',
'password' => 'StrongPassword!7',
'birthdate' => '1992-02-03',
'phone' => '0673891630',
'address' => 'string',
'address2' => 'string',
'city' => 'string',
'postcode' => 'string',
'country' => Country::afghanistan(),
'optin' => true,
'status' => true,
];
foreach ($propTypes as $prop => $type) {
$client->{$prop} = $type;
}
}
public function testPropsAllSetNotOk()
{
$this->expectException(TypeError::class);
$client = new Customer();
$propTypes = [
'hashcode' => (string)Str::uuid(),
'email' => 'toto@gmail.com',
'firstname' => 'string',
'lastname' => 'string',
'password' => 'StrongPassword!7',
'birthdate' => '1992-02-03',
'phone' => '0673891630',
'address' => 'string',
'address2' => 'string',
'city' => 'string',
'postcode' => 'string',
'country' => Country::afghanistan()->value,
'optin' => true,
'status' => true,
];
foreach ($propTypes as $prop => $type) {
$client->{$prop} = $type;
}
}
}