1
0
mirror of synced 2024-11-22 21:36:06 +03:00
api-client-php/tests/RetailCrm/Tests/ApiClientPricesTest.php

135 lines
3.3 KiB
PHP
Raw Normal View History

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
* @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
* @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();
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();
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
)
);
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
)
)
),
));
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
2016-09-21 00:09:24 +03:00
}
}