2016-09-21 00:09:24 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.3
|
|
|
|
*
|
|
|
|
* API client prices test class
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
2017-06-12 23:58:56 +03:00
|
|
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
2016-09-21 00:09:24 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace RetailCrm\Tests;
|
|
|
|
|
|
|
|
use RetailCrm\Test\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ApiClientPricesTest
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
2017-06-12 23:58:56 +03:00
|
|
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
2016-09-21 00:09:24 +03:00
|
|
|
*/
|
|
|
|
class ApiClientPricesTest extends TestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
protected $code;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ApiClientPricesTest constructor.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->code = 'price-code-a-' . time();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group prices
|
|
|
|
*/
|
|
|
|
public function testUsersGroups()
|
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
|
|
|
|
|
|
|
$response = $client->usersGroups();
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
static::assertTrue($response->isSuccessful());
|
2016-09-21 00:09:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group prices
|
|
|
|
*/
|
|
|
|
public function testPricesGet()
|
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
|
|
|
|
|
|
|
$response = $client->pricesTypes();
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
static::assertTrue($response->isSuccessful());
|
2016-09-21 00:09:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group prices
|
|
|
|
*/
|
|
|
|
public function testPricesEdit()
|
|
|
|
{
|
|
|
|
|
|
|
|
$client = static::getApiClient();
|
|
|
|
|
|
|
|
$response = $client->pricesEdit(
|
|
|
|
array(
|
|
|
|
'code' => $this->code,
|
|
|
|
'name' => $this->code,
|
|
|
|
'ordering' => 500,
|
|
|
|
'active' => true
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(201, $response->getStatusCode());
|
|
|
|
static::assertTrue($response->isSuccessful());
|
2016-09-21 00:09:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group prices
|
|
|
|
* @expectedException \InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function testPricesUploadExceptionEmpty()
|
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
|
|
|
$client->storePricesUpload(array());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group prices
|
|
|
|
*/
|
|
|
|
public function testPricesUpload()
|
|
|
|
{
|
|
|
|
$client = static::getApiClient();
|
|
|
|
|
|
|
|
$xmlIdA = 'upload-a-' . time();
|
|
|
|
$xmlIdB = 'upload-b-' . time();
|
|
|
|
|
|
|
|
$response = $client->storePricesUpload(array(
|
|
|
|
array(
|
|
|
|
'xmlId' => $xmlIdA,
|
|
|
|
'prices' => array(
|
|
|
|
array(
|
|
|
|
'code' => $this->code,
|
|
|
|
'price' => 1700
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'xmlId' => $xmlIdB,
|
|
|
|
'prices' => array(
|
|
|
|
array(
|
|
|
|
'code' => $this->code,
|
|
|
|
'price' => 1500
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
2017-06-12 23:58:56 +03:00
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
2016-09-21 00:09:24 +03:00
|
|
|
}
|
|
|
|
}
|