-
0.00% covered (danger)
+
orm |
+
+
+ 69.23% covered (warning)
|
-
0.00% |
-
0 / 582 |
+
69.23% |
+
342 / 494 |
-
- 0.00% covered (danger)
+
+ 28.00% covered (danger)
|
-
0.00% |
-
0 / 25 |
+
28.00% |
+
7 / 25 |
diff --git a/phpunit/phpunit.xml b/phpunit/phpunit.xml
index df22e01..7edda87 100755
--- a/phpunit/phpunit.xml
+++ b/phpunit/phpunit.xml
@@ -1,9 +1,9 @@
-
+
-
- ./tests
+
+ ./tests/user/create.php
diff --git a/phpunit/tests/apiconfig.php b/phpunit/tests/apiconfig.php
deleted file mode 100644
index 218ffba..0000000
--- a/phpunit/tests/apiconfig.php
+++ /dev/null
@@ -1,24 +0,0 @@
-assertFileExists($path);
-
- /* (2) Checks json */
- $config = json_decode( file_get_contents($path), true );
- $this->assertNotNull($config);
-
- }
-
-
- }
-
-?>
\ No newline at end of file
diff --git a/phpunit/tests/user/create.php b/phpunit/tests/user/create.php
new file mode 100644
index 0000000..9c59b9d
--- /dev/null
+++ b/phpunit/tests/user/create.php
@@ -0,0 +1,127 @@
+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 testCreateAlready(){
+
+ /* (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) Gestion erreur */
+ $res = $req->dispatch();
+
+ /* (4) Gestion erreur */
+ $this->assertEquals($res->error->get(), Err::AlreadyExists);
+
+
+ }
+
+ /*
+ * @depends testCreateAlready
+ */
+ 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);
+
+
+ }
+
+
+ }
+
+?>
\ No newline at end of file
|