2014-11-06 02:44:52 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace RetailCrm\Test;
|
|
|
|
|
|
|
|
use RetailCrm\ApiClient;
|
2015-05-04 18:47:14 +03:00
|
|
|
use RetailCrm\Http\Client;
|
2014-11-06 02:44:52 +03:00
|
|
|
|
|
|
|
class TestCase extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Return ApiClient object
|
|
|
|
*
|
|
|
|
* @param string $url (default: null)
|
|
|
|
* @param string $apiKey (default: null)
|
2014-11-27 11:23:44 +03:00
|
|
|
* @param string $site (default: null)
|
2014-11-06 02:44:52 +03:00
|
|
|
* @return ApiClient
|
|
|
|
*/
|
2014-11-27 11:23:44 +03:00
|
|
|
public static function getApiClient($url = null, $apiKey = null, $site = null)
|
2014-11-06 02:44:52 +03:00
|
|
|
{
|
2014-11-27 11:23:44 +03:00
|
|
|
return new ApiClient(
|
|
|
|
$url ?: $_SERVER['CRM_URL'],
|
|
|
|
$apiKey ?: $_SERVER['CRM_API_KEY'],
|
|
|
|
$site ?: (isset($_SERVER['CRM_SITE']) ? $_SERVER['CRM_SITE'] : null)
|
|
|
|
);
|
2014-11-06 02:44:52 +03:00
|
|
|
}
|
2015-05-04 18:47:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return Client object
|
|
|
|
*
|
|
|
|
* @param string $url (default: null)
|
|
|
|
* @param string $apiKey (default: null)
|
|
|
|
* @return Client
|
|
|
|
*/
|
|
|
|
public static function getClient($url = null, $defaultParameters = array())
|
|
|
|
{
|
|
|
|
return new Client(
|
|
|
|
$url ?: $_SERVER['CRM_URL'] . '/api/' . ApiClient::VERSION,
|
|
|
|
array('apiKey' => isset($defaultParameters['apiKey']) ? $defaultParameters['apiKey'] : $_SERVER['CRM_API_KEY'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|