ldc-crm/tests/Unit/CrmClientV2CustomerTest.php
Jérémy Munsch 3619593485 Mise à plat CRM v2
- 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
2021-08-04 13:01:33 +02:00

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;
}
}
}