Open Journal Systems
3.3.0
DefaultResponseParserTest.php
1
<?php
2
3
namespace
Guzzle\Tests\Service\Command
;
4
5
use
Guzzle\Http\Message\Response
;
6
use
Guzzle\Service\Client
;
7
use
Guzzle\Service\Command\DefaultResponseParser
;
8
use
Guzzle\Service\Command\OperationCommand
;
9
use
Guzzle\Service\Description\Operation
;
10
14
class
DefaultResponseParserTest
extends
\Guzzle\Tests\GuzzleTestCase
15
{
16
public
function
testParsesXmlResponses
()
17
{
18
$op
=
new
OperationCommand
(array(),
new
Operation
());
19
$op
->setClient(
new
Client
());
20
$request =
$op
->prepare();
21
$request->setResponse(
new
Response
(200, array(
22
'Content-Type'
=>
'application/xml'
23
),
'<Foo><Baz>Bar</Baz></Foo>'
),
true
);
24
$this->assertInstanceOf(
'SimpleXMLElement'
,
$op
->execute());
25
}
26
27
public
function
testParsesJsonResponses
()
28
{
29
$op
=
new
OperationCommand
(array(),
new
Operation
());
30
$op
->setClient(
new
Client
());
31
$request =
$op
->prepare();
32
$request->setResponse(
new
Response
(200, array(
33
'Content-Type'
=>
'application/json'
34
),
'{"Baz":"Bar"}'
),
true
);
35
$this->assertEquals(array(
'Baz'
=>
'Bar'
),
$op
->execute());
36
}
37
41
public
function
testThrowsExceptionWhenParsingJsonFails
()
42
{
43
$op
=
new
OperationCommand
(array(),
new
Operation
());
44
$op
->setClient(
new
Client
());
45
$request =
$op
->prepare();
46
$request->setResponse(
new
Response
(200, array(
'Content-Type'
=>
'application/json'
),
'{"Baz":ddw}'
),
true
);
47
$op
->execute();
48
}
49
50
public
function
testAddsContentTypeWhenExpectsIsSetOnCommand
()
51
{
52
$op
=
new
OperationCommand
(array(),
new
Operation
());
53
$op
[
'command.expects'
] =
'application/json'
;
54
$op
->setClient(
new
Client
());
55
$request =
$op
->prepare();
56
$request->setResponse(
new
Response
(200,
null
,
'{"Baz":"Bar"}'
),
true
);
57
$this->assertEquals(array(
'Baz'
=>
'Bar'
),
$op
->execute());
58
}
59
}
$op
$op
Definition:
lib/pkp/pages/help/index.php:18
Guzzle\Service\Description\Operation
Definition:
Operation.php:10
Guzzle\Tests\Service\Command\DefaultResponseParserTest\testParsesXmlResponses
testParsesXmlResponses()
Definition:
DefaultResponseParserTest.php:16
Guzzle\Tests\GuzzleTestCase
Definition:
GuzzleTestCase.php:22
Guzzle\Service\Client
Definition:
lib/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php:25
Guzzle\Service\Command\OperationCommand
Definition:
OperationCommand.php:10
Guzzle\Http\Message\Response
Definition:
lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php:17
Guzzle\Service\Command\DefaultResponseParser
Definition:
DefaultResponseParser.php:10
Guzzle\Tests\Service\Command\DefaultResponseParserTest\testParsesJsonResponses
testParsesJsonResponses()
Definition:
DefaultResponseParserTest.php:27
Guzzle\Tests\Service\Command\DefaultResponseParserTest\testAddsContentTypeWhenExpectsIsSetOnCommand
testAddsContentTypeWhenExpectsIsSetOnCommand()
Definition:
DefaultResponseParserTest.php:50
Guzzle\Tests\Service\Command\DefaultResponseParserTest\testThrowsExceptionWhenParsingJsonFails
testThrowsExceptionWhenParsingJsonFails()
Definition:
DefaultResponseParserTest.php:41
Guzzle\Tests\Service\Command
Definition:
AbstractCommandTest.php:3
Guzzle\Tests\Service\Command\DefaultResponseParserTest
Definition:
DefaultResponseParserTest.php:14
plugins
paymethod
paypal
lib
vendor
guzzle
guzzle
tests
Guzzle
Tests
Service
Command
DefaultResponseParserTest.php
Generated on Fri Aug 28 2020 14:51:29 for Open Journal Systems by
1.8.17