mirror of
https://github.com/holidayapi/holidayapi-php.git
synced 2025-06-21 04:16:31 +00:00
* 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.
45 lines
992 B
PHP
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());
|
|
}
|
|
}
|
|
}
|
|
|