getCustomerOrNew(static::$info->hashcode); $arcadiaOrderMail = new ArcadiaMailDefault([ 'email' => static::$customer->email, 'firstname' => static::$info->firstname, 'lastname' => static::$info->lastname, 'phone' => static::$info->phone, 'address' => static::$info->address, 'address2' => static::$info->address2, 'city' => static::$info->city, 'postcode' => static::$info->postcode, 'operation' => 16, 'label_type_support' => 'Send Departaimants', 'order_date' => \date('Y/m/d H:i:s'), 'state_order' => ArcadiaOrderType::cb()->value, 'support_code' => 1, 'label_type_support' => 'Fond carte Aimanté', 'order_num' => 23, 'package_unit_weight' => 0, ]); $this->assertTrue($arcadiaOrderMail->send($customer)); } /** * Test arcadia default mail can serialize to json * * @return void */ public function testArcadiaOrderDefaultJson() { $data = [ 'email' => static::$customer->email, 'firstname' => static::$info->firstname, 'lastname' => static::$info->lastname, 'phone' => static::$info->phone, 'address' => static::$info->address, 'address2' => static::$info->address2, 'city' => static::$info->city, 'postcode' => static::$info->postcode, 'operation' => 16, 'label_type_support' => 'Send Departaimants', 'order_date' => \date('Y/m/d H:i:s'), 'state_order' => ArcadiaOrderType::cb()->value, 'support_code' => 1, 'label_type_support' => 'Fond carte Aimanté', 'order_num' => 23, 'package_unit_weight' => 0, ]; $arcadiaOrderMail = new ArcadiaMailDefault($data); /** Mutator and accessor tests */ foreach ($data as $propName => $value) { $arcadiaOrderMail->{$propName} = $value; $arcadiaOrderMail->{$propName} = $arcadiaOrderMail->{$propName}; } $jsonDecoded = \json_decode(\json_encode($arcadiaOrderMail), true); $this->assertIsArray($jsonDecoded); foreach ($data as $key => $value) { if (isset($jsonDecoded['deliver'][$key])) { $this->assertArrayHasKey($key, $jsonDecoded['deliver']); $this->assertEquals($value, $jsonDecoded['deliver'][$key]); } else { $this->assertArrayHasKey($key, $jsonDecoded); $this->assertEquals($value, $jsonDecoded[$key]); } } } /** * Send arcadia order default game. * * @return void */ public function testArcadiaSendOrderGame() { $api = new CrmApiV2(); $customer = $api->getCustomerOrNew(static::$info->hashcode); $arcadiaOrderMail = new ArcadiaMailGame([ 'email' => static::$customer->email, 'firstname' => static::$info->firstname, 'lastname' => static::$info->lastname, 'phone' => static::$info->phone, 'address' => static::$info->address, 'address2' => static::$info->address2, 'city' => static::$info->city, 'postcode' => static::$info->postcode, 'operation' => 16, 'order_date' => date('Y/m/d H:i:s'), 'support_code' => 32, 'label_type_support' => 'Jeux Reghalal', 'code_unique' => \strtoupper(\str_replace('-', '', (string)Str::uuid())), 'code_on_pack' => '12365214587562' ]); $this->assertTrue($arcadiaOrderMail->send($customer)); } /** * Send arcadia order default game (empty string does not convert to null). * * @return void */ public function testArcadiaSendOrderGameNullString() { $api = new CrmApiV2(); $customer = $api->getCustomerOrNew(static::$info->hashcode); $arcadiaOrderMail = new ArcadiaMailGame([ 'email' => 'toto@gmail.com', 'firstname' => 'Jean', 'lastname' => 'Pouet', 'phone' => '0678142536', 'address' => '30 rue des totots', 'address2' => null, 'city' => 'Le Mans', 'postcode' => '72000', 'operation' => 12, 'order_date' => '2022/03/17 11:24:55', 'support_code' => 16, 'label_type_support' => 'Gain du lot : Lot ', 'code_unique' => '11N311A1', 'code_on_pack' => '12345678' ]); $this->assertTrue($arcadiaOrderMail->send($customer)); } /** * Test arcadia game mail can serialize to json * * @return void */ public function testArcadiaOrderGameJson() { $data = [ 'email' => static::$customer->email, 'firstname' => static::$info->firstname, 'lastname' => static::$info->lastname, 'phone' => static::$info->phone, 'address' => static::$info->address, 'address2' => static::$info->address2, 'city' => static::$info->city, 'postcode' => static::$info->postcode, 'operation' => 16, 'order_date' => date('Y/m/d H:i:s'), 'support_code' => 32, 'label_type_support' => 'Jeux Reghalal', 'code_unique' => \strtoupper(\str_replace('-', '', (string)Str::uuid())), 'code_on_pack' => '12365214587562' ]; $arcadiaGameMail = new ArcadiaMailGame($data); /** Mutator and accessor tests */ foreach ($data as $propName => $value) { $arcadiaGameMail->{$propName} = $value; $arcadiaGameMail->{$propName} = $arcadiaGameMail->{$propName}; } $jsonDecoded = \json_decode(\json_encode($arcadiaGameMail), true); $this->assertIsArray($jsonDecoded); foreach ($data as $key => $value) { if (isset($jsonDecoded['deliver'][$key])) { $this->assertArrayHasKey($key, $jsonDecoded['deliver']); $this->assertEquals($value, $jsonDecoded['deliver'][$key]); } else { $this->assertArrayHasKey($key, $jsonDecoded); $this->assertEquals($value, $jsonDecoded[$key]); } } } }