From e9c7477ff0acedf9b49e508e1543395bbcbf7533 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 27 Mar 2016 19:24:03 +0200 Subject: Modifications in error management and correct error in Image.php --- server/Test/AppTestClass.php | 8 ++-- server/Test/imageTests.php | 95 +++++++++++++++++++++++++++++++++----------- 2 files changed, 77 insertions(+), 26 deletions(-) (limited to 'server/Test') diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index 3f8abbe..a663514 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -89,9 +89,11 @@ class AppTest{ } public function getPostParam($name){ - - return $this->postParams[$name]; - + if(isset($this->postParams[$name])){ + return $this->postParams[$name]; + }else{ + $this->setOutput("Error", "Missing parameter ".$name); + } } public function setPostParam($name, $value){ diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php index d86c664..4adec08 100644 --- a/server/Test/imageTests.php +++ b/server/Test/imageTests.php @@ -6,6 +6,9 @@ include_once("../core/Compute.php"); $image = new Image($App); $compute = new Compute($App); +// Création image +/* +echo "Création image :
"; $opt = Array(); $opt['name'] = "Test"; $opt['tags'] = ['test', 'openstack']; @@ -16,28 +19,86 @@ $opt['minDisk'] = 1; $opt['protected'] = false; $opt['minRam'] = 10; -//$App->setPostParam('id', 'sdfihlus154dfhj'); -//$err = $image->action("createImage"); +$App->setPostParam('opt', $opt); +$image->action("createImage"); +$retCreate = json_decode($App->show(), true)["Images"]; +$idNew = $retCreate['id']; +*/ +/* +// Delete Image +$App->setPostParam('id', $idNew); +$image->action("deleteImage"); +*/ -//Liste des images +// Liste images $image->action("listImage"); $im = $App->show(); $images = json_decode($im, true)["Images"]; -echo "Images présentes :"; -echo "
"; +echo "List images :
"; foreach($images as $i){ - $recup = $i; - echo $recup['name']; + echo $i['name']."
"; // Nom + echo $i['status']."
"; // Status + $id = $i['id']; // Id + echo $id."
"; + foreach ($i['tags'] as $tag) { // Tags + echo $tag."
"; + } echo "
"; - //echo $recup['id']; - } + } + + +// Details images +echo "Détail image :
"; +$App->setPostParam('id', $id); +$image->action("detailsImage"); +$retDetails = json_decode($App->show(), true)["Images"]; +echo $retDetails['id']."
"; +echo "
"; + + +/* +// Download image +$App->setPostParam('id', $id); +$image->action("downloadImage"); +*/ + + +// Desactivate Images +echo "Desactivate image :
"; +echo $id."
"; +$App->setPostParam('id', $id); +$err = $image->action("desactivateImage"); echo "
"; + +/* +// Resactivate Images +echo $id."
"; +$App->setPostParam('id', $id); +$err = $image->action("resactivateImage"); +*/ + + +/* +// Details images +echo "Update image :
"; +$optUpdate = Array(); +$optUpdate['tags'] = ['ciros', 'testUpdate']; +$App->setPostParam('id', $id); +$App->setPostParam('opt', $optUpdate); +$image->action("updateImage"); +$retDetails = json_decode($App->show(), true)["Images"]; +foreach ($retDetails['tags'] as $tag) { // Tags + echo $tag."
"; +} +*/ + + +/* echo "Flavors: "; echo "
"; - $compute->action("listFlavors"); $flavors = json_decode($App->show(), true)["Flavors"]; @@ -49,17 +110,5 @@ foreach($flavors as $f){ echo "vcpus=".$f['vcpus']; echo "
"; } - -/* -$App->setPostParam('id', 354); -$err = $image->action("deleteImage"); -$temp = $App->show(); -$ret = json_decode($temp, true)["Images"]; -echo $ret['id']; -*/ - - - - - +*/ ?> \ No newline at end of file -- cgit v1.2.3