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