2017-06-22 00:55:08 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.4
|
|
|
|
*
|
|
|
|
* API client prices test class
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace RetailCrm\Tests\Methods\Version5;
|
|
|
|
|
|
|
|
use RetailCrm\Test\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ApiClientPricesTest
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
*/
|
|
|
|
class ApiClientPricesTest extends TestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group prices_v5
|
|
|
|
*/
|
|
|
|
public function testPricesEdit()
|
|
|
|
{
|
2017-06-22 16:42:42 +03:00
|
|
|
$client = static::getApiClient();
|
2017-06-22 00:55:08 +03:00
|
|
|
|
|
|
|
$response = $client->request->pricesTypesEdit(
|
|
|
|
[
|
|
|
|
'code' => 'sample_v4_price_code',
|
|
|
|
'name' => 'Sample v4 price type',
|
|
|
|
'ordering' => 500,
|
|
|
|
'active' => true
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
static::assertTrue($response->isSuccessful());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testPricesEdit
|
|
|
|
* @group prices_v5
|
|
|
|
*/
|
|
|
|
public function testPricesGet()
|
|
|
|
{
|
2017-06-22 16:42:42 +03:00
|
|
|
$client = static::getApiClient();
|
2017-06-22 00:55:08 +03:00
|
|
|
$response = $client->request->pricesTypes();
|
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
|
|
|
|
static::assertTrue($response->isSuccessful());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group prices_v5
|
|
|
|
* @expectedException \InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function testPricesUploadExceptionEmpty()
|
|
|
|
{
|
2017-06-22 16:42:42 +03:00
|
|
|
$client = static::getApiClient();
|
2017-06-22 00:55:08 +03:00
|
|
|
$client->request->storePricesUpload([]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testPricesEdit
|
|
|
|
* @group prices_v5
|
|
|
|
*/
|
|
|
|
public function testPricesUpload()
|
|
|
|
{
|
2017-06-22 16:42:42 +03:00
|
|
|
|
|
|
|
$client = static::getApiClient();
|
2017-06-22 00:55:08 +03:00
|
|
|
|
|
|
|
$xmlIdA = 'upload-a-' . time();
|
|
|
|
$xmlIdB = 'upload-b-' . time();
|
|
|
|
|
|
|
|
$response = $client->request->storePricesUpload([
|
|
|
|
[
|
|
|
|
'xmlId' => $xmlIdA,
|
|
|
|
'prices' => [
|
|
|
|
[
|
|
|
|
'code' => 'sample_v4_price_code',
|
|
|
|
'price' => 1700
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'xmlId' => $xmlIdB,
|
|
|
|
'prices' => [
|
|
|
|
[
|
|
|
|
'code' => 'sample_v4_price_code',
|
|
|
|
'price' => 1500
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
}
|