1
0
mirror of synced 2025-01-20 04:01:41 +03:00

61 lines
1.5 KiB
PHP
Raw Normal View History

2019-06-10 16:24:22 +03:00
<?php
/**
* PHP version 5.4
*
* Test case class
*
* @package Test
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
namespace RetailCrm\Mg\Bot\Test;
use PHPUnit\Framework\TestCase as BaseCase;
2019-06-17 12:43:54 +03:00
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
2019-06-10 16:24:22 +03:00
use RetailCrm\Mg\Bot\Client;
/**
* Class TestCase
*
* @category RetailCrm
* @package Test
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
class TestCase extends BaseCase
{
/**
* Return bot api client object
*
2019-06-17 12:43:54 +03:00
* @param string $url (default: null)
* @param string $key (default: null)
* @param bool $debug (default: false)
* @param array $response (default: null)
2019-06-10 16:24:22 +03:00
*
2019-06-17 12:43:54 +03:00
* @return Client
2019-06-10 16:24:22 +03:00
*/
public static function getApiClient(
$url = null,
$key = null,
2019-06-17 12:43:54 +03:00
$debug = false,
...$response
2019-06-10 16:24:22 +03:00
) {
$configUrl = getenv('MG_BOT_URL');
$configKey = getenv('MG_BOT_KEY');
$configDbg = getenv('MG_BOT_DBG');
2019-06-17 12:43:54 +03:00
$mock = new MockHandler($response ?: []);
2019-06-10 16:24:22 +03:00
return new Client(
$url ?: $configUrl,
$key ?: $configKey,
2019-06-17 12:43:54 +03:00
$debug ?: $configDbg,
empty($response) ? null : HandlerStack::create($mock)
2019-06-10 16:24:22 +03:00
);
}
}