Compare commits
5 commits
master
...
client7.3-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4be706fdd0 | ||
|
|
d65d1015c8 | ||
|
|
85228f1bb6 | ||
|
|
1b9acc61ca | ||
|
|
dbb2354085 |
5 changed files with 15 additions and 641 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit b15e9bcb59f4680a736e34dabdb059682fc7b8bc
|
||||
Subproject commit d0287ff9c3c45797ad844c70d7bc1b827773d167
|
||||
|
|
@ -47,7 +47,8 @@
|
|||
},
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"composer/package-versions-deprecated": true
|
||||
"composer/package-versions-deprecated": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
|
|
|
|||
|
|
@ -1,530 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Client;
|
||||
|
||||
use App\Models\Customer as ModelsCustomer;
|
||||
use LDC\LDCCRM\Enums\Country;
|
||||
|
||||
class CrmClientV1CustomerTest extends CrmClientTester
|
||||
{
|
||||
/**
|
||||
* Get customer by ID
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetCustomerById()
|
||||
{
|
||||
$reponse = static::$apiV1->getCustomer(static::$customer->id);
|
||||
|
||||
$this->assertEquals($reponse->status, 'OK');
|
||||
$this->assertEquals($reponse->user->crm_id, static::$customer->id);
|
||||
$this->assertEquals($reponse->user->email, static::$customer->email);
|
||||
$this->assertEquals($reponse->user->firstname, static::$info->firstname);
|
||||
$this->assertEquals($reponse->user->lastname, static::$info->lastname);
|
||||
$this->assertEquals($reponse->user->birth_date, static::$info->birth_date);
|
||||
$this->assertEquals($reponse->user->address, static::$info->address);
|
||||
$this->assertEquals($reponse->user->address2, static::$info->address2);
|
||||
$this->assertEquals($reponse->user->phone, static::$info->phone);
|
||||
$this->assertEquals($reponse->user->country, static::$info->country->label);
|
||||
$this->assertEquals($reponse->user->city, static::$info->city);
|
||||
$this->assertEquals($reponse->user->opt_in, static::$info->opt_in);
|
||||
$this->assertEquals($reponse->user->hashcode, static::$info->hashcode);
|
||||
$this->assertEquals($reponse->user->status, static::$login->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer by id should fail if not found
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetCustomerByIdShouldFail()
|
||||
{
|
||||
$reponse = static::$apiV1->getCustomer(9999999);
|
||||
|
||||
$this->assertEquals($reponse->status, 'KO');
|
||||
$this->assertEquals($reponse->code, 101);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer by email.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetCustomerByEmail()
|
||||
{
|
||||
$reponse = static::$apiV1->getCustomerByEmail(static::$customer->email);
|
||||
|
||||
$this->assertEquals($reponse->status, 'OK');
|
||||
$this->assertEquals($reponse->user->crm_id, static::$customer->id);
|
||||
$this->assertEquals($reponse->user->email, static::$customer->email);
|
||||
$this->assertEquals($reponse->user->firstname, static::$info->firstname);
|
||||
$this->assertEquals($reponse->user->lastname, static::$info->lastname);
|
||||
$this->assertEquals($reponse->user->birth_date, static::$info->birth_date);
|
||||
$this->assertEquals($reponse->user->address, static::$info->address);
|
||||
$this->assertEquals($reponse->user->address2, static::$info->address2);
|
||||
$this->assertEquals($reponse->user->phone, static::$info->phone);
|
||||
$this->assertEquals($reponse->user->country, static::$info->country->label);
|
||||
$this->assertEquals($reponse->user->city, static::$info->city);
|
||||
$this->assertEquals($reponse->user->opt_in, static::$info->opt_in);
|
||||
$this->assertEquals($reponse->user->hashcode, static::$info->hashcode);
|
||||
$this->assertEquals($reponse->user->status, static::$login->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer by email should fail if not found.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetCustomerByEmailShouldFail()
|
||||
{
|
||||
$reponse = static::$apiV1->getCustomer('totoo@toto.fr');
|
||||
|
||||
$this->assertEquals($reponse->status, 'KO');
|
||||
$this->assertEquals($reponse->code, 101);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create customer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerStoreProps()
|
||||
{
|
||||
$reponse = static::$apiV1->createCustomer(
|
||||
'v1toto.delarogerie@gmail.com',
|
||||
'Complic4tEd!P4assW0rd',
|
||||
'toto',
|
||||
'delarogerie',
|
||||
true,
|
||||
'1992-03-08',
|
||||
'0673891160',
|
||||
'rue des totos',
|
||||
'',
|
||||
'Toto ville',
|
||||
'72160',
|
||||
Country::france()->label
|
||||
);
|
||||
|
||||
$this->assertEquals($reponse->status, 'OK');
|
||||
$this->assertNotEmpty($reponse->user->crm_id);
|
||||
$this->assertNotEmpty($reponse->user->hashcode);
|
||||
$this->assertEquals($reponse->user->email, 'v1toto.delarogerie@gmail.com');
|
||||
$this->assertEquals($reponse->user->firstname, 'Toto');
|
||||
$this->assertEquals($reponse->user->lastname, 'Delarogerie');
|
||||
$this->assertEquals($reponse->user->birth_date, '1992-03-08');
|
||||
$this->assertEquals($reponse->user->address, 'rue des totos');
|
||||
$this->assertEquals($reponse->user->address2, '');
|
||||
$this->assertEquals($reponse->user->phone, '0673891160');
|
||||
$this->assertEquals($reponse->user->country, Country::france()->label);
|
||||
$this->assertEquals($reponse->user->city, 'Toto ville');
|
||||
$this->assertEquals($reponse->user->opt_in, true);
|
||||
$this->assertEquals($reponse->user->status, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create customer should fail if exists.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerStorePropsShouldFailBecauseAlreadyExist()
|
||||
{
|
||||
$reponse = static::$apiV1->createCustomer(
|
||||
'v1toto.delarogerie@gmail.com',
|
||||
'Complic4tEd!P4assW0rd',
|
||||
'toto',
|
||||
'delarogerie',
|
||||
true,
|
||||
'1992-03-08',
|
||||
'0673891160',
|
||||
'rue des totos',
|
||||
'',
|
||||
'Toto ville',
|
||||
'72160',
|
||||
Country::france()->label
|
||||
);
|
||||
|
||||
$this->assertEquals($reponse->status, 'KO');
|
||||
$this->assertEquals($reponse->code, 103);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should fail if invalid data is passed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerStorePropsShouldFail()
|
||||
{
|
||||
$reponse = static::$apiV1->createCustomer(
|
||||
'v1bistoto.delarogerie@gmail.com',
|
||||
'123456',
|
||||
'toto bis',
|
||||
'delarogerie',
|
||||
true,
|
||||
'1992-08',
|
||||
'0673891160',
|
||||
'rue des totos',
|
||||
'',
|
||||
'Toto ville',
|
||||
'72160',
|
||||
Country::france()->label
|
||||
);
|
||||
|
||||
$this->assertEquals($reponse->status, 'KO');
|
||||
$this->assertEquals($reponse->code, 102);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer update
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerUpdateProps()
|
||||
{
|
||||
$reponse = static::$apiV1->updateCustomer(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')->firstOrFail()->id,
|
||||
'toto new',
|
||||
'delarogerie',
|
||||
true,
|
||||
'1992-03-08',
|
||||
'0673891160',
|
||||
'rue des totos',
|
||||
'',
|
||||
'Toto ville',
|
||||
'72160',
|
||||
Country::france()->label
|
||||
);
|
||||
|
||||
$this->assertEquals($reponse->status, 'OK');
|
||||
$this->assertNotEmpty($reponse->user->crm_id);
|
||||
$this->assertNotEmpty($reponse->user->hashcode);
|
||||
$this->assertEquals($reponse->user->email, 'v1toto.delarogerie@gmail.com');
|
||||
$this->assertEquals($reponse->user->firstname, 'toto new');
|
||||
$this->assertEquals($reponse->user->lastname, 'delarogerie');
|
||||
$this->assertEquals($reponse->user->birth_date, '1992-03-08');
|
||||
$this->assertEquals($reponse->user->address, 'rue des totos');
|
||||
$this->assertEquals($reponse->user->address2, '');
|
||||
$this->assertEquals($reponse->user->phone, '0673891160');
|
||||
$this->assertEquals($reponse->user->country, Country::france()->label);
|
||||
$this->assertEquals($reponse->user->city, 'Toto ville');
|
||||
$this->assertEquals($reponse->user->opt_in, true);
|
||||
$this->assertEquals($reponse->user->status, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer update should fail if dont exists.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerLoginShouldFailDontExists()
|
||||
{
|
||||
$reponse = static::$apiV1->loginCustomer('v1totso.delarogerie@gmail.com', 'Complic4tEd!P4assW0rd');
|
||||
|
||||
$this->assertEquals('KO', $reponse->status);
|
||||
$this->assertEquals(119, $reponse->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer update should fail if account is not activated.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerLoginShouldFailNotActivated()
|
||||
{
|
||||
$reponse = static::$apiV1->loginCustomer('v1toto.delarogerie@gmail.com', 'Complic4tEd!P4assW0rd');
|
||||
|
||||
$this->assertEquals('KO', $reponse->status);
|
||||
$this->assertEquals(116, $reponse->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer activate
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerActivate()
|
||||
{
|
||||
$reponse = static::$apiV1->activateCustomer(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')->firstOrFail()->id
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer login
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerLogin()
|
||||
{
|
||||
$reponse = static::$apiV1->loginCustomer('v1toto.delarogerie@gmail.com', 'Complic4tEd!P4assW0rd');
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer activation should fail if already exists.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerActivateShouldFail()
|
||||
{
|
||||
$reponse = static::$apiV1->activateCustomer(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')->firstOrFail()->id
|
||||
);
|
||||
|
||||
$this->assertEquals('KO', $reponse->status);
|
||||
$this->assertEquals(110, $reponse->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer toggle optin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerToggleOptin()
|
||||
{
|
||||
$reponse = static::$apiV1->toggleOptInCustomer(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')->firstOrFail()->id
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
$reponse = static::$apiV1->toggleOptInCustomer(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')->firstOrFail()->id
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
$reponse = static::$apiV1->toggleOptInCustomer(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')->firstOrFail()->id
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer remove optin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerRemoveOptin()
|
||||
{
|
||||
$hashcode = static::$apiV1->getCustomerByEmail('v1toto.delarogerie@gmail.com')->user->hashcode;
|
||||
$reponse = static::$apiV1->removeOptInCustomer($hashcode);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerDelete()
|
||||
{
|
||||
$reponse = static::$apiV1->deleteCustomer(ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')
|
||||
->firstOrFail()->id);
|
||||
|
||||
$this->assertNull($reponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create single optin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateSingleOptin()
|
||||
{
|
||||
$reponse = static::$apiV1->createSingleOptin('singlev1toto.delarogerie@gmail.com');
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create single optin already exists.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateSingleOptinShouldFail()
|
||||
{
|
||||
$reponse = static::$apiV1->createSingleOptin('singlev1toto.delarogerie@gmail.com');
|
||||
|
||||
$this->assertEquals('KO', $reponse->status);
|
||||
$this->assertEquals(121, $reponse->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send arcadia outgoing mail.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateArcadiaOutgoingMail()
|
||||
{
|
||||
$reponse = static::$apiV1->ArcadiaOutgoingMail(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')
|
||||
->firstOrFail()->id,
|
||||
[
|
||||
'root' => [
|
||||
[
|
||||
'fieldName' => 'order_num',
|
||||
// Format 9 numeric characters.
|
||||
'fieldValue' => str_pad(12, 9, '0', \STR_PAD_LEFT),
|
||||
],
|
||||
[
|
||||
'fieldName' => 'order_date',
|
||||
// Format : DD/MM/YYYY .
|
||||
'fieldValue' => '12/05/1992',
|
||||
],
|
||||
[
|
||||
'fieldName' => 'state_order_cb',
|
||||
// Format 1 ou Null (oui Null et pas NULL).
|
||||
'fieldValue' => 1,
|
||||
],
|
||||
[
|
||||
'fieldName' => 'state_order_check',
|
||||
// Format 1 ou Null (oui Null et pas NULL).
|
||||
'fieldValue' => 'Null'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'operation',
|
||||
// Mettre valeur dans .env .
|
||||
'fieldValue' => 16
|
||||
]
|
||||
],
|
||||
'orderLine' => [
|
||||
[
|
||||
'fieldName' => 'package_unit_weight',
|
||||
'fieldValue' => 200
|
||||
],
|
||||
[
|
||||
'fieldName' => 'qty',
|
||||
// Forced to 1 faire un appel par produit et pour chaque quantité.
|
||||
'fieldValue' => '1'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'support_code',
|
||||
'fieldValue' => 2
|
||||
],
|
||||
[
|
||||
'fieldName' => 'label_type_support',
|
||||
'fieldValue' => 'label supoport'
|
||||
]
|
||||
]
|
||||
],
|
||||
'default',
|
||||
[
|
||||
"firstname" => 'toto',
|
||||
"lastname" => 'delarogerie',
|
||||
"address" => 'rue des toto',
|
||||
"city" => 'toto ville',
|
||||
"postcode" => '72000',
|
||||
"phone" => '0673891160'
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send arcadia outgoing mail game.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateArcadiaOutgoingMailGameWithEan()
|
||||
{
|
||||
$reponse = static::$apiV1->ArcadiaOutgoingMail(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')
|
||||
->firstOrFail()->id,
|
||||
[
|
||||
'root' => [
|
||||
[
|
||||
'fieldName' => 'order_date',
|
||||
'fieldValue' => date('d/m/Y')
|
||||
],
|
||||
[
|
||||
'fieldName' => 'operation',
|
||||
'fieldValue' => '32'
|
||||
]
|
||||
],
|
||||
'orderLine' => [
|
||||
[
|
||||
'fieldName' => 'code_unique',
|
||||
'fieldValue' => '2A5B416325414232'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'code_on_pack',
|
||||
'fieldValue' => '2541632541423'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'support_code',
|
||||
'fieldValue' => '16'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'label_type_support',
|
||||
'fieldValue' => 'Gain du lot : ballon de foot en métal type "fracture"'
|
||||
]
|
||||
]
|
||||
],
|
||||
'game',
|
||||
[
|
||||
"firstname" => 'toto',
|
||||
"lastname" => 'delarogerie',
|
||||
"address" => 'rue des toto',
|
||||
"city" => 'toto ville',
|
||||
"postcode" => '72000',
|
||||
"phone" => '0673891160'
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send arcadia mail without ean.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateArcadiaOutgoingMailGameWithoutEan()
|
||||
{
|
||||
$reponse = static::$apiV1->ArcadiaOutgoingMail(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')
|
||||
->firstOrFail()->id,
|
||||
[
|
||||
'root' => [
|
||||
[
|
||||
'fieldName' => 'order_date',
|
||||
'fieldValue' => date('d/m/Y')
|
||||
],
|
||||
[
|
||||
'fieldName' => 'operation',
|
||||
'fieldValue' => '32'
|
||||
]
|
||||
],
|
||||
'orderLine' => [
|
||||
[
|
||||
'fieldName' => 'code_unique',
|
||||
'fieldValue' => '25416325414232'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'support_code',
|
||||
'fieldValue' => '16'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'label_type_support',
|
||||
'fieldValue' => 'Gain du lot : ballon de foot en métal type "fracture"'
|
||||
]
|
||||
]
|
||||
],
|
||||
'game',
|
||||
[
|
||||
"firstname" => 'toto',
|
||||
"lastname" => 'delarogerie',
|
||||
"address" => 'rue des toto',
|
||||
"city" => 'toto ville',
|
||||
"postcode" => '72000',
|
||||
"phone" => '0673891160'
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Tests\Client;
|
||||
|
||||
use DOMDocument;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
use LDC\LDCCRM\CrmApiV2;
|
||||
use LDC\LDCCRM\Enums\ArcadiaOrderType;
|
||||
|
|
@ -190,105 +188,4 @@ class CrmClientV2ArcadiaTest extends CrmClientTester
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Valdate xml generated files default.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testValidateGeneratedXmlDefault()
|
||||
{
|
||||
$fileFound = false;
|
||||
|
||||
$files = File::allFiles(\storage_path('export/arcadia'));
|
||||
|
||||
/** @var \Symfony\Component\Finder\SplFileInfo $file */
|
||||
foreach ($files as $file) {
|
||||
if (\strpos($file->getFilename(), 'v2-order-000000023-default-') === 0) {
|
||||
$fileFound = true;
|
||||
|
||||
// Enable user error handling.
|
||||
\libxml_use_internal_errors(true);
|
||||
|
||||
$xml = new DOMDocument();
|
||||
$xml->load($file->getRealPath());
|
||||
|
||||
$this->assertTrue($xml->schemaValidate(\resource_path('documents/arcadia_default.xsd')));
|
||||
$this->libxmlDisplayErrors();
|
||||
}
|
||||
}
|
||||
$this->assertTrue($fileFound, 'Should have found a xml file to validate and pass validation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Valdate xml generated files game.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testValidateGeneratedXmlGame()
|
||||
{
|
||||
$fileFound = false;
|
||||
|
||||
$files = File::allFiles(\storage_path('export/arcadia'));
|
||||
|
||||
/** @var \Symfony\Component\Finder\SplFileInfo $file */
|
||||
foreach ($files as $file) {
|
||||
if (\strpos($file->getFilename(), 'v2-order-000000000-game') === 0) {
|
||||
$fileFound = true;
|
||||
|
||||
// Enable user error handling.
|
||||
\libxml_use_internal_errors(true);
|
||||
|
||||
$xml = new DOMDocument();
|
||||
$xml->load($file->getRealPath());
|
||||
|
||||
$this->assertTrue($xml->schemaValidate(\resource_path('documents/arcadia_game.xsd')));
|
||||
$this->libxmlDisplayErrors();
|
||||
}
|
||||
}
|
||||
$this->assertTrue($fileFound, 'Should have found a xml file to validate and pass validation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a \LibXMLError
|
||||
*
|
||||
* @param \LibXMLError $error
|
||||
* @return string
|
||||
*/
|
||||
private function libxmlDisplayError(\LibXMLError $error): string
|
||||
{
|
||||
$return = "<br/>\n";
|
||||
switch ($error->level) {
|
||||
case LIBXML_ERR_WARNING:
|
||||
$return .= "<b>Warning $error->code</b>: ";
|
||||
break;
|
||||
case LIBXML_ERR_ERROR:
|
||||
$return .= "<b>Error $error->code</b>: ";
|
||||
break;
|
||||
case LIBXML_ERR_FATAL:
|
||||
$return .= "<b>Fatal Error $error->code</b>: ";
|
||||
break;
|
||||
}
|
||||
$return .= trim($error->message);
|
||||
if ($error->file) {
|
||||
$return .= " in <b>$error->file</b>";
|
||||
}
|
||||
$return .= " on line <b>$error->line</b>\n";
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display xml errors.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function libxmlDisplayErrors()
|
||||
{
|
||||
$errors = libxml_get_errors();
|
||||
foreach ($errors as $error) {
|
||||
print $this->libxmlDisplayError($error);
|
||||
}
|
||||
libxml_clear_errors();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -310,6 +310,12 @@ class CrmClientV2CustomerTest extends CrmClientTester
|
|||
$customer = $api->getCustomerOrNew(static::$info->hashcode);
|
||||
$this->assertEquals(Country::belgium(), $customer->country);
|
||||
|
||||
$customer->country = Country::france();
|
||||
$customer->save();
|
||||
|
||||
$customer = $api->getCustomerOrNew(static::$info->hashcode);
|
||||
$this->assertEquals(Country::france(), $customer->country);
|
||||
|
||||
$customer->email = 'pouet@gmail.com';
|
||||
$customer->birth_date = '1992-03-08';
|
||||
$customer->phone = '0388977213';
|
||||
|
|
@ -499,18 +505,18 @@ class CrmClientV2CustomerTest extends CrmClientTester
|
|||
private function createNewCustomer(array $data, Brand $brand)
|
||||
{
|
||||
$customer = \App\Models\Customer::whereEmail($data['email'])
|
||||
->whereHas('brands', function ($q) use ($brand) {
|
||||
$q->where('brands.id', '=', $brand->id);
|
||||
})->firstOrNew();
|
||||
->whereHas('brands', function ($q) use ($brand) {
|
||||
$q->where('brands.id', '=', $brand->id);
|
||||
})->firstOrNew();
|
||||
$customer->fill($data);
|
||||
$saved = $customer->save();
|
||||
|
||||
// * Delete Single optin if exists.
|
||||
/** @var \App\Models\SingleOptin|null $singleOptin */
|
||||
$singleOptin = SingleOptin::query()->where('email', $data['email'])
|
||||
->whereHas('brand', function ($q) use ($brand) {
|
||||
$q->where('brands.id', '=', $brand->id);
|
||||
})->first();
|
||||
->whereHas('brand', function ($q) use ($brand) {
|
||||
$q->where('brands.id', '=', $brand->id);
|
||||
})->first();
|
||||
if ($singleOptin) {
|
||||
$saved = $singleOptin->delete() && $saved;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue