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