2021-11-17 16:01:53 +00:00
|
|
|
|
<?php
|
2022-12-14 16:19:55 +00:00
|
|
|
|
|
2021-11-20 16:17:40 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
|
|
|
|
*
|
|
|
|
|
* This code is licensed under MIT.
|
|
|
|
|
* Этот код распространяется по лицензии MIT.
|
|
|
|
|
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
|
|
|
|
*/
|
2021-11-17 16:01:53 +00:00
|
|
|
|
|
2021-11-23 17:30:54 +00:00
|
|
|
|
namespace AtolOnline\Tests\Api;
|
2021-11-17 16:01:53 +00:00
|
|
|
|
|
2021-11-18 11:07:32 +00:00
|
|
|
|
use AtolOnline\Api\AtolClient;
|
2021-12-19 14:29:17 +00:00
|
|
|
|
use AtolOnline\Api\AtolResponse;
|
|
|
|
|
use AtolOnline\Api\Monitor;
|
2021-11-20 15:38:19 +00:00
|
|
|
|
use AtolOnline\Entities\Kkt;
|
2021-11-19 05:42:51 +00:00
|
|
|
|
use AtolOnline\Exceptions\AuthFailedException;
|
2021-11-18 11:07:32 +00:00
|
|
|
|
use AtolOnline\Exceptions\EmptyLoginException;
|
2021-11-20 15:38:19 +00:00
|
|
|
|
use AtolOnline\Exceptions\EmptyMonitorDataException;
|
2021-11-18 11:07:32 +00:00
|
|
|
|
use AtolOnline\Exceptions\EmptyPasswordException;
|
2021-11-20 15:38:19 +00:00
|
|
|
|
use AtolOnline\Exceptions\NotEnoughMonitorDataException;
|
2021-11-18 11:07:32 +00:00
|
|
|
|
use AtolOnline\Exceptions\TooLongLoginException;
|
|
|
|
|
use AtolOnline\Exceptions\TooLongPasswordException;
|
|
|
|
|
use AtolOnline\Helpers;
|
2021-11-19 05:42:51 +00:00
|
|
|
|
use AtolOnline\TestEnvParams;
|
2021-11-23 17:30:54 +00:00
|
|
|
|
use AtolOnline\Tests\BasicTestCase;
|
2021-12-06 08:14:19 +00:00
|
|
|
|
use Exception;
|
2021-11-19 05:42:51 +00:00
|
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
2021-11-17 16:01:53 +00:00
|
|
|
|
|
2021-11-18 11:07:32 +00:00
|
|
|
|
/**
|
|
|
|
|
* Набор тестов для проверки работы API-клиента на примере монитора ККТ
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
class MonitorTest extends BasicTestCase
|
2021-11-17 16:01:53 +00:00
|
|
|
|
{
|
2021-11-20 15:38:19 +00:00
|
|
|
|
/**
|
2021-12-16 10:35:49 +00:00
|
|
|
|
* Возвращает объект монитора для тестирования с тестовым API АТОЛ
|
2021-11-20 15:38:19 +00:00
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @return Monitor
|
2021-11-20 15:38:19 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
private function newTestClient(): Monitor
|
2021-11-20 15:38:19 +00:00
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
return (new Monitor(true))
|
2021-12-16 10:35:49 +00:00
|
|
|
|
->setLogin(TestEnvParams::FFD105()['login'])
|
|
|
|
|
->setPassword(TestEnvParams::FFD105()['password']);
|
2021-11-20 15:38:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-18 11:07:32 +00:00
|
|
|
|
/**
|
|
|
|
|
* Тестирует успешное создание объекта монитора без аргументов конструктора
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
2021-11-18 11:07:32 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testConstructorWithoutArgs(): void
|
2021-11-18 11:07:32 +00:00
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor();
|
2021-11-18 11:07:32 +00:00
|
|
|
|
$this->assertIsObject($client);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$this->assertIsSameClass(Monitor::class, $client);
|
2021-12-06 06:15:47 +00:00
|
|
|
|
$this->assertExtendsClasses([AtolClient::class], $client);
|
2021-11-18 11:07:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует успешное создание объекта монитора с аргументами конструктора
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setLogin
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getLogin
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setPassword
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getPassword
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
2021-11-18 11:07:32 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testConstructorWithArgs(): void
|
2021-11-18 11:07:32 +00:00
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor(false, 'login', 'password', []);
|
2021-11-18 11:07:32 +00:00
|
|
|
|
$this->assertIsObject($client);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$this->assertIsSameClass($client, Monitor::class);
|
2021-12-06 06:15:47 +00:00
|
|
|
|
$this->assertExtendsClasses([AtolClient::class], $client);
|
2021-11-19 05:42:51 +00:00
|
|
|
|
}
|
2021-12-19 14:29:17 +00:00
|
|
|
|
//
|
2021-11-19 05:42:51 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует установку и возврат логина
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getLogin
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setLogin
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws TooLongLoginException
|
2021-11-19 05:42:51 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testLogin(): void
|
2021-11-19 05:42:51 +00:00
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor(false, login: 'login');
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('login', $client->getLogin());
|
2021-11-19 05:42:51 +00:00
|
|
|
|
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor();
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame(TestEnvParams::FFD105()['login'], $client->getLogin());
|
2021-11-19 05:42:51 +00:00
|
|
|
|
|
|
|
|
|
$client->setLogin('login');
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame(TestEnvParams::FFD105()['login'], $client->getLogin());
|
2021-11-18 11:07:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение при попытке передать пустой логин в конструктор
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setLogin
|
2021-11-19 05:42:51 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\EmptyLoginException
|
2021-11-18 11:07:32 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testEmptyLoginException(): void
|
2021-11-18 11:07:32 +00:00
|
|
|
|
{
|
|
|
|
|
$this->expectException(EmptyLoginException::class);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
new Monitor(login: '');
|
2021-11-18 11:07:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение при попытке передать слишком длинный логин в конструктор
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setLogin
|
2021-11-19 05:42:51 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\TooLongLoginException
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
2021-11-18 11:07:32 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testTooLongLoginException(): void
|
2021-11-18 11:07:32 +00:00
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooLongLoginException::class);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
new Monitor(login: Helpers::randomStr(101));
|
2021-11-18 11:07:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-19 05:42:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* Тестирует установку и возврат пароля
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getPassword
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setPassword
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws TooLongPasswordException
|
2021-11-19 05:42:51 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testPassword(): void
|
2021-11-19 05:42:51 +00:00
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor(false, password: 'password');
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('password', $client->getPassword());
|
2021-11-19 05:42:51 +00:00
|
|
|
|
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor();
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame(TestEnvParams::FFD105()['password'], $client->getPassword());
|
2021-11-19 05:42:51 +00:00
|
|
|
|
|
|
|
|
|
$client->setPassword('password');
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame(TestEnvParams::FFD105()['password'], $client->getPassword());
|
2021-11-19 05:42:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-18 11:07:32 +00:00
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение при попытке передать пустой пароль в конструктор
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setPassword
|
2021-11-19 05:42:51 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\EmptyPasswordException
|
2021-11-18 11:07:32 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testEmptyPasswordException(): void
|
2021-11-18 11:07:32 +00:00
|
|
|
|
{
|
|
|
|
|
$this->expectException(EmptyPasswordException::class);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
new Monitor(password: '');
|
2021-11-18 11:07:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение при попытке передать слишком длинный пароль в конструктор
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setPassword
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
2021-11-18 11:07:32 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testConstructorWithLongPassword(): void
|
2021-11-18 11:07:32 +00:00
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooLongPasswordException::class);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
new Monitor(password: Helpers::randomStr(101));
|
2021-11-18 11:07:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует установку тестового режима
|
|
|
|
|
*
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::__construct
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::isTestMode
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setTestMode
|
2021-11-18 11:07:32 +00:00
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testTestMode(): void
|
2021-11-18 11:07:32 +00:00
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor();
|
2021-11-18 11:07:32 +00:00
|
|
|
|
$this->assertTrue($client->isTestMode());
|
|
|
|
|
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor(true);
|
2021-11-18 11:07:32 +00:00
|
|
|
|
$this->assertTrue($client->isTestMode());
|
|
|
|
|
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor(false);
|
2021-11-18 11:07:32 +00:00
|
|
|
|
$this->assertFalse($client->isTestMode());
|
|
|
|
|
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = (new Monitor())->setTestMode();
|
2021-11-18 11:07:32 +00:00
|
|
|
|
$this->assertTrue($client->isTestMode());
|
|
|
|
|
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = (new Monitor())->setTestMode(false);
|
2021-11-18 11:07:32 +00:00
|
|
|
|
$this->assertFalse($client->isTestMode());
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-19 05:42:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* Тестирует авторизацию
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Api\AtolClient::getHeaders
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::sendRequest
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getAuthEndpoint
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::doAuth
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::auth
|
2021-11-20 15:38:19 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\AuthFailedException
|
2021-11-19 05:42:51 +00:00
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testAuth(): void
|
2021-11-18 11:07:32 +00:00
|
|
|
|
{
|
2021-11-19 05:42:51 +00:00
|
|
|
|
$this->skipIfMonitoringIsOffline();
|
|
|
|
|
$result = $this->newTestClient()->auth();
|
|
|
|
|
$this->assertTrue($result);
|
2021-11-18 11:07:32 +00:00
|
|
|
|
}
|
2021-11-17 16:01:53 +00:00
|
|
|
|
|
2021-11-19 05:42:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* Тестирует возврат токена после авторизации
|
|
|
|
|
*
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @depends testAuth
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::setToken
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getToken
|
2021-11-20 15:38:19 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\AuthFailedException
|
2021-11-19 05:42:51 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testGetToken(): void
|
2021-11-17 16:01:53 +00:00
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$client = new Monitor();
|
2021-11-19 05:42:51 +00:00
|
|
|
|
$this->assertNull($client->getToken());
|
2021-11-17 16:01:53 +00:00
|
|
|
|
|
2021-11-19 05:42:51 +00:00
|
|
|
|
$this->skipIfMonitoringIsOffline();
|
|
|
|
|
$client = $this->newTestClient();
|
|
|
|
|
$client->auth();
|
|
|
|
|
$this->assertIsString($client->getToken());
|
2021-11-17 16:01:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-19 05:42:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* Тестирует возврат объекта последнего ответа от API
|
|
|
|
|
*
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @depends testAuth
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getLastResponse
|
2021-11-20 15:38:19 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\AuthFailedException
|
2021-11-19 05:42:51 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testGetResponse(): void
|
2021-11-17 16:01:53 +00:00
|
|
|
|
{
|
2021-11-19 05:42:51 +00:00
|
|
|
|
$this->skipIfMonitoringIsOffline();
|
|
|
|
|
$client = $this->newTestClient();
|
|
|
|
|
$client->auth();
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$this->assertIsSameClass(AtolResponse::class, $client->getLastResponse());
|
2021-11-17 16:01:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-19 10:42:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* [Мониторинг] Тестирует получение данных о всех ККТ
|
|
|
|
|
*
|
|
|
|
|
* @depends testAuth
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getMainEndpoint
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @covers \AtolOnline\Api\AtolClient::getUrlToMethod
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::fetchAll
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getAll
|
2021-11-20 15:38:19 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\AuthFailedException
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
|
|
|
|
*/
|
2021-11-20 15:38:19 +00:00
|
|
|
|
public function testMonitorGetAll(): void
|
2021-11-17 16:01:53 +00:00
|
|
|
|
{
|
2021-11-19 10:42:14 +00:00
|
|
|
|
$this->skipIfMonitoringIsOffline();
|
|
|
|
|
$client = $this->newTestClient();
|
|
|
|
|
$client->auth();
|
|
|
|
|
$kkts = $client->getAll();
|
2021-12-18 06:45:00 +00:00
|
|
|
|
$this->assertNotEmpty($client->getLastResponse()->getContent());
|
2021-11-19 10:42:14 +00:00
|
|
|
|
$this->assertIsCollection($kkts);
|
|
|
|
|
$this->assertTrue($kkts->count() > 0);
|
2021-11-20 15:38:19 +00:00
|
|
|
|
$this->assertIsSameClass(Kkt::class, $kkts->random());
|
2021-11-17 16:01:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-19 10:42:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* [Мониторинг] Тестирует получение данных о конкретной ККТ
|
|
|
|
|
*
|
|
|
|
|
* @depends testAuth
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getMainEndpoint
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @covers \AtolOnline\Api\AtolClient::getUrlToMethod
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Monitor::fetchOne
|
|
|
|
|
* @covers \AtolOnline\Api\Monitor::getOne
|
2021-11-20 15:38:19 +00:00
|
|
|
|
* @covers \AtolOnline\Entities\Kkt::__construct
|
|
|
|
|
* @covers \AtolOnline\Entities\Kkt::__get
|
|
|
|
|
* @covers \AtolOnline\Entities\Kkt::jsonSerialize
|
|
|
|
|
* @covers \AtolOnline\Entities\Kkt::__toString
|
2021-11-19 10:42:14 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws TooLongLoginException
|
|
|
|
|
* @throws TooLongPasswordException
|
2021-11-20 15:38:19 +00:00
|
|
|
|
* @throws EmptyMonitorDataException
|
|
|
|
|
* @throws NotEnoughMonitorDataException
|
2021-12-06 08:14:19 +00:00
|
|
|
|
* @throws Exception
|
2021-11-19 10:42:14 +00:00
|
|
|
|
*/
|
2021-11-20 16:17:40 +00:00
|
|
|
|
public function testMonitorGetOne(): void
|
2021-11-17 16:01:53 +00:00
|
|
|
|
{
|
2021-11-19 10:42:14 +00:00
|
|
|
|
$this->skipIfMonitoringIsOffline();
|
|
|
|
|
$client = $this->newTestClient();
|
|
|
|
|
$client->auth();
|
2021-11-20 16:17:40 +00:00
|
|
|
|
$serial_number = $client->getAll()->first()->serialNumber;
|
2021-11-20 15:38:19 +00:00
|
|
|
|
$kkt = $client->getOne($serial_number);
|
2021-12-18 06:45:00 +00:00
|
|
|
|
$this->assertNotEmpty($client->getLastResponse());
|
2021-11-20 15:38:19 +00:00
|
|
|
|
$this->assertIsSameClass(Kkt::class, $kkt);
|
2021-12-07 12:04:03 +00:00
|
|
|
|
$this->assertIsAtolable($kkt);
|
2021-11-20 15:38:19 +00:00
|
|
|
|
$this->assertNotNull($kkt->serialNumber);
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame($serial_number, $kkt->serialNumber);
|
2021-11-17 16:01:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|