1
0
mirror of synced 2024-11-24 06:16:27 +03:00
api-client-php/tests/RetailCrm/Tests/ApiClientStoreTest.php
2016-03-12 01:54:33 +03:00

103 lines
2.8 KiB
PHP

<?php
namespace RetailCrm\Tests;
use RetailCrm\Test\TestCase;
/**
* Class ApiClientStoreTest
* @package RetailCrm\Tests
*/
class ApiClientStoreTest extends TestCase
{
/**
* @group integration
*/
public function testStoreInventories()
{
$client = static::getApiClient();
$response = $client->storeInventories();
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertTrue($response->success);
$this->assertTrue(
isset($response['offers']),
'API returns orders assembly history'
);
}
/**
* @group unit
* @expectedException \InvalidArgumentException
*/
public function testStoreInventoriesUploadExceptionEmpty()
{
$client = static::getApiClient();
$client->storeInventoriesUpload(array());
}
/**
* @group integration
*/
public function testStoreInventoriesUpload()
{
$client = static::getApiClient();
$externalIdA = 'upload-a-' . time();
$externalIdB = 'upload-b-' . time();
$response = $client->storeInventoriesUpload(array(
array(
'externalId' => $externalIdA,
'stores' => array(
array(
'code' => $_SERVER['CRM_STORE'],
'available' => 10,
'purchasePrice' => 1700
)
)
),
array(
'externalId' => $externalIdB,
'stores' => array(
array(
'code' => $_SERVER['CRM_STORE'],
'available' => 20,
'purchasePrice' => 1500
)
)
),
));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertTrue($response->isSuccessful());
}
/**
* @group integration
*/
public function testStoreInventoriesUploadFailed()
{
$client = static::getApiClient();
$externalIdA = 'upload-a-' . time();
$externalIdB = 'upload-b-' . time();
$response = $client->storeInventoriesUpload(array(
array(
'externalId' => $externalIdA,
'available' => 10,
'purchasePrice' => 1700
),
array(
'externalId' => $externalIdB,
'available' => 20,
'purchasePrice' => 1500
),
));
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
$this->assertEquals(400, $response->getStatusCode());
$this->assertTrue(isset($response['errorMsg']), $response['errorMsg']);
}
}