FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bazaar-api-php/tests/GuzzleClientTest.php at master · nikapps/bazaar-api-php · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
nikapps
/
bazaar-api-php
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
4
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
bazaar-api-php
/
tests
/
GuzzleClientTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
87 lines (74 loc) · 2.32 KB
Breadcrumbs
bazaar-api-php
/
tests
/
GuzzleClientTest.php
Copy path
File metadata and controls
87 lines (74 loc) · 2.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace
Nikapps
\
BazaarApi
\
Tests
;
use
GuzzleHttp
\
Client
;
use
GuzzleHttp
\
Psr7
\
Response
;
use
Nikapps
\
BazaarApi
\
Client
\
GuzzleClient
;
class
GuzzleClientTest
extends
TestCase
{
/** @test */
public
function
it_should_send_a_get_request
()
{
$
guzzle
=
$
this
->
prophesize
(Client::class);
$
guzzle
->
get
(
'
http://example.com/
'
, [
'
query
'
=> [
'
q
'
=>
'
search
'
]])
->
willReturn
(
new
Response
(
200
,
[],
json_encode
([
'
key-one
'
=>
'
something
'
,
'
key-two
'
=>
'
something-else
'
])
));
$
client
=
new
GuzzleClient
(
$
guzzle
->
reveal
());
$
response
=
$
client
->
get
(
'
http://example.com/
'
, [
'
query
'
=> [
'
q
'
=>
'
search
'
]
]);
$
this
->
assertEquals
([
'
key-one
'
=>
'
something
'
,
'
key-two
'
=>
'
something-else
'
],
$
response
);
}
/** @test */
public
function
it_should_return_response_when_request_is_not_successful
()
{
$
guzzle
=
$
this
->
prophesize
(Client::class);
$
guzzle
->
get
(
'
http://example.com/
'
, [])
->
willReturn
(
new
Response
(
404
,
[],
json_encode
([
'
error
'
=>
'
not_found
'
])
));
$
client
=
new
GuzzleClient
(
$
guzzle
->
reveal
());
$
response
=
$
client
->
get
(
'
http://example.com/
'
);
$
this
->
assertEquals
([
'
error
'
=>
'
not_found
'
],
$
response
);
}
/** @test */
public
function
it_should_send_a_post_request
()
{
$
guzzle
=
$
this
->
prophesize
(Client::class);
$
guzzle
->
post
(
'
http://example.com/
'
, [
'
form_params
'
=> [
'
username
'
=>
'
alibo
'
]])
->
willReturn
(
new
Response
(
200
,
[],
json_encode
([
'
key-one
'
=>
'
something
'
,
'
key-two
'
=>
'
something-else
'
])
));
$
client
=
new
GuzzleClient
(
$
guzzle
->
reveal
());
$
response
=
$
client
->
post
(
'
http://example.com/
'
, [
'
form_params
'
=> [
'
username
'
=>
'
alibo
'
]
]);
$
this
->
assertEquals
([
'
key-one
'
=>
'
something
'
,
'
key-two
'
=>
'
something-else
'
],
$
response
);
}
}
Back
|
FazBrowse Home
|
New Git URL