Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-http-client
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-http-client
Commits
94875105
Commit
94875105
authored
6 years ago
by
Grzegorz Rola
Browse files
Options
Downloads
Patches
Plain Diff
First tests
parent
2f081692
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Feature/first release
Pipeline
#4761
passed with stages
Stage: tools
Stage: tests
in 2 minutes and 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/unit/Curl/TestCurlClient.php
+50
-0
50 additions, 0 deletions
tests/unit/Curl/TestCurlClient.php
tests/unit/TestHttpClientFactory.php
+15
-0
15 additions, 0 deletions
tests/unit/TestHttpClientFactory.php
with
65 additions
and
0 deletions
tests/unit/Curl/TestCurlClient.php
0 → 100644
+
50
−
0
View file @
94875105
<?php
class
TestCurlClient
extends
\PHPUnit\Framework\TestCase
{
/**
* Test get method.
*/
public
function
testGet
()
{
$client
=
new
\WPDesk\HttpClient\Curl\CurlClient
();
$response
=
$client
->
get
(
'https://www.google.com'
,
''
,
array
(),
15
);
$this
->
assertInstanceOf
(
\WPDesk\HttpClient\HttpClientResponse
::
class
,
$response
);
$this
->
assertEquals
(
200
,
$response
->
getResponseCode
());
}
/**
* Test post method.
*/
public
function
testPost
()
{
$client
=
new
\WPDesk\HttpClient\Curl\CurlClient
();
$response
=
$client
->
post
(
'https://www.google.com'
,
''
,
array
(),
15
);
$this
->
assertInstanceOf
(
\WPDesk\HttpClient\HttpClientResponse
::
class
,
$response
);
$this
->
assertEquals
(
405
,
$response
->
getResponseCode
());
}
/**
* Test put method.
*/
public
function
testPut
()
{
$client
=
new
\WPDesk\HttpClient\Curl\CurlClient
();
$response
=
$client
->
put
(
'https://www.google.com'
,
''
,
array
(),
15
);
$this
->
assertInstanceOf
(
\WPDesk\HttpClient\HttpClientResponse
::
class
,
$response
);
$this
->
assertEquals
(
405
,
$response
->
getResponseCode
());
}
/**
* Test delete method.
*/
public
function
testDelete
()
{
$client
=
new
\WPDesk\HttpClient\Curl\CurlClient
();
$response
=
$client
->
put
(
'https://www.google.com'
,
''
,
array
(),
15
);
$this
->
assertInstanceOf
(
\WPDesk\HttpClient\HttpClientResponse
::
class
,
$response
);
$this
->
assertEquals
(
405
,
$response
->
getResponseCode
());
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/unit/TestHttpClientFactory.php
+
15
−
0
View file @
94875105
...
...
@@ -3,4 +3,19 @@
class
TestHttpClientFactory
extends
\PHPUnit\Framework\TestCase
{
/**
* Test createClient method.
*/
public
function
testCreateClient
()
{
$options
=
Mockery
::
mock
(
\WPDesk\HttpClient\HttpClientOptions
::
class
);
$options
->
shouldReceive
(
'getHttpClientClass'
)
->
withAnyArgs
()
->
andReturn
(
\WPDesk\HttpClient\Curl\CurlClient
::
class
);
$factory
=
new
\WPDesk\HttpClient\HttpClientFactory
();
$client
=
$factory
->
createClient
(
$options
);
$this
->
assertInstanceOf
(
\WPDesk\HttpClient\Curl\CurlClient
::
class
,
$client
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment