Skip to content

Commit

Permalink
new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis committed Jul 31, 2016
1 parent 4572ea3 commit 6d44fa9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Options extends JSON
* @var array
*/
protected $_default = array(
'auth' => null,
'auth' => false,
'headers' => array(),
'driver' => self::DEFAULT_DRIVER,
'timeout' => self::DEFAULT_TIMEOUT,
Expand Down Expand Up @@ -64,7 +64,7 @@ public function __construct($data = array())
*/
public function getAuth()
{
return $this->get('auth', array('', ''));
return $this->get('auth', false);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/DriverAutoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function setUp()
parent::setUp();

if ($this->_isPHP53()) {
$this->_methods = array('get', 'post', 'post', 'put');
$this->_methods = array('GET', 'POST', 'PATCH', 'PUT'); // TODO add 'DELETE'
}
}
}
2 changes: 1 addition & 1 deletion tests/DriverRmccueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ class RmccueDriverTest extends DriverTest
{
protected $_driver = 'Rmccue';

protected $_methods = array('get', 'post', 'post', 'put'); // TODO add 'delete'
protected $_methods = array('GET', 'POST', 'PATCH', 'PUT'); // TODO add 'DELETE'
}
18 changes: 13 additions & 5 deletions tests/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class DriverTest extends PHPUnit
/**
* @var array
*/
protected $_methods = array('get', 'post', 'post', 'put', 'delete');
protected $_methods = array('GET', 'POST', 'PATCH', 'PUT', 'DELETE');

/**
* @return bool
Expand Down Expand Up @@ -101,21 +101,29 @@ public function testAllMethods()
foreach ($this->_methods as $method) {

$uniq = uniqid();
$url = 'http://httpbin.org/' . $method;
$url = 'http://mockbin.org/request?method=' . $method . '&qwerty=remove_me';
$args = array('qwerty' => $uniq);
$message = 'Method: ' . $method;

$result = $this->_getClient()->request($url, $args, $method);
$body = $result->getJSON();

if (!$result->getCode()) {
var_dump($result->getBody());
}

isSame(200, $result->getCode(), $message);
isContain('application/json', $result->getHeader('Content-Type'), $message);
isSame($method, $body->find('queryString.method'), $message);
isSame($method, $body->find('method'), $message);

if ($method === 'GET') {
isContain(Url::addArg($args, $url), $body->find('url'), $message);
isSame($uniq, $body->find('queryString.qwerty'), $message);

if ($method === 'get') {
isSame($uniq, $body->find('args.qwerty'), $message);
} else {
isContain($url, $body->find('url'), $message);
isSame($uniq, $body->find('form.qwerty'), $message);
isSame($uniq, $body->find('postData.params.qwerty'), $message);
}
}
}
Expand Down

0 comments on commit 6d44fa9

Please sign in to comment.