Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
OpsPortal
lavoisiercli
Commits
080b1385
Commit
080b1385
authored
Oct 25, 2014
by
Olivier Lequeux
Browse files
fis SensioLabsInsight items
parent
eb7d993b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
20 deletions
+35
-20
composer.json
composer.json
+1
-0
src/Lavoisier/Exceptions/CurlException.php
src/Lavoisier/Exceptions/CurlException.php
+1
-1
src/Lavoisier/Hydrators/DefaultHydrator.php
src/Lavoisier/Hydrators/DefaultHydrator.php
+0
-2
src/Lavoisier/Hydrators/EntriesHydrator.php
src/Lavoisier/Hydrators/EntriesHydrator.php
+1
-3
src/Lavoisier/Hydrators/SimpleXMLHydrator.php
src/Lavoisier/Hydrators/SimpleXMLHydrator.php
+1
-4
src/Lavoisier/Query.php
src/Lavoisier/Query.php
+22
-8
tests/EntriesTest.php
tests/EntriesTest.php
+1
-2
tests/QueryTest.php
tests/QueryTest.php
+8
-0
No files found.
composer.json
View file @
080b1385
{
{
"name"
:
"ccin2p3/lavoisiercli"
,
"name"
:
"ccin2p3/lavoisiercli"
,
"description"
:
"Lavoisier client"
,
"description"
:
"Lavoisier client"
,
"license"
:
"proprietary"
,
"authors"
:
[
"authors"
:
[
{
{
"name"
:
"Olivier Lequeux"
,
"name"
:
"Olivier Lequeux"
,
...
...
src/Lavoisier/Exceptions/
cURL
Exception.php
→
src/Lavoisier/Exceptions/
Curl
Exception.php
View file @
080b1385
...
@@ -4,7 +4,7 @@ namespace Lavoisier\Exceptions;
...
@@ -4,7 +4,7 @@ namespace Lavoisier\Exceptions;
use
\
Lavoisier\Query
;
use
\
Lavoisier\Query
;
class
cUR
LException
extends
\
Exception
class
Curl
LException
extends
\
Exception
{
{
private
$userMessage
=
null
;
private
$userMessage
=
null
;
...
...
src/Lavoisier/Hydrators/DefaultHydrator.php
View file @
080b1385
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
namespace
Lavoisier\Hydrators
;
namespace
Lavoisier\Hydrators
;
use
\
Lavoisier\Hydrators\IHydrator
;
class
DefaultHydrator
implements
IHydrator
{
class
DefaultHydrator
implements
IHydrator
{
public
function
hydrate
(
$str
)
{
public
function
hydrate
(
$str
)
{
...
...
src/Lavoisier/Hydrators/EntriesHydrator.php
View file @
080b1385
...
@@ -2,9 +2,7 @@
...
@@ -2,9 +2,7 @@
namespace
Lavoisier\Hydrators
;
namespace
Lavoisier\Hydrators
;
use
\
Lavoisier\Hydrators\IHydrator
;
use
\
Lavoisier\Entries\IEntries
;
use
\
Lavoisier\Entries\IEntries
;
use
\
Lavoisier\Entries\Entries
;
class
EntriesHydrator
implements
IHydrator
class
EntriesHydrator
implements
IHydrator
{
{
...
@@ -77,7 +75,7 @@ class EntriesHydrator implements IHydrator
...
@@ -77,7 +75,7 @@ class EntriesHydrator implements IHydrator
}
}
}
else
{
}
else
{
$str
=
strval
(
$sxi
->
current
());
$str
=
strval
(
$sxi
->
current
());
if
(
$this
->
value_as_key
==
true
)
{
if
(
$this
->
value_as_key
==
=
true
)
{
$key
=
$str
;
$key
=
$str
;
}
}
if
(
$key
===
null
)
{
if
(
$key
===
null
)
{
...
...
src/Lavoisier/Hydrators/SimpleXMLHydrator.php
View file @
080b1385
...
@@ -7,12 +7,10 @@ use \Lavoisier\Entries\Entries;
...
@@ -7,12 +7,10 @@ use \Lavoisier\Entries\Entries;
class
SimpleXMLHydrator
implements
IHydrator
class
SimpleXMLHydrator
implements
IHydrator
{
{
private
$prefix
;
private
$prefix
;
private
$ns
;
function
__construct
()
function
__construct
()
{
{
$this
->
prefix
=
''
;
$this
->
prefix
=
''
;
$this
->
ns
=
''
;
}
}
public
function
hydrate
(
$str
)
public
function
hydrate
(
$str
)
...
@@ -31,10 +29,9 @@ class SimpleXMLHydrator implements IHydrator
...
@@ -31,10 +29,9 @@ class SimpleXMLHydrator implements IHydrator
return
$sxObject
;
return
$sxObject
;
}
}
public
function
registerNamespace
(
$prefix
,
$ns
)
public
function
registerNamespace
(
$prefix
)
{
{
$this
->
prefix
=
$prefix
;
$this
->
prefix
=
$prefix
;
$this
->
ns
=
$ns
;
}
}
public
function
registerEntriesNamespace
(
$useLavoisierXMLNS
=
true
)
public
function
registerEntriesNamespace
(
$useLavoisierXMLNS
=
true
)
...
...
src/Lavoisier/Query.php
View file @
080b1385
...
@@ -17,7 +17,7 @@ class Query
...
@@ -17,7 +17,7 @@ class Query
{
{
static
private
$queryTemplates
;
static
private
$queryTemplates
;
private
$
is_
secure
;
private
$secure
Mode
;
private
$schema
;
private
$schema
;
private
$hostname
;
private
$hostname
;
private
$port
;
private
$port
;
...
@@ -41,7 +41,7 @@ class Query
...
@@ -41,7 +41,7 @@ class Query
public
function
__construct
(
$hostname
,
$view
=
''
,
$operation
=
'lavoisier'
,
$accept
=
'xml'
)
public
function
__construct
(
$hostname
,
$view
=
''
,
$operation
=
'lavoisier'
,
$accept
=
'xml'
)
{
{
$this
->
set
Is
Secure
(
false
);
$this
->
setSecure
Mode
(
false
);
$this
->
hostname
=
$hostname
;
$this
->
hostname
=
$hostname
;
$this
->
port
=
'8080'
;
$this
->
port
=
'8080'
;
$this
->
operation
=
$operation
;
$this
->
operation
=
$operation
;
...
@@ -56,7 +56,8 @@ class Query
...
@@ -56,7 +56,8 @@ class Query
'lavoisier'
=>
"%s%s:%s/%s/%s%s%saccept=%s"
,
'lavoisier'
=>
"%s%s:%s/%s/%s%s%saccept=%s"
,
'lavoisier_base'
=>
"%s%s:%s/%s/%s%s"
,
'lavoisier_base'
=>
"%s%s:%s/%s/%s%s"
,
'notify'
=>
"%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
();
$this
->
hydrator
=
new
DefaultHydrator
();
...
@@ -67,10 +68,10 @@ class Query
...
@@ -67,10 +68,10 @@ class Query
}
}
public
function
set
Is
Secure
(
$is_secure
)
public
function
setSecure
Mode
(
$is_secure
)
{
{
$this
->
is_
secure
=
$is_secure
;
$this
->
secure
Mode
=
$is_secure
;
if
(
$this
->
is_
secure
===
true
)
{
if
(
$this
->
secure
Mode
===
true
)
{
$this
->
schema
=
'https://'
;
$this
->
schema
=
'https://'
;
}
else
{
}
else
{
$this
->
schema
=
'http://'
;
$this
->
schema
=
'http://'
;
...
@@ -104,7 +105,7 @@ class Query
...
@@ -104,7 +105,7 @@ class Query
public
function
setMethod
(
$method
)
public
function
setMethod
(
$method
)
{
{
if
((
$method
===
'GET'
)
or
(
$method
===
'POST'
))
{
if
((
$method
===
'GET'
)
||
(
$method
===
'POST'
))
{
$this
->
method
=
$method
;
$this
->
method
=
$method
;
}
else
{
}
else
{
...
@@ -154,6 +155,19 @@ class Query
...
@@ -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
()
public
function
curl
()
{
{
// init curl session
// init curl session
...
@@ -324,4 +338,4 @@ class Query
...
@@ -324,4 +338,4 @@ class Query
);
);
}
}
}
}
\ No newline at end of file
tests/EntriesTest.php
View file @
080b1385
...
@@ -37,8 +37,7 @@ class EntriesTest extends \PHPUnit_Framework_TestCase
...
@@ -37,8 +37,7 @@ class EntriesTest extends \PHPUnit_Framework_TestCase
$input
=
file_get_contents
(
dirname
(
__FILE__
)
.
'/Resources/tickets.xml'
);
$input
=
file_get_contents
(
dirname
(
__FILE__
)
.
'/Resources/tickets.xml'
);
$hydrator
=
new
\
Lavoisier\Hydrators\EntriesHydrator
(
"\TicketingSystem\Ticket\GgusFields"
);
$hydrator
=
new
\
Lavoisier\Hydrators\EntriesHydrator
(
"\TicketingSystem\Ticket\GgusFields"
);
$coll
=
$hydrator
->
hydrate
(
$input
);
$hydrator
->
hydrate
(
$input
);
//print_r($coll);
}
}
...
...
tests/QueryTest.php
View file @
080b1385
...
@@ -82,4 +82,12 @@ class QueryTest extends \PHPUnit_Framework_TestCase
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment