Commit 080b1385 authored by Olivier Lequeux's avatar Olivier Lequeux
Browse files

fis SensioLabsInsight items

parent eb7d993b
{
"name": "ccin2p3/lavoisiercli",
"description": "Lavoisier client",
"license" : "proprietary",
"authors": [
{
"name": "Olivier Lequeux",
......
......@@ -4,7 +4,7 @@ namespace Lavoisier\Exceptions;
use \Lavoisier\Query;
class cURLException extends \Exception
class CurlLException extends \Exception
{
private $userMessage = null;
......
......@@ -2,8 +2,6 @@
namespace Lavoisier\Hydrators;
use \Lavoisier\Hydrators\IHydrator;
class DefaultHydrator implements IHydrator{
public function hydrate($str) {
......
......@@ -2,9 +2,7 @@
namespace Lavoisier\Hydrators;
use \Lavoisier\Hydrators\IHydrator;
use \Lavoisier\Entries\IEntries;
use \Lavoisier\Entries\Entries;
class EntriesHydrator implements IHydrator
{
......@@ -77,7 +75,7 @@ class EntriesHydrator implements IHydrator
}
} else {
$str = strval($sxi->current());
if ($this->value_as_key == true) {
if ($this->value_as_key === true) {
$key = $str;
}
if ($key === null) {
......
......@@ -7,12 +7,10 @@ use \Lavoisier\Entries\Entries;
class SimpleXMLHydrator implements IHydrator
{
private $prefix;
private $ns;
function __construct()
{
$this->prefix = '';
$this->ns = '';
}
public function hydrate($str)
......@@ -31,10 +29,9 @@ class SimpleXMLHydrator implements IHydrator
return $sxObject;
}
public function registerNamespace($prefix, $ns)
public function registerNamespace($prefix)
{
$this->prefix = $prefix;
$this->ns = $ns;
}
public function registerEntriesNamespace($useLavoisierXMLNS = true)
......
......@@ -17,7 +17,7 @@ class Query
{
static private $queryTemplates;
private $is_secure;
private $secureMode;
private $schema;
private $hostname;
private $port;
......@@ -41,7 +41,7 @@ class Query
public function __construct($hostname, $view = '', $operation = 'lavoisier', $accept='xml')
{
$this->setIsSecure(false);
$this->setSecureMode(false);
$this->hostname = $hostname;
$this->port = '8080';
$this->operation = $operation;
......@@ -56,7 +56,8 @@ class Query
'lavoisier' => "%s%s:%s/%s/%s%s%saccept=%s",
'lavoisier_base' => "%s%s:%s/%s/%s%s",
'notify' => "%s%s:%s/%s/%s",
'resources' => "%s%s:%s/%s/%s"
'resources' => "%s%s:%s/%s/%s",
'console' => '%s%s:%s/%s'
);
$this->hydrator = new DefaultHydrator();
......@@ -67,10 +68,10 @@ class Query
}
public function setIsSecure($is_secure)
public function setSecureMode($is_secure)
{
$this->is_secure = $is_secure;
if ($this->is_secure === true) {
$this->secureMode = $is_secure;
if ($this->secureMode === true) {
$this->schema = 'https://';
} else {
$this->schema = 'http://';
......@@ -104,7 +105,7 @@ class Query
public function setMethod($method)
{
if (($method === 'GET') or ($method === 'POST')) {
if (($method === 'GET') || ($method === 'POST')) {
$this->method = $method;
} else {
......@@ -154,6 +155,19 @@ class Query
}
}
public function isInstanceRunning() {
$ch = curl_init(($this->getUrl(false, "console")));
curl_setopt($ch, CURLOPT_CONNECT_ONLY, true);
curl_exec($ch);
$response = curl_getinfo($ch);
$response['last_curl_error'] = curl_error($ch);
curl_close($ch);
return empty($response['last_curl_error']);
}
public function curl()
{
// init curl session
......@@ -324,4 +338,4 @@ class Query
);
}
}
\ No newline at end of file
}
......@@ -37,8 +37,7 @@ class EntriesTest extends \PHPUnit_Framework_TestCase
$input = file_get_contents(dirname(__FILE__) . '/Resources/tickets.xml');
$hydrator = new \Lavoisier\Hydrators\EntriesHydrator("\TicketingSystem\Ticket\GgusFields");
$coll = $hydrator->hydrate($input);
//print_r($coll);
$hydrator->hydrate($input);
}
......
......@@ -82,4 +82,12 @@ class QueryTest extends \PHPUnit_Framework_TestCase
}
public function testIsRunning() {
$q =new Query("nohost");
$this->assertEquals("http://nohost:8080/lavoisier", $q ->getUrl(false, "console"));
$this->assertEquals(false, $q->isInstanceRunning());
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment