1
0
mirror of synced 2024-11-26 15:26:06 +03:00
api-client-php/tests/RetailCrm/Tests/Methods/Version5/ApiClientFilesTest.php
2020-12-15 13:32:52 +03:00

88 lines
2.3 KiB
PHP

<?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 ApiClientFilesTest extends TestCase
{
/**
* @group files_v5
*/
public function testFilesList()
{
$client = static::getApiClient();
$response = $client->request->filesList();
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
}
/**
* @group files_v5
*/
public function testFileUpload()
{
$client = static::getApiClient();
$response = $client->request->fileUpload(__DIR__ . '/../../../Tests/Resources/Report.pdf');
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
sleep(1);
$fileId = $response['file']['id'];
$response = $client->request->fileGet($fileId);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
sleep(1);
$response = $client->request->fileEdit($fileId, ['filename' => 'Test file']);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
sleep(1);
$response = $client->request->fileDelete($fileId);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
sleep(1);
}
public function testFileEditFailure()
{
static::expectExceptionObject(new \InvalidArgumentException('Invalid structure of `file` parameter'));
$client = static::getApiClient();
$client->request->fileEdit(1, ['file' => []]);
}
}