From 5ade18a3736923a046fb1d98b018d29056534523 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 13 May 2017 11:21:41 +0200 Subject: [PATCH] [phpunit] user/create/params tests --- build/error/core/Error.php | 5 + phpunit/phpunit.xml | 4 +- .../{create.php => create/errors/already.php} | 10 +- phpunit/tests/user/create/param/code.php | 108 +++++ phpunit/tests/user/create/param/firstname.php | 153 +++++++ phpunit/tests/user/create/param/lastname.php | 153 +++++++ phpunit/tests/user/create/param/mail.php | 398 ++++++++++++++++++ phpunit/tests/user/create/param/username.php | 160 +++++++ 8 files changed, 985 insertions(+), 6 deletions(-) rename phpunit/tests/user/{create.php => create/errors/already.php} (96%) create mode 100644 phpunit/tests/user/create/param/code.php create mode 100644 phpunit/tests/user/create/param/firstname.php create mode 100644 phpunit/tests/user/create/param/lastname.php create mode 100644 phpunit/tests/user/create/param/mail.php create mode 100644 phpunit/tests/user/create/param/username.php diff --git a/build/error/core/Error.php b/build/error/core/Error.php index 7092ada..aee53d5 100644 --- a/build/error/core/Error.php +++ b/build/error/core/Error.php @@ -187,6 +187,11 @@ } + public function args(){ + return $this->arguments; + } + + public function setHttpCode(){ http_response_code( $this->error == Err::Success ? 200 : 417 ); } diff --git a/phpunit/phpunit.xml b/phpunit/phpunit.xml index 7edda87..a046a7e 100755 --- a/phpunit/phpunit.xml +++ b/phpunit/phpunit.xml @@ -2,8 +2,8 @@ - - ./tests/user/create.php + + tests/user/create/ diff --git a/phpunit/tests/user/create.php b/phpunit/tests/user/create/errors/already.php similarity index 96% rename from phpunit/tests/user/create.php rename to phpunit/tests/user/create/errors/already.php index 4a12274..37d695a 100644 --- a/phpunit/tests/user/create.php +++ b/phpunit/tests/user/create/errors/already.php @@ -1,17 +1,17 @@ select('id_warehouse') + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $adminReq[0]['token']; + + $warehouseReq = Table::get('warehouse') + ->whereId($adminReq[0]['id_warehouse']) + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $warehouseReq[0]['token'].$_SERVER['PHP_AUTH_DIGEST']; + + } + + /* API manifest + * + * FIELD TYPE + * --------- ------- + * code rfid + * username varchar(1,30,alphanumeric) + * firstname varchar(3,30,letters) + * lastname varchar(3,30,letters) + * mail mail + * + * Note: letters is alphanumeric + ' ' + * + */ + + + + public function testParamCode(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '09-AB-CD-EF', + 'username' => '', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'username'); + + } + + + + public function testParamCodeAlternative(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10-10-10', + 'username' => '', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'username'); + + } + + public function testParamCodeCharsetError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-1G', + 'username' => '', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'code'); + + } + + } + +?> \ No newline at end of file diff --git a/phpunit/tests/user/create/param/firstname.php b/phpunit/tests/user/create/param/firstname.php new file mode 100644 index 0000000..4863bcb --- /dev/null +++ b/phpunit/tests/user/create/param/firstname.php @@ -0,0 +1,153 @@ +select('id_warehouse') + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $adminReq[0]['token']; + + $warehouseReq = Table::get('warehouse') + ->whereId($adminReq[0]['id_warehouse']) + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $warehouseReq[0]['token'].$_SERVER['PHP_AUTH_DIGEST']; + + } + + /* API manifest + * + * FIELD TYPE + * --------- ------- + * code rfid + * username varchar(1,30,alphanumeric) + * firstname varchar(3,30,letters) + * lastname varchar(3,30,letters) + * mail mail + * + * Note: letters is alphanumeric + ' ' + * + */ + + + public function testParamFirstnameMin(){ + + $value = 'aaa'; + $this->assertEquals(strlen($value), 3); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => $value, + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'lastname'); + + } + + public function testParamFirstnameMinError(){ + + $value = 'aa'; + $this->assertLessThan(3, strlen($value)); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => $value, + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'firstname'); + + } + + public function testParamFirstnameMax(){ + + $value = '1.3-56789012345678901234567 ab'; + $this->assertEquals(strlen($value), 30); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => $value, + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'lastname'); + + } + + public function testParamFirstnameMaxError(){ + + $value = '1.3-56789012345678901234567 ab0'; + $this->assertGreaterThan(30, strlen($value)); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => $value, + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'firstname'); + + } + + public function testParamFirstnameCharsetError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => '1.3-5a*', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'firstname'); + + } + + } + +?> \ No newline at end of file diff --git a/phpunit/tests/user/create/param/lastname.php b/phpunit/tests/user/create/param/lastname.php new file mode 100644 index 0000000..e1c790f --- /dev/null +++ b/phpunit/tests/user/create/param/lastname.php @@ -0,0 +1,153 @@ +select('id_warehouse') + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $adminReq[0]['token']; + + $warehouseReq = Table::get('warehouse') + ->whereId($adminReq[0]['id_warehouse']) + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $warehouseReq[0]['token'].$_SERVER['PHP_AUTH_DIGEST']; + + } + + /* API manifest + * + * FIELD TYPE + * --------- ------- + * code rfid + * username varchar(1,30,alphanumeric) + * firstname varchar(3,30,letters) + * lastname varchar(3,30,letters) + * mail mail + * + * Note: letters is alphanumeric + ' ' + * + */ + + + public function testParamLastnameMin(){ + + $value = 'aaa'; + $this->assertEquals(strlen($value), 3); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => $value, + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + public function testParamLastnameMinError(){ + + $value = 'aa'; + $this->assertLessThan(3, strlen($value)); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => $value, + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'lastname'); + + } + + public function testParamLastnameMax(){ + + $value = '1.3-56789012345678901234567 ab'; + $this->assertEquals(strlen($value), 30); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => $value, + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + public function testParamLastnameMaxError(){ + + $value = '1.3-56789012345678901234567 ab0'; + $this->assertGreaterThan(30, strlen($value)); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => $value, + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'lastname'); + + } + + public function testParamLastnameCharsetError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => '1.3-5a*', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'lastname'); + + } + + } + +?> \ No newline at end of file diff --git a/phpunit/tests/user/create/param/mail.php b/phpunit/tests/user/create/param/mail.php new file mode 100644 index 0000000..c336537 --- /dev/null +++ b/phpunit/tests/user/create/param/mail.php @@ -0,0 +1,398 @@ +select('id_warehouse') + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $adminReq[0]['token']; + + $warehouseReq = Table::get('warehouse') + ->whereId($adminReq[0]['id_warehouse']) + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $warehouseReq[0]['token'].$_SERVER['PHP_AUTH_DIGEST']; + + } + + /* API manifest + * + * FIELD TYPE + * --------- ------- + * code rfid + * username varchar(1,30,alphanumeric) + * firstname varchar(3,30,letters) + * lastname varchar(3,30,letters) + * mail mail + * + * Note: letters is alphanumeric + ' ' + * + */ + + + public function testParamMail(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a.b-c@domain-c.d.com' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + + /*************** + **** Root **** + ****************/ + + + public function testParamMailRootMin(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@b.cd' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + public function testParamMailRootMinError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@b.c' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + public function testParamMailRootMax(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@b.cdef' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + public function testParamMailRootMaxError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@b.cdefg' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + public function testParamMailRootCharsetError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@b.c9d' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + + + /*************** + **** Domain **** + ****************/ + + + public function testParamMailDomain(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@b_c.d-e.f-g.h.com' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + + public function testParamMailDomainMin(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@b.com' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + public function testParamMailDomainMinError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@.com' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + + public function testParamMailDomainMax(){ + + $domain = '1234567890123456789012345678901234567890abcde'; + $mail = "a@{$domain}.fr"; + $this->assertEquals(strlen($mail), 50); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => $mail + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + public function testParamMailDomainMaxError(){ + + $domain = '1234567890123456789012345678901234567890abcdef'; + $mail = "a@{$domain}.fr"; + $this->assertGreaterThan(50, strlen($mail)); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => $mail + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + public function testParamMailDomainCharsetError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@b-c0*d.com' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + + + + /******************* + **** Identifier **** + ********************/ + + + public function testParamMailIdentifier(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'ab-cd.ef-09.xx_3-2@x.yz' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + + public function testParamMailIdentifierMin(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a@x.yz' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + public function testParamMailIdentifierMinError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => '@a.com' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + + public function testParamMailIdentifierMax(){ + + $identifier = '1234567890123456789012345678901234567890abcde'; + $mail = "{$identifier}@a.fr"; + $this->assertEquals(strlen($mail), 50); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => $mail + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::Success); + + } + + public function testParamMailIdentifierMaxError(){ + + $identifier = '1_3-5.7890123456789012345678901234567890abcdef'; + $mail = "{$identifier}@a.fr"; + $this->assertGreaterThan(50, strlen($mail)); + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => $mail + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + public function testParamMailIdentifierCharsetError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => 'aaa', + 'lastname' => 'aaa', + 'mail' => 'a_b-c0*d@x.yz' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'mail'); + + } + + } + +?> \ No newline at end of file diff --git a/phpunit/tests/user/create/param/username.php b/phpunit/tests/user/create/param/username.php new file mode 100644 index 0000000..aad9d52 --- /dev/null +++ b/phpunit/tests/user/create/param/username.php @@ -0,0 +1,160 @@ +select('id_warehouse') + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $adminReq[0]['token']; + + $warehouseReq = Table::get('warehouse') + ->whereId($adminReq[0]['id_warehouse']) + ->select('token') + ->fetch(); + + $_SERVER['PHP_AUTH_DIGEST'] = $warehouseReq[0]['token'].$_SERVER['PHP_AUTH_DIGEST']; + + } + + /* API manifest + * + * FIELD TYPE + * --------- ------- + * code rfid + * username varchar(1,30,alphanumeric) + * firstname varchar(3,30,letters) + * lastname varchar(3,30,letters) + * mail mail + * + * Note: letters is alphanumeric + ' ' + * + */ + + + public function testParamUsername(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a.b-c.d-e10', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'firstname'); + + } + + + public function testParamUsernameMin(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => 'a', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'firstname'); + + } + + public function testParamUsernameMinError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => '', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'username'); + + } + + public function testParamUsernameMax(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => '123456789012345678901234567890', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'firstname'); + + } + + public function testParamUsernameMaxError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => '123456789012345678901234567890x', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'username'); + + } + + public function testParamUsernameCharsetError(){ + + /* (1) Création requête */ + $req = new Request('userDefault/create', [ + 'code' => '01-10-01-10', + 'username' => '12345678901234567890123456789 ', + 'firstname' => '', + 'lastname' => '', + 'mail' => '' + ]); + + /* (2) Gestion erreur */ + $this->assertEquals($req->error->get(), Err::WrongParam); + $this->assertEquals(count($req->error->args()), 2); + $this->assertEquals($req->error->args()[0], 'username'); + + } + + } + +?> \ No newline at end of file