1
0
mirror of synced 2024-11-25 21:16:01 +03:00
mg-bot-api-client-php/tests/Bot/Tests/CommandsTest.php

106 lines
2.2 KiB
PHP
Raw Normal View History

2019-06-10 16:24:22 +03:00
<?php
/**
* PHP version 7.0
*
2019-06-21 11:36:15 +03:00
* Commands Test
2019-06-10 16:24:22 +03:00
*
* @package RetailCrm\Mg\Bot\Tests
*/
namespace RetailCrm\Mg\Bot\Tests;
2019-06-19 12:49:55 +03:00
use RetailCrm\Common\Exception\InvalidJsonException;
2019-06-10 16:24:22 +03:00
use RetailCrm\Mg\Bot\Model\Request\CommandEditRequest;
2019-06-19 12:49:55 +03:00
use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse;
2019-06-10 16:24:22 +03:00
use RetailCrm\Mg\Bot\Test\TestCase;
/**
* PHP version 7.0
*
2019-06-21 11:36:15 +03:00
* Class CommandsTest
2019-06-10 16:24:22 +03:00
*
* @package RetailCrm\Mg\Bot\Tests
*/
class CommandsTest extends TestCase
{
/**
* @group("commands")
* @throws \Exception
*/
public function testCommandEditException()
{
2019-06-21 17:51:57 +03:00
self::expectException(InvalidJsonException::class);
2019-06-10 16:24:22 +03:00
2019-06-19 12:49:55 +03:00
$client = self::getApiClient(
null,
null,
false,
2019-06-21 17:51:57 +03:00
$this->getResponse('EOF', 400)
2019-06-19 12:49:55 +03:00
);
2019-06-10 16:24:22 +03:00
$request = new CommandEditRequest();
$request->setDescription("qwerty");
$client->commandEdit($request);
}
/**
* @group("commands")
* @throws \Exception
*/
public function testCommandDeleteException()
{
2019-06-21 17:51:57 +03:00
self::expectException(\Exception::class);
2019-06-10 16:24:22 +03:00
$client = self::getApiClient();
$request = "qwerty";
$client->commandDelete($request);
}
/**
* @group("commands")
* @throws \Exception
*/
public function testCommandEdit()
{
2019-06-19 12:49:55 +03:00
$client = self::getApiClient(
null,
null,
false,
$this->getJsonResponse('commandEdit')
);
2019-06-10 16:24:22 +03:00
$request = new CommandEditRequest();
$request->setBotId(1);
$request->setName("show_payment_types");
$request->setDescription("Get available payment types");
$response = $client->commandEdit($request);
2019-10-23 21:35:21 +03:00
self::assertInstanceOf(ErrorOnlyResponse::class, $response);
2019-06-20 18:06:21 +03:00
self::assertTrue($response->isSuccessful());
2019-06-10 16:24:22 +03:00
}
/**
* @group("commands")
* @depends testCommandEdit
* @throws \Exception
*/
public function testCommandDelete()
{
2019-06-19 12:49:55 +03:00
$client = self::getApiClient(
null,
null,
false,
$this->getJsonResponse('commandEdit')
);
2019-06-10 16:24:22 +03:00
$response = $client->commandDelete("show_payment_types");
2019-10-23 21:35:21 +03:00
self::assertTrue($response->isSuccessful());
2019-06-10 16:24:22 +03:00
}
}