mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-02 15:44:11 +01:00
Unit test of the import web service
SVN:code[50]
This commit is contained in:
@@ -195,7 +195,7 @@ abstract class TestWebServices extends TestHandler
|
||||
{
|
||||
// simply overload DoExecute (temporary)
|
||||
|
||||
static protected function DoPostRequestAuth($sRelativeUrl, $aData, $sLogin = 'root', $sPassword = '', $sOptionnalHeaders = null)
|
||||
static protected function DoPostRequestAuth($sRelativeUrl, $aData, $sLogin = 'admin', $sPassword = '', $sOptionnalHeaders = null)
|
||||
{
|
||||
$aDataAndAuth = $aData;
|
||||
$aDataAndAuth['operation'] = 'login';
|
||||
|
||||
@@ -941,15 +941,54 @@ class TestItopWebServices extends TestWebServices
|
||||
{
|
||||
return 'Bulk load and ???';
|
||||
}
|
||||
|
||||
protected function DoExecSingleLoad($aLoadSpec)
|
||||
{
|
||||
$sTitle = 'Load: '.$aLoadSpec['class'];
|
||||
$sClass = $aLoadSpec['class'];
|
||||
$sCsvData = $aLoadSpec['csvdata'];
|
||||
|
||||
$aPostData = array('class' => $sClass, 'csvdata' => $sCsvData);
|
||||
$sRes = self::DoPostRequestAuth('webservices/import.php', $aPostData);
|
||||
|
||||
echo "<div><h3>$sTitle</h3><pre>$sCsvData</pre><div>$sRes</div></div>";
|
||||
}
|
||||
|
||||
protected function DoExecute()
|
||||
{
|
||||
$aPostData = array('csvdata' => "name;code
|
||||
WorldCompany;WCY
|
||||
hp;HP");
|
||||
|
||||
$sRes = self::DoPostRequestAuth('webservices/import.php?class=bizOrganization', $aPostData);
|
||||
echo "<div>$sRes</div>";
|
||||
$aLoads = array(
|
||||
array(
|
||||
'class' => 'bizOrganization',
|
||||
'csvdata' => "name;code\nWorldCompany;WCY"
|
||||
),
|
||||
array(
|
||||
'class' => 'bizLocation',
|
||||
'csvdata' => "name;org_id;address\nParis;1;Centre de la Franca"
|
||||
),
|
||||
array(
|
||||
'class' => 'bizPerson',
|
||||
'csvdata' => "email;name;first_name;org_id;phone\njohn.foo@starac.com;Foo;John;1;+33(1)23456789"
|
||||
),
|
||||
array(
|
||||
'class' => 'bizTeam',
|
||||
'csvdata' => "name;org_id;location_id\nSquadra Azzura;1;1"
|
||||
),
|
||||
array(
|
||||
'class' => 'bizWorkgroup',
|
||||
'csvdata' => "name;org_id;team_id\ntravailleurs alpins;1;6"
|
||||
),
|
||||
array(
|
||||
'class' => 'bizIncidentTicket',
|
||||
'csvdata' => "name;title;type;customer_id;initial_situation;start_date;next_update;caller_id;workgroup_id;agent_id\nOVSD-12345;server down;Network;1;server was found down;2009-04-10 12:00;2009-04-10 15:00;3;317;5"
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($aLoads as $aLoadSpec)
|
||||
{
|
||||
$this->DoExecSingleLoad($aLoadSpec);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,6 @@
|
||||
* @version 1.1.1.1 $
|
||||
*/
|
||||
|
||||
//
|
||||
// Test URLs
|
||||
//
|
||||
// http://localhost:81/pages/importcsv_ws.php?class=bizOrganization&csvdata=name;code%0AWorldCompany;WCY
|
||||
// http://localhost:81/pages/importcsv_ws.php?class=bizLocation&csvdata=name;org_id;address%0AParis;1;Centre de la Franca
|
||||
// http://localhost:81/pages/importcsv_ws.php?class=bizPerson&csvdata=email;name;first_name;org_id;phone%0Ajohn.foo@starac.com;Foo;John;1;+33(1)23456789
|
||||
// http://localhost:81/pages/importcsv_ws.php?class=bizTeam&csvdata=name;org_id;location_id%0ASquadra Azzura;1;1
|
||||
// http://localhost:81/pages/importcsv_ws.php?class=bizWorkgroup&csvdata=name;org_id;team_id%0Atravailleurs alpins;1;3
|
||||
// this one is always creating a new ticket ?!?!?
|
||||
// http://localhost:81/pages/importcsv_ws.php?class=bizIncidentTicket&csvdata=name;title;type;customer_id;initial_situation;start_date;next_update;caller_id;workgroup_id;agent_id%0AOVSD-12345;server down;Network;1;server was found down;2009-04-10 12:00;2009-04-10 15:00;2;4;2
|
||||
//
|
||||
//
|
||||
// Known limitations
|
||||
// - output still in html, because the errors are not displayed in xml
|
||||
|
||||
Reference in New Issue
Block a user