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 testCreateCorrect(){ /* (1) Création requête */ $req = new Request('userDefault/create', [ 'code' => '12-AB-CD-EF', 'username' => 'abcdef123456', 'firstname' => 'a bcdef123456', 'lastname' => 'ab cdef123456', 'mail' => 'ab@cd.ef' ]); /* (2) Gestion erreur */ $this->assertEquals($req->error->get(), Err::Success); /* (3) Exécution */ $res = $req->dispatch(); /* (4) Gestion erreur */ $this->assertEquals($res->error->get(), Err::Success); self::$created = $res->get('id_user'); } /* * @depends testCreateCorrect */ public function testCreateAlreadyCode(){ /* (1) Création requête */ $req = new Request('userDefault/create', [ 'code' => '12-AB-CD-EF', 'username' => 'xxx', 'firstname' => 'a bcdef123456', 'lastname' => 'ab cdef123456', 'mail' => 'ab@cd.ef' ]); /* (2) Gestion erreur */ $this->assertEquals($req->error->get(), Err::Success); /* (3) Gestion erreur */ $res = $req->dispatch(); /* (4) Gestion erreur */ $this->assertEquals($res->error->get(), Err::AlreadyExists); } /* * @depends testCreateCorrect */ public function testCreateAlreadyUsername(){ /* (1) Création requête */ $req = new Request('userDefault/create', [ 'code' => '01-10-01-10', 'username' => 'abcdef123456', 'firstname' => 'a bcdef123456', 'lastname' => 'ab cdef123456', 'mail' => 'ab@cd.ef' ]); /* (2) Gestion erreur */ $this->assertEquals($req->error->get(), Err::Success); /* (3) Gestion erreur */ $res = $req->dispatch(); /* (4) Gestion erreur */ $this->assertEquals($res->error->get(), Err::AlreadyExists); } /* * @afterClass */ public function testRemoveCreated(){ /* (1) Création requête */ $req = new Request('userDefault/delete', [ 'id_user' => self::$created ]); /* (2) Gestion erreur */ $this->assertEquals($req->error->get(), Err::Success); /* (3) Exécution */ $res = $req->dispatch(); /* (4) Gestion erreur */ $this->assertEquals($res->error->get(), Err::Success); } } ?>