-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
134 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="./tests/bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="importer-tests"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace DeployBot\Test; | ||
|
||
use Jaybizzle\DeployBot; | ||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Subscriber\Mock; | ||
use GuzzleHttp\Message\Response; | ||
|
||
class DeployBotTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* @dataProvider providerParamNames | ||
*/ | ||
public function testCamelCaseMethodsReturnSnakeCaseParams($original, $expected) | ||
{ | ||
$db = new DeployBot('foo_api_key', 'bar_account_name', new \stdClass()); | ||
|
||
$result = $db->snakeCase($original); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testParseApiEndpoint() | ||
{ | ||
$expected = 'https://foobar.deploybot.com/api/v1/'; | ||
|
||
$db = $this->getMockBuilder('Jaybizzle\DeployBot') | ||
->setConstructorArgs(array('foo_api_key', 'bar_account_name')) | ||
->disableOriginalConstructor() | ||
->setMethods(null) | ||
->getMock(); | ||
|
||
$result = $db->parseApiEndpoint('foobar'); | ||
|
||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
public function testGetUsersResponse() | ||
{ | ||
$client = new Client(); | ||
|
||
$mock = new Mock(); | ||
$mock->addResponse(__DIR__.'/responses/getUsersResponse.txt'); | ||
|
||
$client->getEmitter()->attach($mock); | ||
|
||
$db = new DeployBot('foo_api_key', 'bar_account_name', $client); | ||
|
||
$result = $db->getUsers(); | ||
|
||
$this->assertEquals(3, count($result->entries)); | ||
} | ||
|
||
public function testAddingQueryParams() | ||
{ | ||
$args = array(2); | ||
|
||
$db = new DeployBot('foo_api_key', 'bar_account_name', new \stdClass()); | ||
|
||
$db->addQuery('limit', $args); | ||
|
||
$this->assertTrue(array_key_exists('limit', $db->query)); | ||
$this->assertEquals(2, $db->query['limit']); | ||
} | ||
|
||
public function providerParamNames() | ||
{ | ||
return array( | ||
array('fooBar', 'foo_bar'), | ||
array('FooBar', 'foo_bar'), | ||
array('FOOBAR', 'f_o_o_b_a_r'), | ||
); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
error_reporting(E_ALL | E_STRICT); | ||
require dirname(__DIR__) . '/vendor/autoload.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
Content-Length: 680 | ||
Connection: keep-alive | ||
Status: 200 OK | ||
X-Content-Type-Options: nosniff | ||
ETag: "8de608c3368602f1ab3b0a83804a7ced" | ||
Cache-Control: max-age=0, private, must-revalidate | ||
X-Request-Id: 93e6ea9c-fbe1-4eca-81b6-933223fbf751 | ||
X-Runtime: 0.028322 | ||
X-Powered-By: BeanServ 1.1 | ||
Date: Thu, 13 Aug 2015 16:10:30 CDT | ||
Server: BeanServ 1.1 | ||
X-Frame-Options: SAMEORIGIN | ||
X-Content-Type-Options: nosniff | ||
Strict-Transport-Security: max-age=15768000 | ||
X-XSS-Protection: 1; mode=block | ||
|
||
{"meta":{"next":null,"next_uri":null,"total":3},"entries":[{"id":3189,"first_name":"Andrew","last_name":"Schofield","timezone":"Edinburgh","email":"[email protected]","created_at":"2014/04/22 11:16:17 +0100","updated_at":"2014/08/12 15:37:39 +0100","is_admin":false},{"id":3184,"first_name":"Mark","last_name":"Beech","timezone":"Edinburgh","email":"[email protected]","created_at":"2014/04/22 09:42:12 +0100","updated_at":"2015/08/12 13:41:08 +0100","is_admin":true},{"id":13818,"first_name":"Max","last_name":"King","timezone":"Edinburgh","email":"[email protected]","created_at":"2015/01/14 09:13:30 +0000","updated_at":"2015/02/23 15:29:25 +0000","is_admin":false}]} |