From 43bf54bf137e9acbd7e1022701d359d77988e8fa Mon Sep 17 00:00:00 2001 From: 4Giedrius <4giedrius@gmail.com> Date: Thu, 6 Nov 2014 11:44:02 +0200 Subject: [PATCH] Integration tests for sign up form custom inut fields added --- .../bb-modules/mod_client/Api_GuestTest.php | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/tests/integration/bb-modules/mod_client/Api_GuestTest.php b/tests/integration/bb-modules/mod_client/Api_GuestTest.php index ae047346d..386924f36 100644 --- a/tests/integration/bb-modules/mod_client/Api_GuestTest.php +++ b/tests/integration/bb-modules/mod_client/Api_GuestTest.php @@ -8,6 +8,11 @@ class Api_Guest_ClientTest extends BBDbApiTestCase public function testCreate() { + $this->api_admin->extension_config_save(array( + 'ext' => 'mod_client', + 'required' => array(), + )); + $e = rand(5, 56666).'@gmail.com'; $pass = 'testA1sssss'; @@ -103,4 +108,87 @@ class Api_Guest_ClientTest extends BBDbApiTestCase $array = $this->api_guest->client_required(); $this->assertInternalType('array', $array); } + + public function testCreateWithCustom() + { + $this->api_admin->extension_config_save(array( + 'ext' => 'mod_client', + 'required' => array( + 'last_name' + ), + 'custom_fields' => array( + 'custom_5' => array( + 'active' => true, + 'required' => true, + 'title' => 'Your username' + ) + ) + )); + + + $e = rand(5, 56666) . '@gmail.com'; + $pass = 'testA1sssss'; + + $data = array( + 'aid' => '2', + 'email' => $e, + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => 'Palo Alto', + 'country' => 'USA', + 'company_vat' => 'LS-2qwddwqdsd12', + 'city' => 'California', + 'tel_cc' => '211', + 'phone' => '11212156485451', + 'password' => $pass, + 'password_confirm' => $pass, + 'custom_5' => 'JohnUsername' + + ); + $id = $this->api_guest->client_create($data); + $this->assertInternalType('int', $id); + $client = $this->di['db']->load('Client', $id); + + $this->assertEquals($data['custom_5'], $client->custom_5); + } + + /** + * @expectedException \Box_Exception + */ + public function testCreateWithCustomRequiredException() + { + $this->api_admin->extension_config_save(array( + 'ext' => 'mod_client', + 'required' => array( + 'last_name' + ), + 'custom_fields' => array( + 'custom_5' => array( + 'active' => true, + 'required' => true, + 'title' => 'Your username' + ) + ) + )); + + $e = rand(5, 56666) . '@gmail.com'; + $pass = 'testA1sssss'; + + $data = array( + 'aid' => '2', + 'email' => $e, + 'first_name' => 'John', + 'last_name' => 'Doe', + 'address_1' => 'Palo Alto', + 'country' => 'USA', + 'company_vat' => 'LS-2qwddwqdsd12', + 'city' => 'California', + 'tel_cc' => '211', + 'phone' => '11212156485451', + 'password' => $pass, + 'password_confirm' => $pass, + + ); + $id = $this->api_guest->client_create($data); + } } \ No newline at end of file