summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2016-03-20 14:59:34 -0700
committerElmer Thomas <elmer@thinkingserious.com>2016-03-20 14:59:34 -0700
commit87cf790028f26c9a9c24eb57ea1db5bab8900034 (patch)
treea8ff1692151fe2fd90c7ad2d3e392be89dba9fe9 /test
parente5ab6e0e867f58452dbdd03ee0469c48c9c841fe (diff)
downloadphp-http-client-87cf790028f26c9a9c24eb57ea1db5bab8900034.zip
php-http-client-87cf790028f26c9a9c24eb57ea1db5bab8900034.tar.gz
php-http-client-87cf790028f26c9a9c24eb57ea1db5bab8900034.tar.bz2
Added comments and formatting based on php_codesniffer
Diffstat (limited to 'test')
-rw-r--r--test/unit/ClientTest.php63
-rw-r--r--test/unit/bootstrap.php16
2 files changed, 40 insertions, 39 deletions
diff --git a/test/unit/ClientTest.php b/test/unit/ClientTest.php
index 3781668..d06962f 100644
--- a/test/unit/ClientTest.php
+++ b/test/unit/ClientTest.php
@@ -1,17 +1,18 @@
<?php
class MockClient extends SendGrid\Client
{
- public
- $request_body,
- $request_headers,
- $url;
+ public
+ $request_body,
+ $request_headers,
+ $url;
- public function _make_request($method, $url, $request_body = null, $request_headers = null) {
- $this->request_body = $request_body;
- $this->request_headers = $request_headers;
- $this->url = $url;
- return $this;
- }
+ public function makeRequest($method, $url, $request_body = null, $request_headers = null)
+ {
+ $this->request_body = $request_body;
+ $this->request_headers = $request_headers;
+ $this->url = $url;
+ return $this;
+ }
}
class ClientTest_Client extends PHPUnit_Framework_TestCase
@@ -28,48 +29,48 @@ class ClientTest_Client extends PHPUnit_Framework_TestCase
'Content-Type: application/json',
'Authorization: Bearer SG.XXXX'
);
- $this->client = new MockClient($this->host, $this->headers, "3", null);
+ $this->client = new MockClient($this->host, $this->headers, "/v3", null);
}
public function testInitialization()
{
$this->assertEquals($this->client->host, $this->host);
$this->assertEquals($this->client->request_headers, $this->headers);
- $this->assertEquals($this->client->version, "3");
+ $this->assertEquals($this->client->version, "/v3");
$this->assertEquals($this->client->url_path, []);
$this->assertEquals($this->client->methods, ['delete', 'get', 'patch', 'post', 'put']);
}
public function test_()
{
- $client = $this->client->_("test");
- $this->assertEquals($client->url_path, array("test"));
+ $client = $this->client->_("test");
+ $this->assertEquals($client->url_path, array("test"));
}
public function test__call()
{
- $client = $this->client->get();
- $this->assertEquals($client->url, "https://localhost:4010/v3/");
+ $client = $this->client->get();
+ $this->assertEquals($client->url, "https://localhost:4010/v3/");
- $query_params = array('limit' => 100, 'offset' => 0);
- $client = $this->client->get(null, $query_params);
- $this->assertEquals($client->url, "https://localhost:4010/v3/?limit=100&offset=0");
+ $query_params = array('limit' => 100, 'offset' => 0);
+ $client = $this->client->get(null, $query_params);
+ $this->assertEquals($client->url, "https://localhost:4010/v3/?limit=100&offset=0");
- $request_body = array('name' => 'A New Hope');
- $client = $this->client->get($request_body);
- $this->assertEquals($client->request_body, $request_body);
+ $request_body = array('name' => 'A New Hope');
+ $client = $this->client->get($request_body);
+ $this->assertEquals($client->request_body, $request_body);
- $request_headers = array('X-Mock: 200');
- $client = $this->client->get(null, null, $request_headers);
- $this->assertEquals($client->request_headers, $request_headers);
+ $request_headers = array('X-Mock: 200');
+ $client = $this->client->get(null, null, $request_headers);
+ $this->assertEquals($client->request_headers, $request_headers);
- $client = $this->client->version("4");
- $this->assertEquals($client->version, "4");
+ $client = $this->client->version("/v4");
+ $this->assertEquals($client->version, "/v4");
- $client = $this->client->path_to_endpoint();
- $this->assertEquals($client->url_path, array("path_to_endpoint"));
- $client = $client->one_more_segment();
- $this->assertEquals($client->url_path, array("path_to_endpoint", "one_more_segment"));
+ $client = $this->client->path_to_endpoint();
+ $this->assertEquals($client->url_path, array("path_to_endpoint"));
+ $client = $client->one_more_segment();
+ $this->assertEquals($client->url_path, array("path_to_endpoint", "one_more_segment"));
}
}
?> \ No newline at end of file
diff --git a/test/unit/bootstrap.php b/test/unit/bootstrap.php
index af10b46..8b4e24a 100644
--- a/test/unit/bootstrap.php
+++ b/test/unit/bootstrap.php
@@ -4,14 +4,14 @@ include(dirname(dirname(__FILE__)) . '/../lib/config.php');
require __DIR__ . '/../../vendor/autoload.php';
function autoload_tests($class)
{
- if (strpos($class, 'PHPHTTPClientTest_') !== 0) {
- return;
- }
- $class = substr($class, 13);
- $file = str_replace('_', '/', $class);
- if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
- require_once(dirname(__FILE__) . '/' . $file . '.php');
- }
+ if (strpos($class, 'PHPHTTPClientTest_') !== 0) {
+ return;
+ }
+ $class = substr($class, 13);
+ $file = str_replace('_', '/', $class);
+ if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
+ require_once(dirname(__FILE__) . '/' . $file . '.php');
+ }
}
spl_autoload_register('autoload_tests');
?> \ No newline at end of file