83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
if (!defined('PATH_SEP')) {
|
||
|
|
define('PATH_SEP', '/');
|
||
|
|
}
|
||
|
|
|
||
|
|
require_once PATH_HOME . 'engine/services/rest/crud/Application.php';
|
||
|
|
require_once("Rest/JsonMessage.php");
|
||
|
|
require_once("Rest/XmlMessage.php");
|
||
|
|
require_once("Rest/RestMessage.php");
|
||
|
|
|
||
|
|
class ApplicationTest extends PHPUnit_Extensions_Database_TestCase
|
||
|
|
{
|
||
|
|
public function setup()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function getTearDownOperation()
|
||
|
|
{
|
||
|
|
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||
|
|
*/
|
||
|
|
|
||
|
|
// only instantiate pdo once for test clean-up/fixture load
|
||
|
|
static private $pdo = null;
|
||
|
|
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||
|
|
private $conn = null;
|
||
|
|
|
||
|
|
public function getConnection()
|
||
|
|
{
|
||
|
|
if ($this->conn === null) {
|
||
|
|
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||
|
|
if (self::$pdo == null) {
|
||
|
|
self::$pdo = new PDO(
|
||
|
|
$dsn,
|
||
|
|
$_SERVER['PM_UNIT_DB_USER'],
|
||
|
|
$_SERVER['PM_UNIT_DB_PASS'] );
|
||
|
|
}
|
||
|
|
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||
|
|
}
|
||
|
|
return $this->conn;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||
|
|
*/
|
||
|
|
|
||
|
|
public function getDataSet()
|
||
|
|
{
|
||
|
|
//return $this->createXMLDataSet('pmSLA/tests/db.xml');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testGet()
|
||
|
|
{
|
||
|
|
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||
|
|
$method = "login";
|
||
|
|
|
||
|
|
$jsonm = new JsonMessage();
|
||
|
|
$jsonm->send($method,$msg);
|
||
|
|
//$jsonm->displayResponse();
|
||
|
|
|
||
|
|
$xmlm = new XmlMessage();
|
||
|
|
$xmlm->send($method, $msg);
|
||
|
|
//$xmlm->displayResponse();
|
||
|
|
|
||
|
|
$APP_UID = array("741388075505cd6bba2e993094312973");
|
||
|
|
$table = "APPLICATION";
|
||
|
|
|
||
|
|
$rest = new RestMessage();
|
||
|
|
$resp = $rest->sendGET($table,$APP_UID);
|
||
|
|
//$rest->displayResponse();
|
||
|
|
|
||
|
|
$queryTable = $this->getConnection()->createQueryTable(
|
||
|
|
'APPLICATION', 'SELECT * FROM APPLICATION WHERE APP_UID = "741388075505cd6bba2e993094312973"'
|
||
|
|
);
|
||
|
|
|
||
|
|
$this->assertEquals($resp, $queryTable, "ERROR");
|
||
|
|
}
|
||
|
|
}
|