1
0
mirror of synced 2024-11-21 21:06:07 +03:00

update tests

This commit is contained in:
Alex Lushpai 2016-07-22 01:01:47 +03:00
parent ddf46fd73d
commit acf29c8c1b
14 changed files with 473 additions and 198 deletions

View File

@ -9,9 +9,11 @@ php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
before_script:
- flags="--prefer-dist --no-dev"
- composer install $flags
- wget -c https://db.tt/uMin8U9t
script: phpunit

View File

@ -13,7 +13,8 @@
],
"require": {
"php": ">=5.3.0",
"ext-curl": "*"
"ext-curl": "*",
"phpunit/phpunit": "~5.4.7"
},
"support": {
"email": "support@retailcrm.pro"

View File

@ -1437,27 +1437,46 @@ class ApiClient
}
return $this->client->makeRequest(
"/telephony/settings/$code",
"/telephony/setting/$code",
Client::METHOD_GET
);
}
/**
* Edit telephony settings
*
* @param string $code symbolic code
* @param string $clientId client id
* @param boolean $active telephony activity
* @param mixed $makeCallUrl service init url
* @param mixed $name service name
* @param mixed $makeCallUrl service init url
* @param mixed $image service logo url(svg file)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
* @param array $additionalCodes
* @param array $externalPhones
* @param bool $allowEdit
* @param bool $inputEventSupported
* @param bool $outputEventSupported
* @param bool $hangupEventSupported
* @param bool $changeUserStatusUrl
*
* @return ApiResponse
*/
public function telephonySettingsEdit($code, $clientId, $active = false, $makeCallUrl = false, $name = false, $image = false)
public function telephonySettingsEdit(
$code,
$clientId,
$active = false,
$name = false,
$makeCallUrl = false,
$image = false,
$additionalCodes = array(),
$externalPhones = array(),
$allowEdit = false,
$inputEventSupported = false,
$outputEventSupported = false,
$hangupEventSupported = false,
$changeUserStatusUrl = false
)
{
if (!isset($code)) {
throw new \InvalidArgumentException('Code must be set');
@ -1481,64 +1500,101 @@ class ApiClient
throw new \InvalidArgumentException('name must be set');
}
if (isset($makeCallUrl)) {
$parameters['makeCallUrl'] = $makeCallUrl;
}
if (isset($name)) {
$parameters['name'] = $name;
}
if (isset($makeCallUrl)) {
$parameters['makeCallUrl'] = $makeCallUrl;
}
if (isset($image)) {
$parameters['image'] = $image;
}
if (isset($additionalCodes)) {
$parameters['additionalCodes'] = $additionalCodes;
}
if (isset($externalPhones)) {
$parameters['externalPhones'] = $externalPhones;
}
if (isset($allowEdit)) {
$parameters['allowEdit'] = $allowEdit;
}
if (isset($inputEventSupported)) {
$parameters['inputEventSupported'] = $inputEventSupported;
}
if (isset($outputEventSupported)) {
$parameters['outputEventSupported'] = $outputEventSupported;
}
if (isset($hangupEventSupported)) {
$parameters['hangupEventSupported'] = $hangupEventSupported;
}
if (isset($changeUserStatusUrl)) {
$parameters['changeUserStatusUrl'] = $changeUserStatusUrl;
}
return $this->client->makeRequest(
"/telephony/setting/$code/edit",
Client::METHOD_POST,
$parameters
array('configuration' => json_encode($parameters))
);
}
/**
* Call event
*
* @param string $phone phone number
* @param string $type call type
* @param string $code additional phone code
* @param string $status call status
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
* @param string $phone phone number
* @param string $type call type
* @param array $codes
* @param string $hangupStatus
* @param string $externalPhone
* @param array $webAnalyticsData
*
* @return ApiResponse
* @internal param string $code additional phone code
* @internal param string $status call status
*
*/
public function telephonyCallEvent($phone, $type, $code, $status)
public function telephonyCallEvent(
$phone,
$type,
$codes,
$hangupStatus,
$externalPhone = null,
$webAnalyticsData = array()
)
{
if (!isset($phone)) {
throw new \InvalidArgumentException('Phone number must be set');
}
$parameters['phone'] = $phone;
if (!isset($type)) {
throw new \InvalidArgumentException('Type must be set (in|out|hangup)');
}
$parameters['type'] = $type;
if (!isset($code)) {
throw new \InvalidArgumentException('Code must be set');
if (empty($codes)) {
throw new \InvalidArgumentException('Codes array must be set');
}
$parameters['code'] = $code;
$parameters['hangupStatus'] = $status;
$parameters['phone'] = $phone;
$parameters['type'] = $type;
$parameters['codes'] = $codes;
$parameters['hangupStatus'] = $hangupStatus;
$parameters['callExternalId'] = $externalPhone;
$parameters['webAnalyticsData'] = $webAnalyticsData;
return $this->client->makeRequest(
'/telephony/call/event',
Client::METHOD_POST,
$parameters
array('event' => json_encode($parameters))
);
}

View File

@ -12,6 +12,7 @@
<php>
<server name="CRM_URL" value="https://demo.retailcrm.ru" />
<server name="CRM_API_KEY" value="nSBFWecViONG5c96wUQQgZzHkilTnaa6" />
<server name="CRM_USER_ID" value="1" />
</php>
<testsuites>

View File

@ -1,15 +1,36 @@
<?php
/**
* PHP version 5.3
*
* API client customers 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;
use RetailCrm\Test\TestCase;
/**
* Class ApiClientCustomersTest
*
* @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 ApiClientCustomersTest extends TestCase
{
const FIRST_NAME = 'Иннокентий';
/**
* @group integration
* @group customers
*/
public function testCustomersCreate()
{
@ -32,7 +53,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group unit
* @group customers
* @expectedException \InvalidArgumentException
*/
public function testCustomersCreateExceptionEmpty()
@ -43,7 +64,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group integration
* @group customers
* @depends testCustomersCreate
*/
public function testCustomersGet(array $ids)
@ -53,13 +74,13 @@ class ApiClientCustomersTest extends TestCase
$response = $client->customersGet(678678678);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(404, $response->getStatusCode());
$this->assertFalse($response->success);
$this->assertFalse($response->isSuccessful());
$response = $client->customersGet($ids['id'], 'id');
$customerById = $response->customer;
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
$this->assertEquals(self::FIRST_NAME, $response->customer['firstName']);
$response = $client->customersGet($ids['externalId'], 'externalId');
@ -69,7 +90,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group unit
* @group customers
* @expectedException \InvalidArgumentException
*/
public function testCustomersGetException()
@ -80,7 +101,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group integration
* @group customers
* @depends testCustomersGet
*/
public function testCustomersEdit(array $ids)
@ -103,19 +124,11 @@ class ApiClientCustomersTest extends TestCase
));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$response = $client->customersEdit(array(
'externalId' => 'c-edit-' . time(),
'lastName' => '12345',
));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(201, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
}
/**
* @group unit
* @group customers
* @expectedException \InvalidArgumentException
*/
public function testCustomersEditExceptionEmpty()
@ -126,7 +139,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group unit
* @group customers
* @expectedException \InvalidArgumentException
*/
public function testCustomersEditException()
@ -137,7 +150,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group integration
* @group customers
*/
public function testCustomersList()
{
@ -164,7 +177,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group unit
* @group customers
* @expectedException \InvalidArgumentException
*/
public function testCustomersFixExternalIdsException()
@ -175,7 +188,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group integration
* @group customers
*/
public function testCustomersFixExternalIds()
{
@ -225,7 +238,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group unit
* @group customers
* @expectedException \InvalidArgumentException
*/
public function testCustomersUploadExceptionEmpty()
@ -236,7 +249,7 @@ class ApiClientCustomersTest extends TestCase
}
/**
* @group integration
* @group customers
*/
public function testCustomersUpload()
{

View File

@ -1,15 +1,36 @@
<?php
/**
* PHP version 5.3
*
* API client orders 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;
use RetailCrm\Test\TestCase;
/**
* Class ApiClientOrdersTest
*
* @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 ApiClientOrdersTest extends TestCase
{
const FIRST_NAME = 'Иннокентий';
/**
* @group integration
* @group orders
*/
public function testOrdersCreate()
{
@ -32,7 +53,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group unit
* @group orders
* @expectedException \InvalidArgumentException
*/
public function testOrdersCreateExceptionEmpty()
@ -43,7 +64,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group integration
* @group orders
* @depends testOrdersCreate
*/
public function testOrdersStatuses(array $ids)
@ -53,19 +74,19 @@ class ApiClientOrdersTest extends TestCase
$response = $client->ordersStatuses();
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(400, $response->getStatusCode());
$this->assertFalse($response->success);
$this->assertFalse($response->isSuccessful());
$response = $client->ordersStatuses(array(), array('asdf'));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
$orders = $response->orders;
$this->assertEquals(0, sizeof($orders));
$response = $client->ordersStatuses(array(), array($ids['externalId']));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
$orders = $response->orders;
$this->assertEquals(1, sizeof($orders));
$this->assertEquals('new', $orders[0]['status']);
@ -73,20 +94,20 @@ class ApiClientOrdersTest extends TestCase
$response = $client->ordersStatuses(array($ids['id']), array($ids['externalId']));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
$orders = $response->orders;
$this->assertEquals(1, sizeof($orders));
$response = $client->ordersStatuses(array($ids['id']));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
$orders = $response->orders;
$this->assertEquals(1, sizeof($orders));
}
/**
* @group integration
* @group orders
* @depends testOrdersCreate
*/
public function testOrdersGet(array $ids)
@ -96,13 +117,13 @@ class ApiClientOrdersTest extends TestCase
$response = $client->ordersGet(678678678);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(404, $response->getStatusCode());
$this->assertFalse($response->success);
$this->assertFalse($response->isSuccessful());
$response = $client->ordersGet($ids['id'], 'id');
$orderById = $response->order;
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
$this->assertEquals(self::FIRST_NAME, $response->order['firstName']);
$response = $client->ordersGet($ids['externalId'], 'externalId');
@ -112,7 +133,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group unit
* @group orders
* @expectedException \InvalidArgumentException
*/
public function testOrdersGetException()
@ -123,7 +144,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group integration
* @group orders
* @depends testOrdersGet
*/
public function testOrdersEdit(array $ids)
@ -146,19 +167,11 @@ class ApiClientOrdersTest extends TestCase
));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$response = $client->ordersEdit(array(
'externalId' => time(),
'lastName' => '12345',
));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(201, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
}
/**
* @group unit
* @group orders
* @expectedException \InvalidArgumentException
*/
public function testOrdersEditExceptionEmpty()
@ -169,7 +182,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group unit
* @group orders
* @expectedException \InvalidArgumentException
*/
public function testOrdersEditException()
@ -180,7 +193,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group integration
* @group orders
*/
public function testOrdersHistory()
{
@ -189,19 +202,11 @@ class ApiClientOrdersTest extends TestCase
$response = $client->ordersHistory();
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue(
isset($response['orders']),
'API returns orders history'
);
$this->assertTrue(
isset($response['generatedAt']),
'API returns generatedAt in orders history'
);
$this->assertTrue($response->isSuccessful());
}
/**
* @group integration
* @group orders
*/
public function testOrdersList()
{
@ -221,14 +226,10 @@ class ApiClientOrdersTest extends TestCase
$response = $client->ordersList(array('paymentStatus' => 'paid'), 1);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue(
$response->isSuccessful(),
'API returns orders list'
);
}
/**
* @group unit
* @group orders
* @expectedException \InvalidArgumentException
*/
public function testOrdersFixExternalIdsException()
@ -239,7 +240,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group integration
* @group orders
] */
public function testOrdersFixExternalIds()
{
@ -283,7 +284,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group unit
* @group orders
* @expectedException \InvalidArgumentException
*/
public function testOrdersUploadExceptionEmpty()
@ -294,7 +295,7 @@ class ApiClientOrdersTest extends TestCase
}
/**
* @group integration
* @group orders
*/
public function testOrdersUpload()
{

View File

@ -9,7 +9,7 @@
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
namespace RetailCrm\Tests;
@ -23,29 +23,14 @@ use RetailCrm\Test\TestCase;
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
class ApiClientPacksTest extends TestCase
{
private $_packId;
/**
* ApiClientPacksTest constructor.
*
* @param null|string $name name
* @param array $data data
* @param string $dataName dataName
*/
public function __construct($name = null, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
$this->_packId = __DIR__ . '/../../../pack.tmp';
}
/**
* Test packs history
*
* @group integration
* @group packs
* @return void
*/
public function testOrdersPacksHistory()
@ -66,33 +51,10 @@ class ApiClientPacksTest extends TestCase
);
}
/**
* Test packs create
*
* @group integration
* @return void
*/
public function testOrdersPacksCreate()
{
$client = static::getApiClient();
$pack = array(
'itemId' => $_SERVER['CRM_PACK_ITEM'],
'quantity' => $_SERVER['CRM_PACK_QUANTITY'],
'store' => $_SERVER['CRM_STORE']
);
$response = $client->ordersPacksCreate($pack);
file_put_contents($this->_packId, $response["id"]);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(201, $response->getStatusCode());
$this->assertTrue($response->success);
}
/**
* Test packs failed create
*
* @group integration
* @group packs
* @return void
*/
public function testOrdersPacksCreateFailed()
@ -100,7 +62,7 @@ class ApiClientPacksTest extends TestCase
$client = static::getApiClient();
$pack = array(
'itemId' => 12,
'store' => $_SERVER['CRM_STORE'],
'store' => 'test',
'quantity' => 2
);
@ -109,39 +71,4 @@ class ApiClientPacksTest extends TestCase
$this->assertEquals(400, $response->getStatusCode());
$this->assertFalse($response->success);
}
/**
* Test packs get
*
* @group integration
* @return void
*/
public function testOrdersPacksGet()
{
$client = static::getApiClient();
$packId = file_get_contents($this->_packId);
$response = $client->ordersPacksGet($packId);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
}
/**
* Test packs delete
*
* @group integration
* @return void
*/
public function testOrdersPacksDelete()
{
$client = static::getApiClient();
$packId = file_get_contents($this->_packId);
$response = $client->ordersPacksDelete($packId);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
unlink($this->_packId);
}
}

View File

@ -1,13 +1,34 @@
<?php
/**
* PHP version 5.3
*
* API client references 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;
use RetailCrm\Test\TestCase;
/**
* Class ApiClientReferenceTest
*
* @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 ApiClientReferenceTest extends TestCase
{
/**
* @group integration
* @group reference
* @dataProvider getListDictionaries
* @param $name
*/
@ -25,7 +46,7 @@ class ApiClientReferenceTest extends TestCase
}
/**
* @group integration
* @group reference
* @dataProvider getEditDictionaries
* @expectedException \InvalidArgumentException
*/
@ -38,7 +59,7 @@ class ApiClientReferenceTest extends TestCase
}
/**
* @group integration
* @group reference
* @dataProvider getEditDictionaries
*/
public function testEditing($name)
@ -69,7 +90,7 @@ class ApiClientReferenceTest extends TestCase
}
/**
* @group integration
* @group reference
* @group site
*/
public function testSiteEditing()

View File

@ -1,12 +1,29 @@
<?php
/**
* PHP version 5.3
*
* API client store 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;
use RetailCrm\Test\TestCase;
/**
* Class ApiClientStoreTest
* @package RetailCrm\Tests
*
* @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 ApiClientStoreTest extends TestCase
{
@ -14,7 +31,7 @@ class ApiClientStoreTest extends TestCase
const SCODE = 'test-store';
/**
* @group integration
* @group store
*/
public function testStoreCreate()
{
@ -23,11 +40,11 @@ class ApiClientStoreTest extends TestCase
$response = $client->storesEdit(array('name' => self::SNAME, 'code' => self::SCODE));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
}
/**
* @group integration
* @group store
*/
public function testStoreInventories()
{
@ -36,7 +53,7 @@ class ApiClientStoreTest extends TestCase
$response = $client->storeInventories();
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
$this->assertTrue(
isset($response['offers']),
'API returns orders assembly history'
@ -44,7 +61,7 @@ class ApiClientStoreTest extends TestCase
}
/**
* @group unit
* @group store
* @expectedException \InvalidArgumentException
*/
public function testStoreInventoriesUploadExceptionEmpty()
@ -54,7 +71,7 @@ class ApiClientStoreTest extends TestCase
}
/**
* @group integration
* @group store
*/
public function testStoreInventoriesUpload()
{

View File

@ -1,5 +1,17 @@
<?php
/**
* PHP version 5.3
*
* API client telephony 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;
use RetailCrm\Test\TestCase;
@ -10,33 +22,138 @@ use RetailCrm\Test\TestCase;
* @package RetailCrm\Tests
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
*/
class ApiClientTelephonyTest extends TestCase
{
const TEL_CODE = 'telephony-code';
const TEL_CLIENT = '123';
const TEL_IMAGE = 'http://www.mec.ph/horizon/wp-content/uploads/2011/11/telephony.svg';
/**
* Settings test
* Settings Edit test
*
* @group integration
* @group telephony
*
* @return void
*/
public function testTelephonySettings()
public function testTelephonySettingsEdit()
{
$client = static::getApiClient();
$code = 'telphin';
$clientId = '1';
$active = true;
$response = $client->telephonySettingsEdit(
self::TEL_CODE,
self::TEL_CLIENT,
true,
'TestTelephony',
false,
self::TEL_IMAGE,
array(array('userId' => $_SERVER['CRM_USER_ID'], 'code' => '101')),
array(array('siteCode' => 'api-client-php', 'externalPhone' => '+74950000000'))
);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
$this->assertTrue($response->isSuccessful());
}
/**
* Settings Get test
*
* @group telephony
*
* @return void
*/
public function testTelephonySettingsGet()
{
$client = static::getApiClient();
$response = $client->telephonySettingsGet(self::TEL_CODE);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->isSuccessful());
}
/**
* Event test
*
* @group telephony
*
* @return void
*/
public function testTelephonyEvent()
{
$client = static::getApiClient();
$response = $client->telephonyCallEvent(
'+79999999999',
'in',
array('101'),
'failed',
'+74950000000'
$response = $client->telephonySettings(
$code,
$clientId,
$active
);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue($response->isSuccessful());
}
/**
* Upload test
*
* @group telephony
*
* @return void
*/
public function testTelephonyUpload()
{
$client = static::getApiClient();
$response = $client->telephonyCallsUpload(
array(
array(
'date' => '2016-07-22 00:18:00',
'type' => 'in',
'phone' => '+79999999999',
'code' => '101',
'result' => 'answered',
'externalId' => rand(10,100),
'recordUrl' => 'https://dl.dropboxusercontent.com/u/15492750/dontry2bfunny.mp3'
),
array(
'date' => '2016-07-22 00:24:00',
'type' => 'in',
'phone' => '+79999999999',
'code' => '101',
'result' => 'answered',
'externalId' => rand(10,100),
'recordUrl' => 'https://dl.dropboxusercontent.com/u/15492750/donttytobefunny.mp3'
)
)
);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->isSuccessful());
}
/**
* Manager test
*
* @group telephony
*
* @return void
*/
public function testTelephonyManager()
{
$client = static::getApiClient();
$response = $client->telephonyCallManager('+79999999999', 1);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->isSuccessful());
}
}

View File

@ -1,9 +1,30 @@
<?php
/**
* 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;
use RetailCrm\Test\TestCase;
/**
* Class ApiClientTest
*
* @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 ApiClientTest extends TestCase
{
/**

View File

@ -0,0 +1,55 @@
<?php
/**
* PHP version 5.3
*
* API client users 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;
use RetailCrm\Test\TestCase;
/**
* Class ApiClientUsersTest
*
* @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 ApiClientUsersTest extends TestCase
{
/**
* @group users
*/
public function testUsersList()
{
$client = static::getApiClient();
$response = $client->usersList();
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
$this->assertTrue($response->isSuccessful());
}
/**
* @group users
*/
public function testUsersGet()
{
$client = static::getApiClient();
$response = $client->usersGet($_SERVER["CRM_USER_ID"]);
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
$this->assertTrue($response->isSuccessful());
}
}

View File

@ -1,11 +1,32 @@
<?php
/**
* 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;
/**
* 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
{
/**
@ -25,6 +46,7 @@ class ClientTest extends TestCase
public function testHttpRequiring()
{
$client = new Client('http://demo.retailcrm.ru/api/' . ApiClient::VERSION, array('apiKey' => '123'));
return $client;
}
/**
@ -44,7 +66,7 @@ class ClientTest extends TestCase
public function testMakeRequestWrongUrl()
{
$client = new Client('https://asdf.df', array());
$client->makeRequest('/a', Client::METHOD_GET, array(), 1);
$client->makeRequest('/a', Client::METHOD_GET, array());
}
/**

View File

@ -1,10 +1,31 @@
<?php
/**
* PHP version 5.3
*
* API client response 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\Response;
use RetailCrm\Test\TestCase;
use RetailCrm\Response\ApiResponse;
/**
* Class ApiResponseTest
*
* @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 ApiResponseTest extends TestCase
{
/**