2019-06-10 16:24:22 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 7.0
|
|
|
|
*
|
2019-06-21 11:36:15 +03:00
|
|
|
* Messages Test
|
2019-06-10 16:24:22 +03:00
|
|
|
*
|
|
|
|
* @package RetailCrm\Mg\Bot\Tests
|
|
|
|
* @author retailCRM <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
|
|
|
* @link http://help.retailcrm.pro/docs/Developers
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace RetailCrm\Mg\Bot\Tests;
|
|
|
|
|
|
|
|
use RetailCrm\Mg\Bot\Model\Constants;
|
|
|
|
use RetailCrm\Mg\Bot\Model\Request\MessageSendRequest;
|
|
|
|
use RetailCrm\Mg\Bot\Test\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 7.0
|
|
|
|
*
|
|
|
|
* Class MessagesTest
|
|
|
|
*
|
|
|
|
* @package RetailCrm\Mg\Bot\Tests
|
|
|
|
* @author retailCRM <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
|
|
|
* @link http://help.retailcrm.pro/docs/Developers
|
|
|
|
*/
|
|
|
|
class MessagesTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @group("messages")
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
|
|
|
public function testMessageSend()
|
|
|
|
{
|
2019-06-19 12:49:55 +03:00
|
|
|
$client = self::getApiClient(
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
false,
|
|
|
|
$this->getResponse(
|
|
|
|
'{"errors":["chat_id is a required field"]}',
|
|
|
|
400
|
|
|
|
)
|
|
|
|
);
|
2019-06-10 16:24:22 +03:00
|
|
|
|
|
|
|
$request = new MessageSendRequest();
|
|
|
|
$request->setChatId(0);
|
|
|
|
$request->setScope(Constants::MESSAGE_SCOPE_PUBLIC);
|
|
|
|
$request->setContent("Hello");
|
|
|
|
|
2019-06-19 12:49:55 +03:00
|
|
|
$response = $client->messageSend($request);
|
2019-06-10 16:24:22 +03:00
|
|
|
|
2019-06-20 18:06:21 +03:00
|
|
|
self::assertTrue(!$response->isSuccessful());
|
2019-06-19 12:49:55 +03:00
|
|
|
self::assertEquals(1, count($response->getErrors()));
|
2019-06-10 16:24:22 +03:00
|
|
|
}
|
|
|
|
}
|