1
0
mirror of synced 2024-11-23 22:06:09 +03:00
api-client-php/tests/RetailCrm/Tests/Http/ClientTest.php

84 lines
2.0 KiB
PHP
Raw Permalink Normal View History

<?php
2016-07-22 01:01:47 +03:00
/**
* PHP version 5.3
*
* API client test class
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
namespace RetailCrm\Tests\Http;
use RetailCrm\Test\TestCase;
use RetailCrm\ApiClient;
use RetailCrm\Http\Client;
2016-07-22 01:01:47 +03:00
/**
* Class ClientTest
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
class ClientTest extends TestCase
{
/**
* @group unit
*/
public function testConstruct()
{
$client = new Client('https://asdf.df', array());
$this->assertInstanceOf('RetailCrm\Http\Client', $client);
}
/**
* @group unit
* @expectedException \InvalidArgumentException
*/
public function testHttpRequiring()
{
$client = new Client('http://demo.retailcrm.ru/api/' . ApiClient::VERSION, array('apiKey' => '123'));
2016-07-22 01:01:47 +03:00
return $client;
}
/**
* @group unit
* @expectedException \InvalidArgumentException
*/
public function testMakeRequestWrongMethod()
{
$client = static::getClient();
$client->makeRequest('/a', 'adsf');
}
/**
* @group integration
* @expectedException \RetailCrm\Exception\CurlException
*/
public function testMakeRequestWrongUrl()
{
$client = new Client('https://asdf.df', array());
2016-07-22 01:01:47 +03:00
$client->makeRequest('/a', Client::METHOD_GET, array());
}
/**
* @group integration
*/
public function testMakeRequestSuccess()
{
$client = static::getClient();
2014-11-06 03:18:39 +03:00
$response = $client->makeRequest('/orders', Client::METHOD_GET);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
}
}