ldc-crm/tests/Unit/CrmClientV2SingleOptinTest.php
Jérémy Munsch 260d5fd259 - Arcadia separate routes on v2
- fix optin v2
- customer validation password
- full working v2 tests
2021-08-06 15:57:48 +02:00

39 lines
1.3 KiB
PHP

<?php
namespace Tests\Unit;
use LDC\LDCCRM\Enums\ApiError;
use LDC\LDCCRM\Enums\Country;
use LDC\LDCCRM\Exceptions\ApiErrorException;
use LDC\LDCCRM\Models\Customer;
use LDC\LDCCRM\Models\SingleOptin;
class CrmClientV2SingleOptinTest extends CrmClientTester
{
public function testCreateSingleOptin()
{
$this->assertTrue(SingleOptin::setStatus(static::$customer->email, true));
}
public function testCreateSingleOptinShouldFailBecauseCustomerExists()
{
$this->expectException(ApiErrorException::class);
$this->expectExceptionMessage(ApiError::singleOptinCustomerExists()->label);
$customer = new Customer();
$customer->firstname = 'toto singleoptin';
$customer->lastname = 'delarogerie';
$customer->email = 'totosingleoptin.delarogerie@gmail.com';
$customer->password = 'Complic4tEd!P4assW0rd';
$customer->birth_date = '1992-03-08';
$customer->phone = '0673891160';
$customer->address = 'rue des totos';
$customer->city = 'Toto ville';
$customer->postcode = '72160';
$customer->country = Country::france();
$this->assertTrue($customer->save());
$this->assertFalse(SingleOptin::setStatus($customer->email, true));
}
}