2017-06-22 00:55:08 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.4
|
|
|
|
*
|
|
|
|
* API client orders test class
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace RetailCrm\Tests\Methods\Version5;
|
|
|
|
|
|
|
|
use RetailCrm\Test\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ApiClientTasksTest
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
*/
|
|
|
|
class ApiClientTasksTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @group tasks_v5
|
|
|
|
*/
|
|
|
|
public function testTasksList()
|
|
|
|
{
|
|
|
|
|
2017-06-22 16:42:42 +03:00
|
|
|
$client = static::getApiClient();
|
2017-06-22 00:55:08 +03:00
|
|
|
$response = $client->request->tasksList();
|
|
|
|
|
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
|
|
static::assertEquals(200, $response->getStatusCode());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group tasks_v5
|
|
|
|
* @expectedException \InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function testTasksCreateExceptionEmpty()
|
|
|
|
{
|
2017-06-22 16:42:42 +03:00
|
|
|
$client = static::getApiClient();
|
2017-06-22 00:55:08 +03:00
|
|
|
$client->request->tasksCreate([]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTasksCRU()
|
|
|
|
{
|
2017-06-22 16:42:42 +03:00
|
|
|
$client = static::getApiClient();
|
2018-02-20 17:50:45 +03:00
|
|
|
$user = getenv('RETAILCRM_USER') ?: $_SERVER['RETAILCRM_USER'];
|
2017-06-22 00:55:08 +03:00
|
|
|
$task = [
|
|
|
|
'text' => 'test task',
|
|
|
|
'commentary' => 'test task commentary',
|
2018-02-20 17:50:45 +03:00
|
|
|
'performerId' => $user,
|
2017-06-22 00:55:08 +03:00
|
|
|
'complete' => false
|
|
|
|
];
|
|
|
|
|
|
|
|
$responseCreate = $client->request->tasksCreate($task);
|
|
|
|
|
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $responseCreate);
|
|
|
|
static::assertEquals(201, $responseCreate->getStatusCode());
|
|
|
|
|
|
|
|
$uid = $responseCreate['id'];
|
|
|
|
|
|
|
|
$responseRead = $client->request->tasksGet($uid);
|
|
|
|
|
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $responseRead);
|
|
|
|
static::assertEquals(200, $responseRead->getStatusCode());
|
|
|
|
|
|
|
|
$task['id'] = $uid;
|
|
|
|
$task['complete'] = true;
|
|
|
|
|
|
|
|
$responseUpdate = $client->request->tasksEdit($task);
|
|
|
|
|
|
|
|
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $responseUpdate);
|
|
|
|
static::assertEquals(200, $responseUpdate->getStatusCode());
|
|
|
|
}
|
|
|
|
}
|