- ajout une colonne new country pour enum - fix des test v2 - fix du handler - fix des middleware - fix du timestamp checker - fix des stats fix du api handler - ajout du middleware json only - remove crm-id du client en faveur du hashcode seulement - fix du route service provider - déplacement de la route arcradia en dehors du customer
97 lines
2.5 KiB
PHP
97 lines
2.5 KiB
PHP
<?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;
|
|
}
|
|
}
|
|
}
|