holidayapi-php/tests/RequestTest.php
Josh Sherman b125e70f31
feat: include all endpoints
* Reworked interfacing to drop the versioning in the class name.
* Refactored / cleaned up existing code.
* Stuck with support for PHP 5.3+ since PHP 5.x still seems to hold majority.
* Abstracted request logic to another class for mocking.
* Added test suite and hit full code coverage.
* Updated readme, included migration guide and the full gamut of examples.
* Wired up travis-ci and coveralls for testing and coverage.
2019-10-09 23:55:32 -05:00

45 lines
992 B
PHP

<?php
namespace HolidayAPI\Tests;
use HolidayAPI\Client;
use HolidayAPI\Request;
require __DIR__ . '/../vendor/autoload.php';
if (
!class_exists('\PHPUnit_Framework_TestCase')
&& class_exists('\PHPUnit\Framework\TestCase')
) {
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
}
class RequestTest extends \PHPUnit_Framework_TestCase
{
public function testExecute()
{
$curl = curl_init();
$request = new Request();
$this->assertFalse($request->execute($curl));
}
public function testGet()
{
$url = 'https://holidayapi.com';
$request = new Request(array(
'execute' => array(
$url => function ()
{
return '';
},
),
));
try {
$request->get($url);
} catch (\Exception $e) {
$this->assertRegExp('/empty response/i', $e->getMessage());
}
}
}