From fdd7c3d4c80212852eab23588bc61aacb3e77d8c Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Mon, 12 Jun 2017 23:58:56 +0300 Subject: [PATCH] V5 (#37) * update tests * update version to 5.0.0, combine methods for orders & customer, update status method for users, custom fields|dictionaries & task methods, segments & product groups list methods, orders payments --- .travis.yml | 5 +- README.md | 4 +- README.ru.md | 2 +- composer.json | 9 +- lib/RetailCrm/ApiClient.php | 558 +++++++++++++++++- lib/RetailCrm/Exception/CurlException.php | 4 +- .../Exception/InvalidJsonException.php | 4 +- lib/RetailCrm/Http/Client.php | 4 +- lib/RetailCrm/Response/ApiResponse.php | 4 +- tests/RetailCrm/Test/TestCase.php | 19 +- .../Tests/ApiClientCustomersTest.php | 168 ++++-- .../Tests/ApiClientMarketplaceTest.php | 15 +- tests/RetailCrm/Tests/ApiClientOrdersTest.php | 251 +++++--- tests/RetailCrm/Tests/ApiClientPacksTest.php | 24 +- tests/RetailCrm/Tests/ApiClientPricesTest.php | 26 +- .../Tests/ApiClientReferenceTest.php | 52 +- tests/RetailCrm/Tests/ApiClientStoreTest.php | 67 ++- tests/RetailCrm/Tests/ApiClientTasksTest.php | 84 +++ .../Tests/ApiClientTelephonyTest.php | 42 +- tests/RetailCrm/Tests/ApiClientTest.php | 6 +- tests/RetailCrm/Tests/ApiClientUsersTest.php | 29 +- tests/RetailCrm/Tests/Http/ClientTest.php | 16 +- .../Tests/Response/ApiResponseTest.php | 4 +- 23 files changed, 1121 insertions(+), 276 deletions(-) create mode 100644 tests/RetailCrm/Tests/ApiClientTasksTest.php diff --git a/.travis.yml b/.travis.yml index 703cb27..37b543d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,15 @@ cache: - $HOME/.composer/cache php: + - '5.3' - '5.4' - '5.5' - '5.6' - '7.0' before_script: - - flags="--prefer-dist --no-dev" + - flags="--prefer-dist --no-dev -o" - composer install $flags - - wget -c -O phpunit.xml https://db.tt/uMin8U9t + - wget -c -O phpunit.xml https://goo.gl/yZHStN script: phpunit diff --git a/README.md b/README.md index b352208..2ff0553 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # retailCRM API PHP client -PHP-client for [retailCRM API](http://www.retailcrm.pro/docs/Developers/ApiVersion4). +PHP-client for [retailCRM API](http://www.retailcrm.pro/docs/Developers/ApiVersion5). Use [API documentation](http://retailcrm.github.io/api-client-php) @@ -28,7 +28,7 @@ require 'path/to/vendor/autoload.php'; ### Get order ```php $client = new \RetailCrm\ApiClient( - 'https://demo.retailcrm.pro', + 'https://demo.retailcrm.ru', 'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH' ); diff --git a/README.ru.md b/README.ru.md index c262ab0..4ef56fa 100644 --- a/README.ru.md +++ b/README.ru.md @@ -1,6 +1,6 @@ # PHP-клиент для retailCRM API -PHP-клиент для работы с [retailCRM API](http://www.retailcrm.ru/docs/Developers/ApiVersion4). +PHP-клиент для работы с [retailCRM API](http://www.retailcrm.ru/docs/Developers/ApiVersion5). Рекомендуем обращаться к [документации](http://retailcrm.github.io/api-client-php) по библиотеке, в частности по классу [RetailCrm\ApiClient](http://retailcrm.github.io/api-client-php/class-RetailCrm.ApiClient.html). diff --git a/composer.json b/composer.json index 37b63a0..135ed47 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "PHP client for retailCRM API", "type": "library", "keywords": ["API", "retailCRM", "REST"], - "homepage": "http://www.retailcrm.pro/", + "homepage": "http://www.retailcrm.ru/", "license": "MIT", "authors": [ { @@ -16,17 +16,18 @@ "ext-curl": "*" }, "require-dev": { - "phpunit/phpunit": "4.8.29" + "phpunit/phpunit": "5.*", + "squizlabs/php_codesniffer": "3.*" }, "support": { - "email": "support@retailcrm.pro" + "email": "support@retailcrm.ru" }, "autoload": { "psr-0": { "RetailCrm\\": "lib/" } }, "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "5.x-dev" } }, "config": { diff --git a/lib/RetailCrm/ApiClient.php b/lib/RetailCrm/ApiClient.php index 22fd304..e8a3678 100644 --- a/lib/RetailCrm/ApiClient.php +++ b/lib/RetailCrm/ApiClient.php @@ -9,11 +9,12 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm; +use function json_encode; use RetailCrm\Http\Client; use RetailCrm\Response\ApiResponse; @@ -26,12 +27,12 @@ use RetailCrm\Response\ApiResponse; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClient { - const VERSION = 'v4'; + const VERSION = 'v5'; protected $client; @@ -140,6 +141,31 @@ class ApiClient return $this->client->makeRequest("/users/$id", Client::METHOD_GET); } + /** + * Change user status + * + * @param integer $id user ID + * @param string $status user status + * + * @return ApiResponse + */ + public function usersStatus($id, $status) + { + $statuses = array("free", "busy", "dinner", "break"); + + if (empty($status) || !in_array($status, $statuses)) { + throw new \InvalidArgumentException( + 'Parameter `status` must be not empty & must be equal one of these values: free|busy|dinner|break' + ); + } + + return $this->client->makeRequest( + "/users/$id/status", + Client::METHOD_POST, + array('status' => $status) + ); + } + /** * Returns filtered orders list * @@ -175,7 +201,43 @@ class ApiClient } /** - * Create a order + * Combine orders + * + * @param string $technique + * @param array $order + * @param array $resultOrder + * + * @return ApiResponse + */ + public function ordersCombine($order, $resultOrder, $technique = 'ours') + { + $techniques = array('ours', 'summ', 'theirs'); + + if (!count($order) || !count($resultOrder)) { + throw new \InvalidArgumentException( + 'Parameters `order` & `resultOrder` must contains a data' + ); + } + + if (!in_array($technique, $techniques)) { + throw new \InvalidArgumentException( + 'Parameter `technique` must be on of ours|summ|theirs' + ); + } + + return $this->client->makeRequest( + '/orders/combine', + Client::METHOD_POST, + array( + 'technique' => $technique, + 'order' => json_encode($order), + 'resultOrder' => json_encode($resultOrder) + ) + ); + } + + /** + * Create an order * * @param array $order order data * @param string $site (default: null) @@ -202,7 +264,7 @@ class ApiClient } /** - * Save order IDs' (id and externalId) association in the CRM + * Save order IDs' (id and externalId) association into CRM * * @param array $ids order identificators * @@ -310,7 +372,7 @@ class ApiClient } /** - * Edit a order + * Edit an order * * @param array $order order data * @param string $by (default: 'externalId') @@ -377,6 +439,67 @@ class ApiClient ); } + /** + * Create an order payment + * + * @param array $payment order data + * + * @throws \InvalidArgumentException + * @throws \RetailCrm\Exception\CurlException + * @throws \RetailCrm\Exception\InvalidJsonException + * + * @return ApiResponse + */ + public function ordersPaymentCreate(array $payment) + { + if (!count($payment)) { + throw new \InvalidArgumentException( + 'Parameter `payment` must contains a data' + ); + } + + return $this->client->makeRequest( + '/orders/payments/create', + Client::METHOD_POST, + array('payment' => json_encode($payment)) + ); + } + + /** + * Edit an order payment + * + * @param array $payment order data + * @param string $by by key + * @param null $site site code + * + * @return ApiResponse + */ + public function ordersPaymentEdit(array $payment, $by = 'externalId', $site = null) + { + if (!count($payment)) { + throw new \InvalidArgumentException( + 'Parameter `payment` must contains a data' + ); + } + + $this->checkIdParameter($by); + + if (!array_key_exists($by, $payment)) { + throw new \InvalidArgumentException( + sprintf('Order array must contain the "%s" parameter.', $by) + ); + } + + return $this->client->makeRequest( + sprintf('/orders/payments/%s/edit', $payment[$by]), + Client::METHOD_POST, + $this->fillSite( + $site, + array('payment' => json_encode($payment), 'by' => $by) + ) + ); + } + /** * Returns filtered customers list * @@ -411,6 +534,33 @@ class ApiClient ); } + /** + * Combine customers + * + * @param array $customers + * @param array $resultCustomer + * + * @return ApiResponse + */ + public function customersCombine(array $customers, $resultCustomer) + { + + if (!count($customers) || !count($resultCustomer)) { + throw new \InvalidArgumentException( + 'Parameters `customers` & `resultCustomer` must contains a data' + ); + } + + return $this->client->makeRequest( + '/customers/combine', + Client::METHOD_POST, + array( + 'customers' => json_encode($customers), + 'resultCustomer' => json_encode($resultCustomer) + ) + ); + } + /** * Create a customer * @@ -923,6 +1073,40 @@ class ApiClient ); } + /** + * Get products groups + * + * @param array $filter (default: array()) + * @param int $page (default: null) + * @param int $limit (default: null) + * + * @throws \InvalidArgumentException + * @throws \RetailCrm\Exception\CurlException + * @throws \RetailCrm\Exception\InvalidJsonException + * + * @return ApiResponse + */ + public function storeProductsGroups(array $filter = array(), $page = null, $limit = null) + { + $parameters = array(); + + if (count($filter)) { + $parameters['filter'] = $filter; + } + if (null !== $page) { + $parameters['page'] = (int) $page; + } + if (null !== $limit) { + $parameters['limit'] = (int) $limit; + } + + return $this->client->makeRequest( + '/store/product-groups', + Client::METHOD_GET, + $parameters + ); + } + /** * Get delivery settings * @@ -1578,8 +1762,7 @@ class ApiClient $outputEventSupported = false, $hangupEventSupported = false, $changeUserStatusUrl = false - ) - { + ) { if (!isset($code)) { throw new \InvalidArgumentException('Code must be set'); } @@ -1671,8 +1854,7 @@ class ApiClient $hangupStatus, $externalPhone = null, $webAnalyticsData = array() - ) - { + ) { if (!isset($phone)) { throw new \InvalidArgumentException('Phone number must be set'); } @@ -1797,6 +1979,362 @@ class ApiClient ); } + /** + * Get custom fields list + * + * @param array $filter + * @param null $limit + * @param null $page + * + * @return ApiResponse + */ + public function customFieldsList(array $filter = array(), $limit = null, $page = null) + { + $parameters = array(); + + if (count($filter)) { + $parameters['filter'] = $filter; + } + if (null !== $page) { + $parameters['page'] = (int) $page; + } + if (null !== $limit) { + $parameters['limit'] = (int) $limit; + } + + return $this->client->makeRequest( + '/custom-fields', + Client::METHOD_GET, + $parameters + ); + } + + /** + * Create custom field + * + * @param $entity + * @param $customField + * + * @return ApiResponse + */ + public function customFieldsCreate($entity, $customField) + { + if (!count($customField) || + empty($customField['code']) || + empty($customField['name']) || + empty($customField['type']) + ) { + throw new \InvalidArgumentException( + 'Parameter `customField` must contain a data & fields `code`, `name` & `type` must be set' + ); + } + + if (empty($entity) || $entity != 'customer' || $entity != 'order') { + throw new \InvalidArgumentException( + 'Parameter `entity` must contain a data & value must be `order` or `customer`' + ); + } + + return $this->client->makeRequest( + "/custom-fields/$entity/create", + Client::METHOD_POST, + array('customField' => json_encode($customField)) + ); + } + + /** + * Edit custom field + * + * @param $entity + * @param $customField + * + * @return ApiResponse + */ + public function customFieldsEdit($entity, $customField) + { + if (!count($customField) || empty($customField['code'])) { + throw new \InvalidArgumentException( + 'Parameter `customField` must contain a data & fields `code` must be set' + ); + } + + if (empty($entity) || $entity != 'customer' || $entity != 'order') { + throw new \InvalidArgumentException( + 'Parameter `entity` must contain a data & value must be `order` or `customer`' + ); + } + + return $this->client->makeRequest( + "/custom-fields/$entity/edit/{$customField['code']}", + Client::METHOD_POST, + array('customField' => json_encode($customField)) + ); + } + + /** + * Get custom field + * + * @param $entity + * @param $code + * + * @return ApiResponse + */ + public function customFieldsGet($entity, $code) + { + if (empty($code)) { + throw new \InvalidArgumentException( + 'Parameter `code` must be not empty' + ); + } + + if (empty($entity) || $entity != 'customer' || $entity != 'order') { + throw new \InvalidArgumentException( + 'Parameter `entity` must contain a data & value must be `order` or `customer`' + ); + } + + return $this->client->makeRequest( + "/custom-fields/$entity/$code", + Client::METHOD_GET + ); + } + + /** + * Get custom dictionaries list + * + * @param array $filter + * @param null $limit + * @param null $page + * + * @return ApiResponse + */ + public function customDictionariesList(array $filter = array(), $limit = null, $page = null) + { + $parameters = array(); + + if (count($filter)) { + $parameters['filter'] = $filter; + } + if (null !== $page) { + $parameters['page'] = (int) $page; + } + if (null !== $limit) { + $parameters['limit'] = (int) $limit; + } + + return $this->client->makeRequest( + '/custom-fields/dictionaries', + Client::METHOD_GET, + $parameters + ); + } + + /** + * Create custom dictionary + * + * @param $customDictionary + * + * @return ApiResponse + */ + public function customDictionariesCreate($customDictionary) + { + if (!count($customDictionary) || + empty($customDictionary['code']) || + empty($customDictionary['elements']) + ) { + throw new \InvalidArgumentException( + 'Parameter `dictionary` must contain a data & fields `code` & `elemets` must be set' + ); + } + + return $this->client->makeRequest( + "/custom-fields/dictionaries/{$customDictionary['code']}/create", + Client::METHOD_POST, + array('customDictionary' => json_encode($customDictionary)) + ); + } + + /** + * Edit custom dictionary + * + * @param $customDictionary + * + * @return ApiResponse + */ + public function customDictionariesEdit($customDictionary) + { + if (!count($customDictionary) || + empty($customDictionary['code']) || + empty($customDictionary['elements']) + ) { + throw new \InvalidArgumentException( + 'Parameter `dictionary` must contain a data & fields `code` & `elemets` must be set' + ); + } + + return $this->client->makeRequest( + "/custom-fields/dictionaries/{$customDictionary['code']}/edit", + Client::METHOD_POST, + array('customDictionary' => json_encode($customDictionary)) + ); + } + + /** + * Get custom dictionary + * + * @param $code + * + * @return ApiResponse + */ + public function customDictionariesGet($code) + { + if (empty($code)) { + throw new \InvalidArgumentException( + 'Parameter `code` must be not empty' + ); + } + + return $this->client->makeRequest( + "/custom-fields/dictionaries/$code", + Client::METHOD_GET + ); + } + + /** + * Get segments list + * + * @param array $filter + * @param null $limit + * @param null $page + * + * @return ApiResponse + */ + public function segmentsList(array $filter = array(), $limit = null, $page = null) + { + $parameters = array(); + + if (count($filter)) { + $parameters['filter'] = $filter; + } + if (null !== $page) { + $parameters['page'] = (int) $page; + } + if (null !== $limit) { + $parameters['limit'] = (int) $limit; + } + + return $this->client->makeRequest( + '/segments', + Client::METHOD_GET, + $parameters + ); + } + + /** + * Get tasks list + * + * @param array $filter + * @param null $limit + * @param null $page + * + * @return ApiResponse + */ + public function tasksList(array $filter = array(), $limit = null, $page = null) + { + $parameters = array(); + + if (count($filter)) { + $parameters['filter'] = $filter; + } + if (null !== $page) { + $parameters['page'] = (int) $page; + } + if (null !== $limit) { + $parameters['limit'] = (int) $limit; + } + + return $this->client->makeRequest( + '/tasks', + Client::METHOD_GET, + $parameters + ); + } + + /** + * Create task + * + * @param array $task + * @param null $site + * + * @return ApiResponse + * + */ + public function tasksCreate($task, $site = null) + { + if (!count($task)) { + throw new \InvalidArgumentException( + 'Parameter `task` must contain a data' + ); + } + + return $this->client->makeRequest( + "/tasks/create", + Client::METHOD_POST, + $this->fillSite( + $site, + array('task' => json_encode($task)) + ) + ); + } + + /** + * Edit task + * + * @param array $task + * @param null $site + * + * @return ApiResponse + * + */ + public function tasksEdit($task, $site = null) + { + if (!count($task)) { + throw new \InvalidArgumentException( + 'Parameter `task` must contain a data' + ); + } + + return $this->client->makeRequest( + "/tasks/{$task['id']}/edit", + Client::METHOD_POST, + $this->fillSite( + $site, + array('task' => json_encode($task)) + ) + ); + } + + /** + * Get custom dictionary + * + * @param $id + * + * @return ApiResponse + */ + public function tasksGet($id) + { + if (empty($id)) { + throw new \InvalidArgumentException( + 'Parameter `id` must be not empty' + ); + } + + return $this->client->makeRequest( + "/tasks/$id", + Client::METHOD_GET + ); + } + /** * Return current site * diff --git a/lib/RetailCrm/Exception/CurlException.php b/lib/RetailCrm/Exception/CurlException.php index a2cd668..2524b4f 100644 --- a/lib/RetailCrm/Exception/CurlException.php +++ b/lib/RetailCrm/Exception/CurlException.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Exception; @@ -23,7 +23,7 @@ namespace RetailCrm\Exception; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class CurlException extends \RuntimeException { diff --git a/lib/RetailCrm/Exception/InvalidJsonException.php b/lib/RetailCrm/Exception/InvalidJsonException.php index e4b8dd7..fe1b9c7 100644 --- a/lib/RetailCrm/Exception/InvalidJsonException.php +++ b/lib/RetailCrm/Exception/InvalidJsonException.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Exception; @@ -23,7 +23,7 @@ namespace RetailCrm\Exception; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class InvalidJsonException extends \DomainException { diff --git a/lib/RetailCrm/Http/Client.php b/lib/RetailCrm/Http/Client.php index 58b628a..3fa4ca4 100644 --- a/lib/RetailCrm/Http/Client.php +++ b/lib/RetailCrm/Http/Client.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Http; @@ -27,7 +27,7 @@ use RetailCrm\Response\ApiResponse; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class Client { diff --git a/lib/RetailCrm/Response/ApiResponse.php b/lib/RetailCrm/Response/ApiResponse.php index 03ecb82..6c8efa0 100644 --- a/lib/RetailCrm/Response/ApiResponse.php +++ b/lib/RetailCrm/Response/ApiResponse.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Response; @@ -25,7 +25,7 @@ use RetailCrm\Exception\InvalidJsonException; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiResponse implements \ArrayAccess { diff --git a/tests/RetailCrm/Test/TestCase.php b/tests/RetailCrm/Test/TestCase.php index bd23a0f..c623330 100644 --- a/tests/RetailCrm/Test/TestCase.php +++ b/tests/RetailCrm/Test/TestCase.php @@ -1,10 +1,27 @@ + * @license https://opensource.org/licenses/MIT MIT License + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 + */ + namespace RetailCrm\Test; use RetailCrm\ApiClient; use RetailCrm\Http\Client; +/** + * Class TestCase + * + * @package RetailCrm\Test + */ class TestCase extends \PHPUnit_Framework_TestCase { /** @@ -13,6 +30,7 @@ class TestCase extends \PHPUnit_Framework_TestCase * @param string $url (default: null) * @param string $apiKey (default: null) * @param string $site (default: null) + * * @return ApiClient */ public static function getApiClient($url = null, $apiKey = null, $site = null) @@ -44,4 +62,3 @@ class TestCase extends \PHPUnit_Framework_TestCase ); } } - diff --git a/tests/RetailCrm/Tests/ApiClientCustomersTest.php b/tests/RetailCrm/Tests/ApiClientCustomersTest.php index c8c822e..476654a 100644 --- a/tests/RetailCrm/Tests/ApiClientCustomersTest.php +++ b/tests/RetailCrm/Tests/ApiClientCustomersTest.php @@ -9,12 +9,13 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; use RetailCrm\Test\TestCase; +use function var_dump; /** * Class ApiClientCustomersTest @@ -23,7 +24,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientCustomersTest extends TestCase { @@ -42,12 +43,13 @@ class ApiClientCustomersTest extends TestCase 'firstName' => self::FIRST_NAME, 'externalId' => $externalId, )); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(201, $response->getStatusCode()); - $this->assertTrue(is_int($response->getId())); + + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(201, $response->getStatusCode()); + static::assertTrue(is_int($response['id'])); return array( - 'id' => $response->getId(), + 'id' => $response['id'], 'externalId' => $externalId, ); } @@ -56,35 +58,38 @@ class ApiClientCustomersTest extends TestCase * @group customers * @expectedException \InvalidArgumentException */ - public function testCustomersCreateExceptionEmpty() + public function testCreateExceptionEmpty() { $client = static::getApiClient(); - - $response = $client->customersCreate(array()); + $client->customersCreate(array()); } /** - * @group customers + * @group customers * @depends testCustomersCreate + * + * @param array $ids + * + * @return array */ public function testCustomersGet(array $ids) { $client = static::getApiClient(); $response = $client->customersGet(678678678); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(404, $response->getStatusCode()); - $this->assertFalse($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(404, $response->getStatusCode()); + static::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->isSuccessful()); - $this->assertEquals(self::FIRST_NAME, $response->customer['firstName']); + $customerById = $response['customer']; + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); + static::assertEquals(self::FIRST_NAME, $response['customer']['firstName']); $response = $client->customersGet($ids['externalId'], 'externalId'); - $this->assertEquals($customerById['id'], $response->customer['id']); + static::assertEquals($customerById['id'], $response['customer']['id']); return $ids; } @@ -96,13 +101,14 @@ class ApiClientCustomersTest extends TestCase public function testCustomersGetException() { $client = static::getApiClient(); - - $response = $client->customersGet(678678678, 'asdf'); + $client->customersGet(678678678, 'asdf'); } /** - * @group customers + * @group customers * @depends testCustomersGet + * + * @param array $ids */ public function testCustomersEdit(array $ids) { @@ -115,16 +121,16 @@ class ApiClientCustomersTest extends TestCase ), 'id' ); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(404, $response->getStatusCode()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(404, $response->getStatusCode()); $response = $client->customersEdit(array( 'externalId' => $ids['externalId'], 'lastName' => '12345', )); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -134,8 +140,7 @@ class ApiClientCustomersTest extends TestCase public function testCustomersEditExceptionEmpty() { $client = static::getApiClient(); - - $response = $client->customersEdit(array(), 'asdf'); + $client->customersEdit(array(), 'asdf'); } /** @@ -145,8 +150,7 @@ class ApiClientCustomersTest extends TestCase public function testCustomersEditException() { $client = static::getApiClient(); - - $response = $client->customersEdit(array('id' => 678678678), 'asdf'); + $client->customersEdit(array('id' => 678678678), 'asdf'); } /** @@ -157,20 +161,20 @@ class ApiClientCustomersTest extends TestCase $client = static::getApiClient(); $response = $client->customersList(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertTrue($response->isSuccessful()); - $this->assertTrue(isset($response['customers'])); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue($response->isSuccessful()); + static::assertTrue(isset($response['customers'])); $response = $client->customersList(array(), 1, 300); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertFalse( + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertFalse( $response->isSuccessful(), 'Pagination error' ); $response = $client->customersList(array('maxOrdersCount' => 10), 1); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertTrue( + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue( $response->isSuccessful(), 'API returns customers list' ); @@ -183,8 +187,7 @@ class ApiClientCustomersTest extends TestCase public function testCustomersFixExternalIdsException() { $client = static::getApiClient(); - - $response = $client->customersFixExternalIds(array()); + $client->customersFixExternalIds(array()); } /** @@ -197,42 +200,43 @@ class ApiClientCustomersTest extends TestCase $response = $client->ordersCreate(array( 'firstName' => 'Aaa111', )); - $this->assertTrue( + + static::assertTrue( $response->isSuccessful(), 'Order created' ); - $response = $client->ordersGet($response->id, 'id'); - $this->assertTrue( + $response = $client->ordersGet($response['id'], 'id'); + static::assertTrue( $response->isSuccessful(), 'Order fetched' ); - $id = $response->order['customer']['id']; + $id = $response['order']['customer']['id']; $externalId = 'asdf' . time(); $response = $client->customersFixExternalIds(array( array('id' => $id, 'externalId' => $externalId) )); - $this->assertTrue( + static::assertTrue( $response->isSuccessful(), 'Fixed customer ids' ); $response = $client->customersGet($externalId); - $this->assertTrue( + static::assertTrue( $response->isSuccessful(), 'Got customer' ); - $this->assertEquals( + static::assertEquals( $id, - $response->customer['id'], + $response['customer']['id'], 'Fixing of customer ids were right' ); - $this->assertEquals( + static::assertEquals( $externalId, - $response->customer['externalId'], + $response['customer']['externalId'], 'Fixing of customer ids were right' ); } @@ -244,8 +248,7 @@ class ApiClientCustomersTest extends TestCase public function testCustomersUploadExceptionEmpty() { $client = static::getApiClient(); - - $response = $client->customersUpload(array()); + $client->customersUpload(array()); } /** @@ -268,17 +271,68 @@ class ApiClientCustomersTest extends TestCase 'lastName' => 'Bbb', ), )); - $this->assertTrue( + static::assertTrue( $response->isSuccessful(), 'Got customer' ); - $this->assertEquals( + static::assertEquals( $externalIdA, - $response->uploadedCustomers[0]['externalId'] + $response['uploadedCustomers'][0]['externalId'] ); - $this->assertEquals( + static::assertEquals( $externalIdB, - $response->uploadedCustomers[1]['externalId'] + $response['uploadedCustomers'][1]['externalId'] + ); + } + + /** + * @group customers + */ + public function testCustomersCombine() + { + $client = static::getApiClient(); + + $responseCreateFirst = $client->customersCreate(array( + 'firstName' => 'Aaa111', + 'externalId' => 'AA-' . time(), + 'phones' => array( + array( + 'number' => '+79999999990' + ) + ) + )); + + static::assertTrue( + $responseCreateFirst->isSuccessful(), + 'Got customer' + ); + + $responseCreateSecond = $client->customersCreate(array( + 'firstName' => 'Aaa222', + 'externalId' => 'BB-' . time(), + 'phones' => array( + array( + 'number' => '+79999999991' + ) + ) + )); + + static::assertTrue( + $responseCreateSecond->isSuccessful(), + 'Got customer' + ); + + $customers = array( + array('id' => $responseCreateFirst['id']) + ); + + $resultCustomer = array('id' => $responseCreateSecond['id']); + + $response = $client->customersCombine($customers, $resultCustomer); + + static::assertTrue( + $response->isSuccessful(), + 'Customers combined' ); } } diff --git a/tests/RetailCrm/Tests/ApiClientMarketplaceTest.php b/tests/RetailCrm/Tests/ApiClientMarketplaceTest.php index cb66246..9378bb2 100644 --- a/tests/RetailCrm/Tests/ApiClientMarketplaceTest.php +++ b/tests/RetailCrm/Tests/ApiClientMarketplaceTest.php @@ -1,4 +1,5 @@ * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; use RetailCrm\Test\TestCase; - +/** + * Class ApiClientMarketplaceTest + * + * @package RetailCrm\Tests + */ class ApiClientMarketplaceTest extends TestCase { const SNAME = 'Marketplace integration'; @@ -37,8 +42,8 @@ class ApiClientMarketplaceTest extends TestCase ) ); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertTrue(in_array($response->getStatusCode(), array(200, 201))); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue(in_array($response->getStatusCode(), array(200, 201))); + static::assertTrue($response->isSuccessful()); } } diff --git a/tests/RetailCrm/Tests/ApiClientOrdersTest.php b/tests/RetailCrm/Tests/ApiClientOrdersTest.php index 2345a0a..7ce9d1b 100644 --- a/tests/RetailCrm/Tests/ApiClientOrdersTest.php +++ b/tests/RetailCrm/Tests/ApiClientOrdersTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; @@ -23,7 +23,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientOrdersTest extends TestCase { @@ -42,12 +42,12 @@ class ApiClientOrdersTest extends TestCase 'firstName' => self::FIRST_NAME, 'externalId' => $externalId, )); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(201, $response->getStatusCode()); - $this->assertTrue(is_int($response->getId())); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(201, $response->getStatusCode()); + static::assertTrue(is_int($response['id'])); return array( - 'id' => $response->getId(), + 'id' => $response['id'], 'externalId' => $externalId, ); } @@ -59,75 +59,80 @@ class ApiClientOrdersTest extends TestCase public function testOrdersCreateExceptionEmpty() { $client = static::getApiClient(); - - $response = $client->ordersCreate(array()); + $client->ordersCreate(array()); } /** - * @group orders + * @group orders * @depends testOrdersCreate + * + * @param array $ids */ public function testOrdersStatuses(array $ids) { $client = static::getApiClient(); $response = $client->ordersStatuses(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(400, $response->getStatusCode()); - $this->assertFalse($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(400, $response->getStatusCode()); + static::assertFalse($response->isSuccessful()); $response = $client->ordersStatuses(array(), array('asdf')); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); - $orders = $response->orders; - $this->assertEquals(0, sizeof($orders)); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); + $orders = $response['orders']; + static::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->isSuccessful()); - $orders = $response->orders; - $this->assertEquals(1, sizeof($orders)); - $this->assertEquals('new', $orders[0]['status']); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); + $orders = $response['orders']; + static::assertEquals(1, sizeof($orders)); + static::assertEquals('new', $orders[0]['status']); $response = $client->ordersStatuses(array($ids['id']), array($ids['externalId'])); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); - $orders = $response->orders; - $this->assertEquals(1, sizeof($orders)); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); + $orders = $response['orders']; + static::assertEquals(1, sizeof($orders)); $response = $client->ordersStatuses(array($ids['id'])); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); - $orders = $response->orders; - $this->assertEquals(1, sizeof($orders)); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); + $orders = $response['orders']; + static::assertEquals(1, sizeof($orders)); } /** - * @group orders + * @group orders * @depends testOrdersCreate + * + * @param array $ids + * + * @return array */ public function testOrdersGet(array $ids) { $client = static::getApiClient(); $response = $client->ordersGet(678678678); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(404, $response->getStatusCode()); - $this->assertFalse($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(404, $response->getStatusCode()); + static::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->isSuccessful()); - $this->assertEquals(self::FIRST_NAME, $response->order['firstName']); + $orderById = $response['order']; + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); + static::assertEquals(self::FIRST_NAME, $response['order']['firstName']); $response = $client->ordersGet($ids['externalId'], 'externalId'); - $this->assertEquals($orderById['id'], $response->order['id']); + static::assertEquals($orderById['id'], $response['order']['id']); return $ids; } @@ -139,13 +144,14 @@ class ApiClientOrdersTest extends TestCase public function testOrdersGetException() { $client = static::getApiClient(); - - $response = $client->ordersGet(678678678, 'asdf'); + $client->ordersGet(678678678, 'asdf'); } /** - * @group orders + * @group orders * @depends testOrdersGet + * + * @param array $ids */ public function testOrdersEdit(array $ids) { @@ -158,16 +164,16 @@ class ApiClientOrdersTest extends TestCase ), 'id' ); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(404, $response->getStatusCode()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(404, $response->getStatusCode()); $response = $client->ordersEdit(array( 'externalId' => $ids['externalId'], 'lastName' => '12345', )); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -177,8 +183,7 @@ class ApiClientOrdersTest extends TestCase public function testOrdersEditExceptionEmpty() { $client = static::getApiClient(); - - $response = $client->ordersEdit(array(), 'asdf'); + $client->ordersEdit(array(), 'asdf'); } /** @@ -188,8 +193,7 @@ class ApiClientOrdersTest extends TestCase public function testOrdersEditException() { $client = static::getApiClient(); - - $response = $client->ordersEdit(array('id' => 678678678), 'asdf'); + $client->ordersEdit(array('id' => 678678678), 'asdf'); } /** @@ -200,9 +204,9 @@ class ApiClientOrdersTest extends TestCase $client = static::getApiClient(); $response = $client->ordersHistory(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -213,19 +217,19 @@ class ApiClientOrdersTest extends TestCase $client = static::getApiClient(); $response = $client->ordersList(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertTrue($response->isSuccessful()); - $this->assertTrue(isset($response['orders'])); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue($response->isSuccessful()); + static::assertTrue(isset($response['orders'])); $response = $client->ordersList(array(), 1, 300); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertFalse( + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertFalse( $response->isSuccessful(), 'Pagination error' ); $response = $client->ordersList(array('paymentStatus' => 'paid'), 1); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); } /** @@ -235,8 +239,7 @@ class ApiClientOrdersTest extends TestCase public function testOrdersFixExternalIdsException() { $client = static::getApiClient(); - - $response = $client->ordersFixExternalIds(array()); + $client->ordersFixExternalIds(array()); } /** @@ -249,36 +252,36 @@ class ApiClientOrdersTest extends TestCase $response = $client->ordersCreate(array( 'firstName' => 'Aaa', )); - $this->assertTrue( + static::assertTrue( $response->isSuccessful(), 'Order created' ); - $id = $response->id; + $id = $response['id']; $externalId = 'asdf' . time(); $response = $client->ordersFixExternalIds(array( array('id' => $id, 'externalId' => $externalId) )); - $this->assertTrue( + static::assertTrue( $response->isSuccessful(), 'Fixed order ids' ); $response = $client->ordersGet($externalId); - $this->assertTrue( + static::assertTrue( $response->isSuccessful(), 'Got order' ); - $this->assertEquals( + static::assertEquals( $id, - $response->order['id'], + $response['order']['id'], 'Fixing of order ids were right' ); - $this->assertEquals( + static::assertEquals( $externalId, - $response->order['externalId'], + $response['order']['externalId'], 'Fixing of order ids were right' ); } @@ -290,8 +293,7 @@ class ApiClientOrdersTest extends TestCase public function testOrdersUploadExceptionEmpty() { $client = static::getApiClient(); - - $response = $client->ordersUpload(array()); + $client->ordersUpload(array()); } /** @@ -314,17 +316,104 @@ class ApiClientOrdersTest extends TestCase 'lastName' => 'Bbb', ), )); - $this->assertTrue( + static::assertTrue( $response->isSuccessful(), 'Got order' ); - $this->assertEquals( + static::assertEquals( $externalIdA, - $response->uploadedOrders[0]['externalId'] + $response['uploadedOrders'][0]['externalId'] ); - $this->assertEquals( + static::assertEquals( $externalIdB, - $response->uploadedOrders[1]['externalId'] + $response['uploadedOrders'][1]['externalId'] + ); + } + + /** + * @group orders + */ + public function testOrdersCombine() + { + $client = static::getApiClient(); + + $responseCreateFirst = $client->ordersCreate([ + 'firstName' => 'Aaa111', + 'externalId' => 'AA-' . time(), + 'phone' => '+79999999990' + ]); + + static::assertTrue( + $responseCreateFirst->isSuccessful(), + 'Got order' + ); + + $responseCreateSecond = $client->ordersCreate([ + 'firstName' => 'Aaa222', + 'externalId' => 'BB-' . time(), + 'phone' => '+79999999991' + ]); + + static::assertTrue( + $responseCreateSecond->isSuccessful(), + 'Got order' + ); + + $order = ['id' => $responseCreateFirst['id']]; + $resultOrder = ['id' => $responseCreateSecond['id']]; + + $response = $client->ordersCombine($order, $resultOrder, 'ours'); + + static::assertTrue( + $response->isSuccessful(), + 'Orders combined' + ); + } + + public function testOrdersPayment() + { + $client = static::getApiClient(); + $externalId = 'AA-' . time(); + + $responseCreateFirst = $client->ordersCreate([ + 'firstName' => 'Aaa111aaA', + 'phone' => '+79999999990' + ]); + + static::assertTrue( + $responseCreateFirst->isSuccessful(), + 'Got order' + ); + + $payment = array( + 'externalId' => $externalId, + 'order' => array('id' => $responseCreateFirst['id']), + 'amount' => 1200, + 'comment' => 'test payment', + 'type' => 'cash', + 'status' => 'paid' + ); + + $response = $client->ordersPaymentCreate($payment); + + static::assertTrue( + $response->isSuccessful(), + 'Got payment' + ); + + $paymentEdit = array( + 'externalId' => $externalId, + 'amount' => 1500, + 'comment' => 'test payment!', + 'type' => 'cash', + 'status' => 'paid' + ); + + $responseAgain = $client->ordersPaymentEdit($paymentEdit); + + static::assertTrue( + $responseAgain->isSuccessful(), + 'Got payment' ); } } diff --git a/tests/RetailCrm/Tests/ApiClientPacksTest.php b/tests/RetailCrm/Tests/ApiClientPacksTest.php index 87d83a8..1acbde6 100644 --- a/tests/RetailCrm/Tests/ApiClientPacksTest.php +++ b/tests/RetailCrm/Tests/ApiClientPacksTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; @@ -23,7 +23,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientPacksTest extends TestCase { @@ -33,19 +33,19 @@ class ApiClientPacksTest extends TestCase * @group packs * @return void */ - public function testOrdersPacksHistory() + public function testPacksHistory() { $client = static::getApiClient(); $response = $client->ordersPacksHistory(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->success); - $this->assertTrue( + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->success); + static::assertTrue( isset($response['history']), 'API returns orders assembly history' ); - $this->assertTrue( + static::assertTrue( isset($response['generatedAt']), 'API returns generatedAt in orders assembly history' ); @@ -57,7 +57,7 @@ class ApiClientPacksTest extends TestCase * @group packs * @return void */ - public function testOrdersPacksCreateFailed() + public function testPacksCreateFailed() { $client = static::getApiClient(); $pack = array( @@ -67,8 +67,8 @@ class ApiClientPacksTest extends TestCase ); $response = $client->ordersPacksCreate($pack); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(400, $response->getStatusCode()); - $this->assertFalse($response->success); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(400, $response->getStatusCode()); + static::assertFalse($response->success); } } diff --git a/tests/RetailCrm/Tests/ApiClientPricesTest.php b/tests/RetailCrm/Tests/ApiClientPricesTest.php index 468f6ff..649c215 100644 --- a/tests/RetailCrm/Tests/ApiClientPricesTest.php +++ b/tests/RetailCrm/Tests/ApiClientPricesTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; @@ -23,7 +23,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientPricesTest extends TestCase { @@ -47,9 +47,9 @@ class ApiClientPricesTest extends TestCase $client = static::getApiClient(); $response = $client->usersGroups(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -60,9 +60,9 @@ class ApiClientPricesTest extends TestCase $client = static::getApiClient(); $response = $client->pricesTypes(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -82,9 +82,9 @@ class ApiClientPricesTest extends TestCase ) ); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(201, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(201, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -128,7 +128,7 @@ class ApiClientPricesTest extends TestCase ), )); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); } } diff --git a/tests/RetailCrm/Tests/ApiClientReferenceTest.php b/tests/RetailCrm/Tests/ApiClientReferenceTest.php index 3ee6076..cfbc75b 100644 --- a/tests/RetailCrm/Tests/ApiClientReferenceTest.php +++ b/tests/RetailCrm/Tests/ApiClientReferenceTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; @@ -23,7 +23,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientReferenceTest extends TestCase { @@ -39,28 +39,34 @@ class ApiClientReferenceTest extends TestCase $method = $name . 'List'; $response = $client->$method(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertTrue($response->isSuccessful()); - $this->assertTrue(isset($response[$name])); - $this->assertTrue(is_array($response[$name])); + /* @var \RetailCrm\Response\ApiResponse $response */ + + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue($response->isSuccessful()); + static::assertTrue(isset($response[$name])); + static::assertTrue(is_array($response[$name])); } /** - * @group reference + * @group reference * @dataProvider getEditDictionaries * @expectedException \InvalidArgumentException + * + * @param $name */ public function testEditingException($name) { $client = static::getApiClient(); $method = $name . 'Edit'; - $response = $client->$method(array()); + $client->$method(array()); } /** - * @group reference + * @group reference * @dataProvider getEditDictionaries + * + * @param $name */ public function testEditing($name) { @@ -70,21 +76,25 @@ class ApiClientReferenceTest extends TestCase $method = $name . 'Edit'; $params = array( 'code' => $code, - 'name' => 'Aaa', + 'name' => 'Aaa' . $code, + 'active' => false ); if ($name == 'statuses') { $params['group'] = 'new'; } $response = $client->$method($params); - $this->assertTrue(in_array($response->getStatusCode(), array(200, 201))); + /* @var \RetailCrm\Response\ApiResponse $response */ + + static::assertTrue(in_array($response->getStatusCode(), array(200, 201))); $response = $client->$method(array( 'code' => $code, - 'name' => 'Bbb', + 'name' => 'Bbb' . $code, + 'active' => false )); - $this->assertTrue(in_array($response->getStatusCode(), array(200, 201))); + static::assertTrue(in_array($response->getStatusCode(), array(200, 201))); } /** @@ -101,23 +111,30 @@ class ApiClientReferenceTest extends TestCase $params = array( 'code' => $code, 'name' => 'Aaa', + 'active' => false ); $response = $client->$method($params); - $this->assertEquals(400, $response->getStatusCode()); + /* @var \RetailCrm\Response\ApiResponse $response */ - if ($code = $client->getSite()) { + static::assertEquals(400, $response->getStatusCode()); + + if ($code == $client->getSite()) { $method = $name . 'Edit'; $params = array( 'code' => $code, 'name' => 'Aaa' . time(), + 'active' => false ); $response = $client->$method($params); - $this->assertEquals(200, $response->getStatusCode()); + static::assertEquals(200, $response->getStatusCode()); } } + /** + * @return array + */ public function getListDictionaries() { return array( @@ -134,6 +151,9 @@ class ApiClientReferenceTest extends TestCase ); } + /** + * @return array + */ public function getEditDictionaries() { return array( diff --git a/tests/RetailCrm/Tests/ApiClientStoreTest.php b/tests/RetailCrm/Tests/ApiClientStoreTest.php index 9a0b0d0..118ab83 100644 --- a/tests/RetailCrm/Tests/ApiClientStoreTest.php +++ b/tests/RetailCrm/Tests/ApiClientStoreTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; @@ -23,7 +23,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientStoreTest extends TestCase { @@ -38,9 +38,9 @@ class ApiClientStoreTest extends TestCase $client = static::getApiClient(); $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->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue(in_array($response->getStatusCode(), array(200, 201))); + static::assertTrue($response->isSuccessful()); } /** @@ -51,10 +51,10 @@ class ApiClientStoreTest extends TestCase $client = static::getApiClient(); $response = $client->storeInventories(); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); - $this->assertTrue( + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); + static::assertTrue( isset($response['offers']), 'API returns orders assembly history' ); @@ -64,7 +64,7 @@ class ApiClientStoreTest extends TestCase * @group store * @expectedException \InvalidArgumentException */ - public function testStoreInventoriesUploadExceptionEmpty() + public function testInventoriesException() { $client = static::getApiClient(); $client->storeInventoriesUpload(array()); @@ -73,16 +73,13 @@ class ApiClientStoreTest extends TestCase /** * @group store */ - public function testStoreInventoriesUpload() + public function testInventoriesUpload() { $client = static::getApiClient(); - $externalIdA = 'upload-a-' . time(); - $externalIdB = 'upload-b-' . time(); - $response = $client->storeInventoriesUpload(array( array( - 'externalId' => $externalIdA, + 'externalId' => 'pTKIKAeghYzX21HTdzFCe1', 'stores' => array( array( 'code' => self::SCODE, @@ -92,7 +89,7 @@ class ApiClientStoreTest extends TestCase ) ), array( - 'externalId' => $externalIdB, + 'externalId' => 'JQIvcrCtiSpOV3AAfMiQB3', 'stores' => array( array( 'code' => self::SCODE, @@ -103,14 +100,14 @@ class ApiClientStoreTest extends TestCase ), )); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertFalse($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue($response->isSuccessful()); } /** * @group integration */ - public function testStoreInventoriesUploadFailed() + public function testInventoriesFailed() { $client = static::getApiClient(); @@ -129,8 +126,34 @@ class ApiClientStoreTest extends TestCase 'purchasePrice' => 1500 ), )); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(400, $response->getStatusCode()); - $this->assertTrue(isset($response['errorMsg']), $response['errorMsg']); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(400, $response->getStatusCode()); + static::assertTrue(isset($response['errorMsg']), $response['errorMsg']); + } + + /** + * @group store + */ + public function testStoreProducts() + { + $client = static::getApiClient(); + + $response = $client->storeProducts(); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); + } + + /** + * @group store + */ + public function testStoreProductsGroups() + { + $client = static::getApiClient(); + + $response = $client->storeProductsGroups(); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } } diff --git a/tests/RetailCrm/Tests/ApiClientTasksTest.php b/tests/RetailCrm/Tests/ApiClientTasksTest.php new file mode 100644 index 0000000..bb21b2c --- /dev/null +++ b/tests/RetailCrm/Tests/ApiClientTasksTest.php @@ -0,0 +1,84 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 + */ + +namespace RetailCrm\Tests; + +use RetailCrm\Test\TestCase; + +/** + * Class ApiClientTasksTest + * + * @category RetailCrm + * @package RetailCrm + * @author RetailCrm + * @license https://opensource.org/licenses/MIT MIT License + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 + */ +class ApiClientTasksTest extends TestCase +{ + /** + * @group tasks + */ + public function testTasksList() + { + $client = static::getApiClient(); + + $response = $client->tasksList(); + + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + } + + /** + * @group tasks + * @expectedException \InvalidArgumentException + */ + public function testTasksCreateExceptionEmpty() + { + $client = static::getApiClient(); + $client->tasksCreate(array()); + } + + public function testTasksCRU() + { + $client = static::getApiClient(); + + $task = array( + 'text' => 'test task', + 'commentary' => 'test task commentary', + 'performerId' => $_SERVER['CRM_USER_ID'], + 'complete' => false + ); + + $responseCreate = $client->tasksCreate($task); + + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $responseCreate); + static::assertEquals(201, $responseCreate->getStatusCode()); + + $uid = $responseCreate['id']; + + $responseRead = $client->tasksGet($uid); + + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $responseRead); + static::assertEquals(200, $responseRead->getStatusCode()); + + $task['id'] = $uid; + $task['complete'] = true; + + $responseUpdate = $client->tasksEdit($task); + + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $responseUpdate); + static::assertEquals(200, $responseUpdate->getStatusCode()); + } +} diff --git a/tests/RetailCrm/Tests/ApiClientTelephonyTest.php b/tests/RetailCrm/Tests/ApiClientTelephonyTest.php index 9177df7..88c650b 100644 --- a/tests/RetailCrm/Tests/ApiClientTelephonyTest.php +++ b/tests/RetailCrm/Tests/ApiClientTelephonyTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; @@ -22,7 +22,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm\Tests * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientTelephonyTest extends TestCase { @@ -53,9 +53,9 @@ class ApiClientTelephonyTest extends TestCase 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()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue(in_array($response->getStatusCode(), array(200, 201))); + static::assertTrue($response->isSuccessful()); } /** @@ -70,9 +70,9 @@ class ApiClientTelephonyTest extends TestCase $client = static::getApiClient(); $response = $client->telephonySettingsGet(self::TEL_CODE); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -95,9 +95,9 @@ class ApiClientTelephonyTest extends TestCase ); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -119,8 +119,8 @@ class ApiClientTelephonyTest extends TestCase 'phone' => '+79999999999', 'code' => '101', 'result' => 'answered', - 'externalId' => rand(10,100), - 'recordUrl' => 'https://dl.dropboxusercontent.com/u/15492750/dontry2bfunny.mp3' + 'externalId' => rand(10, 100), + 'recordUrl' => 'http://download.retailcrm.pro/api-client-files/beep1.mp3' ), array( 'date' => '2016-07-22 00:24:00', @@ -128,15 +128,15 @@ class ApiClientTelephonyTest extends TestCase 'phone' => '+79999999999', 'code' => '101', 'result' => 'answered', - 'externalId' => rand(10,100), - 'recordUrl' => 'https://dl.dropboxusercontent.com/u/15492750/donttytobefunny.mp3' + 'externalId' => rand(10, 100), + 'recordUrl' => 'http://download.retailcrm.pro/api-client-files/beep2.mp3' ) ) ); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } /** @@ -152,8 +152,8 @@ class ApiClientTelephonyTest extends TestCase $response = $client->telephonyCallManager('+79999999999', 1); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertTrue($response->isSuccessful()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); + static::assertTrue($response->isSuccessful()); } } diff --git a/tests/RetailCrm/Tests/ApiClientTest.php b/tests/RetailCrm/Tests/ApiClientTest.php index a57a445..1bc5d6e 100644 --- a/tests/RetailCrm/Tests/ApiClientTest.php +++ b/tests/RetailCrm/Tests/ApiClientTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; @@ -23,7 +23,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientTest extends TestCase { @@ -34,6 +34,6 @@ class ApiClientTest extends TestCase { $client = static::getApiClient(); - $this->assertInstanceOf('RetailCrm\ApiClient', $client); + static::assertInstanceOf('RetailCrm\ApiClient', $client); } } diff --git a/tests/RetailCrm/Tests/ApiClientUsersTest.php b/tests/RetailCrm/Tests/ApiClientUsersTest.php index 0508b7b..666bf4c 100644 --- a/tests/RetailCrm/Tests/ApiClientUsersTest.php +++ b/tests/RetailCrm/Tests/ApiClientUsersTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests; @@ -23,7 +23,7 @@ use RetailCrm\Test\TestCase; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiClientUsersTest extends TestCase { @@ -35,9 +35,9 @@ class ApiClientUsersTest extends TestCase $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()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue(in_array($response->getStatusCode(), array(200, 201))); + static::assertTrue($response->isSuccessful()); } /** @@ -48,8 +48,21 @@ class ApiClientUsersTest extends TestCase $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()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue(in_array($response->getStatusCode(), array(200, 201))); + static::assertTrue($response->isSuccessful()); + } + + /** + * @group users + */ + public function testUsersStatus() + { + $client = static::getApiClient(); + + $response = $client->usersStatus($_SERVER["CRM_USER_ID"], 'dinner'); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertTrue(in_array($response->getStatusCode(), array(200, 201))); + static::assertTrue($response->isSuccessful()); } } diff --git a/tests/RetailCrm/Tests/Http/ClientTest.php b/tests/RetailCrm/Tests/Http/ClientTest.php index 98dbd8c..28f4d10 100644 --- a/tests/RetailCrm/Tests/Http/ClientTest.php +++ b/tests/RetailCrm/Tests/Http/ClientTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests\Http; @@ -25,7 +25,7 @@ use RetailCrm\Http\Client; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ClientTest extends TestCase { @@ -36,7 +36,7 @@ class ClientTest extends TestCase { $client = new Client('https://asdf.df', array()); - $this->assertInstanceOf('RetailCrm\Http\Client', $client); + static::assertInstanceOf('RetailCrm\Http\Client', $client); } /** @@ -53,7 +53,7 @@ class ClientTest extends TestCase * @group unit * @expectedException \InvalidArgumentException */ - public function testMakeRequestWrongMethod() + public function testRequestWrongMethod() { $client = static::getClient(); $client->makeRequest('/a', 'adsf'); @@ -63,7 +63,7 @@ class ClientTest extends TestCase * @group integration * @expectedException \RetailCrm\Exception\CurlException */ - public function testMakeRequestWrongUrl() + public function testRequestWrongUrl() { $client = new Client('https://asdf.df', array()); $client->makeRequest('/a', Client::METHOD_GET, array()); @@ -72,12 +72,12 @@ class ClientTest extends TestCase /** * @group integration */ - public function testMakeRequestSuccess() + public function testRequestSuccess() { $client = static::getClient(); $response = $client->makeRequest('/orders', Client::METHOD_GET); - $this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response); - $this->assertEquals(200, $response->getStatusCode()); + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals(200, $response->getStatusCode()); } } diff --git a/tests/RetailCrm/Tests/Response/ApiResponseTest.php b/tests/RetailCrm/Tests/Response/ApiResponseTest.php index 43e9f1b..80bc6dc 100644 --- a/tests/RetailCrm/Tests/Response/ApiResponseTest.php +++ b/tests/RetailCrm/Tests/Response/ApiResponseTest.php @@ -9,7 +9,7 @@ * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ namespace RetailCrm\Tests\Response; @@ -24,7 +24,7 @@ use RetailCrm\Response\ApiResponse; * @package RetailCrm * @author RetailCrm * @license https://opensource.org/licenses/MIT MIT License - * @link http://www.retailcrm.ru/docs/Developers/ApiVersion4 + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 */ class ApiResponseTest extends TestCase {