mirror of
https://github.com/anthonyaxenov/atol-online.git
synced 2024-11-21 21:34:34 +00:00
Переименования классов для пущей простоты
This commit is contained in:
parent
71d1f2900c
commit
fdc5ab112a
@ -35,9 +35,9 @@ abstract class AtolClient
|
||||
protected array $request;
|
||||
|
||||
/**
|
||||
* @var KktResponse|null Последний ответ сервера АТОЛ
|
||||
* @var AtolResponse|null Последний ответ сервера АТОЛ
|
||||
*/
|
||||
protected ?KktResponse $response;
|
||||
protected ?AtolResponse $response;
|
||||
|
||||
/**
|
||||
* @var bool Флаг тестового режима
|
||||
@ -106,9 +106,9 @@ abstract class AtolClient
|
||||
/**
|
||||
* Возвращает последний ответ сервера
|
||||
*
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
*/
|
||||
public function getLastResponse(): ?KktResponse
|
||||
public function getLastResponse(): ?AtolResponse
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
@ -263,7 +263,7 @@ abstract class AtolClient
|
||||
'login' => $this->getLogin() ?? throw new EmptyLoginException(),
|
||||
'pass' => $this->getPassword() ?? throw new EmptyPasswordException(),
|
||||
]);
|
||||
if (!$result->isValid() || !$result->getContent()->token) {
|
||||
if (!$result->isSuccessful() || !$result->getContent()->token) {
|
||||
throw new AuthFailedException($result);
|
||||
}
|
||||
return $result->getContent()?->token;
|
||||
@ -276,7 +276,7 @@ abstract class AtolClient
|
||||
* @param string $url URL
|
||||
* @param array|null $data Данные для передачи
|
||||
* @param array|null $options Параметры Guzzle
|
||||
* @return KktResponse
|
||||
* @return AtolResponse
|
||||
* @throws GuzzleException
|
||||
* @see https://guzzle.readthedocs.io/en/latest/request-options.html
|
||||
*/
|
||||
@ -285,7 +285,7 @@ abstract class AtolClient
|
||||
string $url,
|
||||
?array $data = null,
|
||||
?array $options = null
|
||||
): KktResponse {
|
||||
): AtolResponse {
|
||||
$http_method = strtoupper(trim($http_method));
|
||||
$options['headers'] = array_merge($this->getHeaders(), $options['headers'] ?? []);
|
||||
$http_method != 'GET' && $options['json'] = $data;
|
||||
@ -294,7 +294,7 @@ abstract class AtolClient
|
||||
'url' => $url,
|
||||
], $options);
|
||||
$response = $this->http->request($http_method, $url, $options);
|
||||
return $this->response = new KktResponse($response);
|
||||
return $this->response = new AtolResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -328,5 +328,4 @@ abstract class AtolClient
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getMainEndpoint(): string;
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use Stringable;
|
||||
* @property mixed $error
|
||||
* @package AtolOnline\Api
|
||||
*/
|
||||
class KktResponse implements JsonSerializable, Stringable
|
||||
class AtolResponse implements JsonSerializable, Stringable
|
||||
{
|
||||
/**
|
||||
* @var int Код ответа сервера
|
||||
@ -104,7 +104,7 @@ class KktResponse implements JsonSerializable, Stringable
|
||||
* @return bool
|
||||
*/
|
||||
#[Pure]
|
||||
public function isValid(): bool
|
||||
public function isSuccessful(): bool
|
||||
{
|
||||
return !empty($this->getCode())
|
||||
&& !empty($this->getContent())
|
@ -38,7 +38,7 @@ use Ramsey\Uuid\Uuid;
|
||||
/**
|
||||
* Класс фискализатора для регистрации документов на ККТ
|
||||
*/
|
||||
class KktFiscalizer extends AtolClient
|
||||
class Fiscalizer extends AtolClient
|
||||
{
|
||||
/**
|
||||
* @var string|null Группа ККТ
|
||||
@ -139,7 +139,7 @@ class KktFiscalizer extends AtolClient
|
||||
*
|
||||
* @param Receipt $receipt Объект документа
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -149,7 +149,7 @@ class KktFiscalizer extends AtolClient
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function sell(Receipt $receipt, ?string $external_id = null): ?KktResponse
|
||||
public function sell(Receipt $receipt, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $this->registerDocument('sell', $receipt, $external_id);
|
||||
}
|
||||
@ -159,7 +159,7 @@ class KktFiscalizer extends AtolClient
|
||||
*
|
||||
* @param Receipt $receipt Объект документа
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -169,7 +169,7 @@ class KktFiscalizer extends AtolClient
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function sellRefund(Receipt $receipt, ?string $external_id = null): ?KktResponse
|
||||
public function sellRefund(Receipt $receipt, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $this->registerDocument('sell_refund', $receipt, $external_id);
|
||||
}
|
||||
@ -179,7 +179,7 @@ class KktFiscalizer extends AtolClient
|
||||
*
|
||||
* @param Correction $correction Объект документа
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -189,7 +189,7 @@ class KktFiscalizer extends AtolClient
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function sellCorrect(Correction $correction, ?string $external_id = null): ?KktResponse
|
||||
public function sellCorrect(Correction $correction, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $this->registerDocument('sell_correction', $correction, $external_id);
|
||||
}
|
||||
@ -199,7 +199,7 @@ class KktFiscalizer extends AtolClient
|
||||
*
|
||||
* @param Receipt $receipt Объект документа
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -209,7 +209,7 @@ class KktFiscalizer extends AtolClient
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function buy(Receipt $receipt, ?string $external_id = null): ?KktResponse
|
||||
public function buy(Receipt $receipt, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $this->registerDocument('buy', $receipt, $external_id);
|
||||
}
|
||||
@ -219,7 +219,7 @@ class KktFiscalizer extends AtolClient
|
||||
*
|
||||
* @param Receipt $receipt Объект документа
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -229,7 +229,7 @@ class KktFiscalizer extends AtolClient
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function buyRefund(Receipt $receipt, ?string $external_id = null): ?KktResponse
|
||||
public function buyRefund(Receipt $receipt, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $this->registerDocument('buy_refund', $receipt, $external_id);
|
||||
}
|
||||
@ -239,7 +239,7 @@ class KktFiscalizer extends AtolClient
|
||||
*
|
||||
* @param Correction $correction Объект документа
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -249,7 +249,7 @@ class KktFiscalizer extends AtolClient
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function buyCorrect(Correction $correction, ?string $external_id = null): ?KktResponse
|
||||
public function buyCorrect(Correction $correction, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $this->registerDocument('buy_correction', $correction, $external_id);
|
||||
}
|
||||
@ -258,14 +258,14 @@ class KktFiscalizer extends AtolClient
|
||||
* Проверяет статус чека на ККТ один раз
|
||||
*
|
||||
* @param string $uuid UUID регистрации
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
* @throws GuzzleException
|
||||
* @throws InvalidUuidException
|
||||
*/
|
||||
public function getDocumentStatus(string $uuid): ?KktResponse
|
||||
public function getDocumentStatus(string $uuid): ?AtolResponse
|
||||
{
|
||||
!Uuid::isValid($uuid = trim($uuid)) && throw new InvalidUuidException($uuid);
|
||||
return $this->auth()
|
||||
@ -280,19 +280,19 @@ class KktFiscalizer extends AtolClient
|
||||
* @param string $uuid UUID регистрации
|
||||
* @param int $retry_count Количество попыток
|
||||
* @param int $timeout Таймаут в секундах между попытками
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
* @throws GuzzleException
|
||||
* @throws InvalidUuidException
|
||||
*/
|
||||
public function pollDocumentStatus(string $uuid, int $retry_count = 5, int $timeout = 1): ?KktResponse
|
||||
public function pollDocumentStatus(string $uuid, int $retry_count = 5, int $timeout = 1): ?AtolResponse
|
||||
{
|
||||
$try = 0;
|
||||
do {
|
||||
$response = $this->getDocumentStatus($uuid);
|
||||
if ($response->isValid() && $response->getContent()->status == 'done') {
|
||||
if ($response->isSuccessful() && $response->getContent()->status == 'done') {
|
||||
break;
|
||||
} else {
|
||||
sleep($timeout);
|
||||
@ -308,7 +308,7 @@ class KktFiscalizer extends AtolClient
|
||||
* @param string $api_method Метод API
|
||||
* @param Receipt|Correction $document Документ
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -322,7 +322,7 @@ class KktFiscalizer extends AtolClient
|
||||
string $api_method,
|
||||
Receipt|Correction $document,
|
||||
?string $external_id = null
|
||||
): ?KktResponse {
|
||||
): ?AtolResponse {
|
||||
$this->isTestMode() && $document->getCompany()
|
||||
->setInn(TestEnvParams::FFD105()['inn'])
|
||||
->setPaymentAddress(TestEnvParams::FFD105()['payment_address']);
|
@ -27,7 +27,7 @@ use JetBrains\PhpStorm\Pure;
|
||||
*
|
||||
* @see https://online.atol.ru/files/API_service_information.pdf Документация
|
||||
*/
|
||||
class KktMonitor extends AtolClient
|
||||
class Monitor extends AtolClient
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
@ -56,14 +56,14 @@ class KktMonitor extends AtolClient
|
||||
*
|
||||
* @param int|null $limit
|
||||
* @param int|null $offset
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws GuzzleException
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
* @see https://online.atol.ru/files/API_service_information.pdf Документация, стр 9
|
||||
*/
|
||||
protected function fetchAll(?int $limit = null, ?int $offset = null): ?KktResponse
|
||||
protected function fetchAll(?int $limit = null, ?int $offset = null): ?AtolResponse
|
||||
{
|
||||
$params = [];
|
||||
!is_null($limit) && $params['limit'] = $limit;
|
||||
@ -95,11 +95,11 @@ class KktMonitor extends AtolClient
|
||||
* Получает от API информацию о конкретной ККТ по её серийному номеру
|
||||
*
|
||||
* @param string $serial_number
|
||||
* @return KktResponse
|
||||
* @return AtolResponse
|
||||
* @throws GuzzleException
|
||||
* @see https://online.atol.ru/files/API_service_information.pdf Документация, стр 11
|
||||
*/
|
||||
protected function fetchOne(string $serial_number): KktResponse
|
||||
protected function fetchOne(string $serial_number): AtolResponse
|
||||
{
|
||||
return $this->sendRequest(
|
||||
'GET',
|
@ -10,8 +10,8 @@
|
||||
namespace AtolOnline\Entities;
|
||||
|
||||
use AtolOnline\{
|
||||
Api\KktFiscalizer,
|
||||
Api\KktResponse,
|
||||
Api\AtolResponse,
|
||||
Api\Fiscalizer,
|
||||
Collections\Payments,
|
||||
Collections\Vats,
|
||||
Constants\Constraints};
|
||||
@ -211,9 +211,9 @@ class Correction extends Entity
|
||||
/**
|
||||
* Регистрирует коррекцию прихода по текущему документу
|
||||
*
|
||||
* @param KktFiscalizer $fiscalizer Объект фискализатора
|
||||
* @param Fiscalizer $fiscalizer Объект фискализатора
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -223,7 +223,7 @@ class Correction extends Entity
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function sellCorrect(KktFiscalizer $fiscalizer, ?string $external_id = null): ?KktResponse
|
||||
public function sellCorrect(Fiscalizer $fiscalizer, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $fiscalizer->sellCorrect($this, $external_id);
|
||||
}
|
||||
@ -231,9 +231,9 @@ class Correction extends Entity
|
||||
/**
|
||||
* Регистрирует коррекцию расхода по текущему документу
|
||||
*
|
||||
* @param KktFiscalizer $fiscalizer Объект фискализатора
|
||||
* @param Fiscalizer $fiscalizer Объект фискализатора
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -243,7 +243,7 @@ class Correction extends Entity
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function buyCorrect(KktFiscalizer $fiscalizer, ?string $external_id = null): ?KktResponse
|
||||
public function buyCorrect(Fiscalizer $fiscalizer, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $fiscalizer->buyCorrect($this, $external_id);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ abstract class Entity implements JsonSerializable, Stringable, Arrayable, ArrayA
|
||||
'correction_info' => "\AtolOnline\Entities\CorrectionInfo",
|
||||
'payments' => "array",
|
||||
'vats' => "\AtolOnline\Collections\Vats|null",
|
||||
'cashier' => "\null|string"
|
||||
'cashier' => "null|string",
|
||||
])]
|
||||
public function toArray()
|
||||
{
|
||||
|
@ -11,8 +11,8 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Entities;
|
||||
|
||||
use AtolOnline\Api\KktFiscalizer;
|
||||
use AtolOnline\Api\KktResponse;
|
||||
use AtolOnline\Api\AtolResponse;
|
||||
use AtolOnline\Api\Fiscalizer;
|
||||
use AtolOnline\Collections\Items;
|
||||
use AtolOnline\Collections\Payments;
|
||||
use AtolOnline\Collections\Vats;
|
||||
@ -377,9 +377,9 @@ final class Receipt extends Entity
|
||||
/**
|
||||
* Регистрирует приход по текущему документу
|
||||
*
|
||||
* @param KktFiscalizer $fiscalizer Объект фискализатора
|
||||
* @param Fiscalizer $fiscalizer Объект фискализатора
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -389,7 +389,7 @@ final class Receipt extends Entity
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function sell(KktFiscalizer $fiscalizer, ?string $external_id = null): ?KktResponse
|
||||
public function sell(Fiscalizer $fiscalizer, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $fiscalizer->sell($this, $external_id);
|
||||
}
|
||||
@ -397,9 +397,9 @@ final class Receipt extends Entity
|
||||
/**
|
||||
* Регистрирует возврат прихода по текущему документу
|
||||
*
|
||||
* @param KktFiscalizer $fiscalizer Объект фискализатора
|
||||
* @param Fiscalizer $fiscalizer Объект фискализатора
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -409,7 +409,7 @@ final class Receipt extends Entity
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function sellRefund(KktFiscalizer $fiscalizer, ?string $external_id = null): ?KktResponse
|
||||
public function sellRefund(Fiscalizer $fiscalizer, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $fiscalizer->sellRefund($this, $external_id);
|
||||
}
|
||||
@ -417,9 +417,9 @@ final class Receipt extends Entity
|
||||
/**
|
||||
* Регистрирует расход по текущему документу
|
||||
*
|
||||
* @param KktFiscalizer $fiscalizer Объект фискализатора
|
||||
* @param Fiscalizer $fiscalizer Объект фискализатора
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -429,7 +429,7 @@ final class Receipt extends Entity
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function buy(KktFiscalizer $fiscalizer, ?string $external_id = null): ?KktResponse
|
||||
public function buy(Fiscalizer $fiscalizer, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $fiscalizer->buy($this, $external_id);
|
||||
}
|
||||
@ -437,9 +437,9 @@ final class Receipt extends Entity
|
||||
/**
|
||||
* Регистрирует возврат расхода по текущему документу
|
||||
*
|
||||
* @param KktFiscalizer $fiscalizer Объект фискализатора
|
||||
* @param Fiscalizer $fiscalizer Объект фискализатора
|
||||
* @param string|null $external_id Уникальный код документа (если не указан, то будет создан новый UUID)
|
||||
* @return KktResponse|null
|
||||
* @return AtolResponse|null
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -449,7 +449,7 @@ final class Receipt extends Entity
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws TooLongPaymentAddressException
|
||||
*/
|
||||
public function buyRefund(KktFiscalizer $fiscalizer, ?string $external_id = null): ?KktResponse
|
||||
public function buyRefund(Fiscalizer $fiscalizer, ?string $external_id = null): ?AtolResponse
|
||||
{
|
||||
return $fiscalizer->buyRefund($this, $external_id);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Api\KktResponse;
|
||||
use AtolOnline\Api\AtolResponse;
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
|
||||
@ -23,11 +23,11 @@ class AuthFailedException extends Exception
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @param KktResponse $response
|
||||
* @param AtolResponse $response
|
||||
* @param string $message
|
||||
*/
|
||||
#[Pure]
|
||||
public function __construct(KktResponse $response, string $message = '')
|
||||
public function __construct(AtolResponse $response, string $message = '')
|
||||
{
|
||||
parent::__construct(($message ?: 'Ошибка авторизации: ') . ': ' . $response);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use AtolOnline\{
|
||||
Tests\BasicTestCase};
|
||||
use AtolOnline\Api\{
|
||||
AtolClient,
|
||||
KktFiscalizer};
|
||||
Fiscalizer};
|
||||
use AtolOnline\Exceptions\{
|
||||
AuthFailedException,
|
||||
EmptyCorrectionNumberException,
|
||||
@ -39,8 +39,6 @@ use AtolOnline\Exceptions\{
|
||||
TooHighPaymentSumException,
|
||||
TooLongCallbackUrlException,
|
||||
TooLongItemNameException,
|
||||
TooLongLoginException,
|
||||
TooLongPasswordException,
|
||||
TooLongPaymentAddressException,
|
||||
TooManyException};
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
@ -48,7 +46,7 @@ use GuzzleHttp\Exception\GuzzleException;
|
||||
/**
|
||||
* Набор тестов для проверки работы фискализатора
|
||||
*/
|
||||
class KktFiscalizerTest extends BasicTestCase
|
||||
class FiscalizerTest extends BasicTestCase
|
||||
{
|
||||
/**
|
||||
* @var array Массив UUID-ов результатов регистрации документов для переиспользования
|
||||
@ -60,13 +58,13 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* Тестирует успешное создание объекта фискализатора без аргументов конструктора
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Api\KktFiscalizer
|
||||
* @covers \AtolOnline\Api\Fiscalizer
|
||||
*/
|
||||
public function testConstructorWithourArgs(): void
|
||||
{
|
||||
$fisc = new KktFiscalizer();
|
||||
$fisc = new Fiscalizer();
|
||||
$this->assertIsObject($fisc);
|
||||
$this->assertIsSameClass(KktFiscalizer::class, $fisc);
|
||||
$this->assertIsSameClass(Fiscalizer::class, $fisc);
|
||||
$this->assertExtendsClasses([AtolClient::class], $fisc);
|
||||
}
|
||||
|
||||
@ -74,41 +72,41 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* Тестирует установку и возврат группы ККТ
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Api\KktFiscalizer
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getGroup
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::setGroup
|
||||
* @covers \AtolOnline\Api\Fiscalizer
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getGroup
|
||||
* @covers \AtolOnline\Api\Fiscalizer::setGroup
|
||||
*/
|
||||
public function testGroup(): void
|
||||
{
|
||||
// test mode
|
||||
$this->assertEquals(
|
||||
TestEnvParams::FFD105()['group'],
|
||||
(new KktFiscalizer(group: 'group'))->getGroup()
|
||||
(new Fiscalizer(group: 'group'))->getGroup()
|
||||
);
|
||||
// prod mode
|
||||
$this->assertEquals('group', (new KktFiscalizer(false, group: 'group'))->getGroup());
|
||||
$this->assertNull((new KktFiscalizer(false))->getGroup());
|
||||
$this->assertEquals('group', (new Fiscalizer(false, group: 'group'))->getGroup());
|
||||
$this->assertNull((new Fiscalizer(false))->getGroup());
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует выброс исключения при попытке передать пустую группу ККТ в конструктор
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Api\KktFiscalizer
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::setGroup
|
||||
* @covers \AtolOnline\Api\Fiscalizer
|
||||
* @covers \AtolOnline\Api\Fiscalizer::setGroup
|
||||
* @covers \AtolOnline\Exceptions\EmptyGroupException
|
||||
*/
|
||||
public function testEmptyGroupException(): void
|
||||
{
|
||||
$this->expectException(EmptyGroupException::class);
|
||||
new KktFiscalizer(group: "\n\r \0\t");
|
||||
new Fiscalizer(group: "\n\r \0\t");
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует выброс исключения при попытке установить слишком длинный адрес колбека
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::setCallbackUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::setCallbackUrl
|
||||
* @covers \AtolOnline\Exceptions\TooLongCallbackUrlException
|
||||
* @throws InvalidCallbackUrlException
|
||||
* @throws TooLongCallbackUrlException
|
||||
@ -116,14 +114,14 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
public function testTooLongCallbackUrlException(): void
|
||||
{
|
||||
$this->expectException(TooLongCallbackUrlException::class);
|
||||
(new KktFiscalizer())->setCallbackUrl(Helpers::randomStr(Constraints::MAX_LENGTH_CALLBACK_URL + 1));
|
||||
(new Fiscalizer())->setCallbackUrl(Helpers::randomStr(Constraints::MAX_LENGTH_CALLBACK_URL + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует выброс исключения при попытке установить слишком длинный адрес колбека
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::setCallbackUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::setCallbackUrl
|
||||
* @covers \AtolOnline\Exceptions\InvalidCallbackUrlException
|
||||
* @throws InvalidCallbackUrlException
|
||||
* @throws TooLongCallbackUrlException
|
||||
@ -131,7 +129,7 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
public function testInvalidCallbackUrlException(): void
|
||||
{
|
||||
$this->expectException(InvalidCallbackUrlException::class);
|
||||
(new KktFiscalizer())->setCallbackUrl(Helpers::randomStr());
|
||||
(new Fiscalizer())->setCallbackUrl(Helpers::randomStr());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,15 +137,15 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
*
|
||||
* @param mixed $param
|
||||
* @return void
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::setCallbackUrl
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getCallbackUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::setCallbackUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getCallbackUrl
|
||||
* @dataProvider providerNullableStrings
|
||||
* @throws InvalidCallbackUrlException
|
||||
* @throws TooLongCallbackUrlException
|
||||
*/
|
||||
public function testNullableCallbackUrl(mixed $param): void
|
||||
{
|
||||
$this->assertNull((new KktFiscalizer())->setCallbackUrl($param)->getCallbackUrl());
|
||||
$this->assertNull((new Fiscalizer())->setCallbackUrl($param)->getCallbackUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,11 +153,11 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Entities\Receipt::sell
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::sell
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::registerDocument
|
||||
* @covers \AtolOnline\Api\Fiscalizer::sell
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::registerDocument
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyItemNameException
|
||||
* @throws EmptyItemsException
|
||||
@ -175,16 +173,14 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* @throws TooHighItemPriceException
|
||||
* @throws TooHighPaymentSumException
|
||||
* @throws TooLongItemNameException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
* @throws TooLongPaymentAddressException
|
||||
* @throws TooManyException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function testSell(): void
|
||||
{
|
||||
$fisc_result = $this->newReceipt()->sell(new KktFiscalizer());
|
||||
$this->assertTrue($fisc_result->isValid());
|
||||
$fisc_result = $this->newReceipt()->sell(new Fiscalizer());
|
||||
$this->assertTrue($fisc_result->isSuccessful());
|
||||
$this->assertEquals('wait', $fisc_result->getContent()->status);
|
||||
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
}
|
||||
@ -194,11 +190,11 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Entities\Receipt::sellRefund
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::sellRefund
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::registerDocument
|
||||
* @covers \AtolOnline\Api\Fiscalizer::sellRefund
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::registerDocument
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyItemNameException
|
||||
* @throws EmptyItemsException
|
||||
@ -214,16 +210,14 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* @throws TooHighItemPriceException
|
||||
* @throws TooHighPaymentSumException
|
||||
* @throws TooLongItemNameException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
* @throws TooLongPaymentAddressException
|
||||
* @throws TooManyException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function testSellRefund(): void
|
||||
{
|
||||
$fisc_result = $this->newReceipt()->sellRefund(new KktFiscalizer());
|
||||
$this->assertTrue($fisc_result->isValid());
|
||||
$fisc_result = $this->newReceipt()->sellRefund(new Fiscalizer());
|
||||
$this->assertTrue($fisc_result->isSuccessful());
|
||||
$this->assertEquals('wait', $fisc_result->getContent()->status);
|
||||
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
}
|
||||
@ -233,11 +227,11 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Entities\Correction::sellCorrect
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::sellCorrect
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::registerDocument
|
||||
* @covers \AtolOnline\Api\Fiscalizer::sellCorrect
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::registerDocument
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -248,18 +242,16 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws NegativePaymentSumException
|
||||
* @throws TooHighPaymentSumException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
* @throws TooLongPaymentAddressException
|
||||
* @throws EmptyCorrectionNumberException
|
||||
* @throws InvalidCorrectionDateException
|
||||
*/
|
||||
public function testSellCorrect(): void
|
||||
{
|
||||
$fisc_result = $this->newCorrection()->sellCorrect(new KktFiscalizer());
|
||||
$this->assertTrue($fisc_result->isValid());
|
||||
$fisc_result = $this->newCorrection()->sellCorrect(new Fiscalizer());
|
||||
$this->assertTrue($fisc_result->isSuccessful());
|
||||
$this->assertEquals('wait', $fisc_result->getContent()->status);
|
||||
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -267,11 +259,11 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Entities\Receipt::buy
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::buy
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::registerDocument
|
||||
* @covers \AtolOnline\Api\Fiscalizer::buy
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::registerDocument
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyItemNameException
|
||||
* @throws EmptyItemsException
|
||||
@ -287,18 +279,16 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* @throws TooHighItemPriceException
|
||||
* @throws TooHighPaymentSumException
|
||||
* @throws TooLongItemNameException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
* @throws TooLongPaymentAddressException
|
||||
* @throws TooManyException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function testBuy(): void
|
||||
{
|
||||
$fisc_result = $this->newReceipt()->buy(new KktFiscalizer());
|
||||
$this->assertTrue($fisc_result->isValid());
|
||||
$fisc_result = $this->newReceipt()->buy(new Fiscalizer());
|
||||
$this->assertTrue($fisc_result->isSuccessful());
|
||||
$this->assertEquals('wait', $fisc_result->getContent()->status);
|
||||
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,11 +296,11 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Entities\Receipt::buyRefund
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::buyRefund
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::registerDocument
|
||||
* @covers \AtolOnline\Api\Fiscalizer::buyRefund
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::registerDocument
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyItemNameException
|
||||
* @throws EmptyItemsException
|
||||
@ -326,18 +316,16 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* @throws TooHighItemPriceException
|
||||
* @throws TooHighPaymentSumException
|
||||
* @throws TooLongItemNameException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
* @throws TooLongPaymentAddressException
|
||||
* @throws TooManyException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function testBuyRefund(): void
|
||||
{
|
||||
$fisc_result = $this->newReceipt()->buyRefund(new KktFiscalizer());
|
||||
$this->assertTrue($fisc_result->isValid());
|
||||
$fisc_result = $this->newReceipt()->buyRefund(new Fiscalizer());
|
||||
$this->assertTrue($fisc_result->isSuccessful());
|
||||
$this->assertEquals('wait', $fisc_result->getContent()->status);
|
||||
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -345,11 +333,11 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Entities\Correction::buyCorrect
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::buyCorrect
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::registerDocument
|
||||
* @covers \AtolOnline\Api\Fiscalizer::buyCorrect
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getFullUrl
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\Fiscalizer::registerDocument
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -360,37 +348,34 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* @throws InvalidPaymentAddressException
|
||||
* @throws NegativePaymentSumException
|
||||
* @throws TooHighPaymentSumException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
* @throws TooLongPaymentAddressException
|
||||
* @throws EmptyCorrectionNumberException
|
||||
* @throws InvalidCorrectionDateException
|
||||
*/
|
||||
public function testBuyCorrect(): void
|
||||
{
|
||||
$fisc_result = $this->newCorrection()->buyCorrect(new KktFiscalizer());
|
||||
$this->assertTrue($fisc_result->isValid());
|
||||
$fisc_result = $this->newCorrection()->buyCorrect(new Fiscalizer());
|
||||
$this->assertTrue($fisc_result->isSuccessful());
|
||||
$this->assertEquals('wait', $fisc_result->getContent()->status);
|
||||
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует разовое получение статуса фискализации документа
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::getDocumentStatus
|
||||
* @covers \AtolOnline\Api\Fiscalizer::getDocumentStatus
|
||||
* @depends testSell
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
* @throws GuzzleException
|
||||
* @throws InvalidUuidException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
*/
|
||||
public function testGetDocumentStatus(): void
|
||||
{
|
||||
$fisc_status = (new KktFiscalizer())->getDocumentStatus(self::$registered_uuids[0]);
|
||||
$this->assertTrue($fisc_status->isValid());
|
||||
$fisc_status = (new Fiscalizer())->getDocumentStatus(array_shift(self::$registered_uuids));
|
||||
$this->assertTrue($fisc_status->isSuccessful());
|
||||
$this->assertTrue(in_array($fisc_status->getContent()->status, ['wait', 'done']));
|
||||
}
|
||||
|
||||
@ -398,20 +383,18 @@ class KktFiscalizerTest extends BasicTestCase
|
||||
* Тестирует опрос API на получение статуса фискализации документа
|
||||
*
|
||||
* @return void
|
||||
* @covers \AtolOnline\Api\KktFiscalizer::pollDocumentStatus
|
||||
* @covers \AtolOnline\Api\Fiscalizer::pollDocumentStatus
|
||||
* @depends testSellRefund
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
* @throws GuzzleException
|
||||
* @throws InvalidUuidException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
*/
|
||||
public function testPollDocumentStatus(): void
|
||||
{
|
||||
$fisc_status = (new KktFiscalizer())->pollDocumentStatus(self::$registered_uuids[1]);
|
||||
$this->assertTrue($fisc_status->isValid());
|
||||
$fisc_status = (new Fiscalizer())->pollDocumentStatus(array_shift(self::$registered_uuids));
|
||||
$this->assertTrue($fisc_status->isSuccessful());
|
||||
$this->assertEquals('done', $fisc_status->getContent()->status);
|
||||
}
|
||||
|
||||
}
|
@ -10,8 +10,8 @@
|
||||
namespace AtolOnline\Tests\Api;
|
||||
|
||||
use AtolOnline\Api\AtolClient;
|
||||
use AtolOnline\Api\KktMonitor;
|
||||
use AtolOnline\Api\KktResponse;
|
||||
use AtolOnline\Api\AtolResponse;
|
||||
use AtolOnline\Api\Monitor;
|
||||
use AtolOnline\Entities\Kkt;
|
||||
use AtolOnline\Exceptions\AuthFailedException;
|
||||
use AtolOnline\Exceptions\EmptyLoginException;
|
||||
@ -29,20 +29,20 @@ use GuzzleHttp\Exception\GuzzleException;
|
||||
/**
|
||||
* Набор тестов для проверки работы API-клиента на примере монитора ККТ
|
||||
*/
|
||||
class KktMonitorTest extends BasicTestCase
|
||||
class MonitorTest extends BasicTestCase
|
||||
{
|
||||
/**
|
||||
* Возвращает объект монитора для тестирования с тестовым API АТОЛ
|
||||
*
|
||||
* @return KktMonitor
|
||||
* @return Monitor
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
* @throws TooLongLoginException
|
||||
* @throws TooLongPasswordException
|
||||
*/
|
||||
private function newTestClient(): KktMonitor
|
||||
private function newTestClient(): Monitor
|
||||
{
|
||||
return (new KktMonitor(true))
|
||||
return (new Monitor(true))
|
||||
->setLogin(TestEnvParams::FFD105()['login'])
|
||||
->setPassword(TestEnvParams::FFD105()['password']);
|
||||
}
|
||||
@ -50,24 +50,24 @@ class KktMonitorTest extends BasicTestCase
|
||||
/**
|
||||
* Тестирует успешное создание объекта монитора без аргументов конструктора
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\Monitor::__construct
|
||||
*/
|
||||
public function testConstructorWithoutArgs(): void
|
||||
{
|
||||
$client = new KktMonitor();
|
||||
$client = new Monitor();
|
||||
$this->assertIsObject($client);
|
||||
$this->assertIsSameClass(KktMonitor::class, $client);
|
||||
$this->assertIsSameClass(Monitor::class, $client);
|
||||
$this->assertExtendsClasses([AtolClient::class], $client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует успешное создание объекта монитора с аргументами конструктора
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\KktMonitor::setLogin
|
||||
* @covers \AtolOnline\Api\KktMonitor::getLogin
|
||||
* @covers \AtolOnline\Api\KktMonitor::setPassword
|
||||
* @covers \AtolOnline\Api\KktMonitor::getPassword
|
||||
* @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
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
* @throws TooLongLoginException
|
||||
@ -75,27 +75,28 @@ class KktMonitorTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructorWithArgs(): void
|
||||
{
|
||||
$client = new KktMonitor(false, 'login', 'password', []);
|
||||
$client = new Monitor(false, 'login', 'password', []);
|
||||
$this->assertIsObject($client);
|
||||
$this->assertIsSameClass($client, KktMonitor::class);
|
||||
$this->assertIsSameClass($client, Monitor::class);
|
||||
$this->assertExtendsClasses([AtolClient::class], $client);
|
||||
}
|
||||
//
|
||||
|
||||
/**
|
||||
* Тестирует установку и возврат логина
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\KktMonitor::getLogin
|
||||
* @covers \AtolOnline\Api\KktMonitor::setLogin
|
||||
* @covers \AtolOnline\Api\Monitor::__construct
|
||||
* @covers \AtolOnline\Api\Monitor::getLogin
|
||||
* @covers \AtolOnline\Api\Monitor::setLogin
|
||||
* @throws EmptyLoginException
|
||||
* @throws TooLongLoginException
|
||||
*/
|
||||
public function testLogin(): void
|
||||
{
|
||||
$client = new KktMonitor(false, login: 'login');
|
||||
$client = new Monitor(false, login: 'login');
|
||||
$this->assertEquals('login', $client->getLogin());
|
||||
|
||||
$client = new KktMonitor();
|
||||
$client = new Monitor();
|
||||
$this->assertEquals(TestEnvParams::FFD105()['login'], $client->getLogin());
|
||||
|
||||
$client->setLogin('login');
|
||||
@ -105,21 +106,21 @@ class KktMonitorTest extends BasicTestCase
|
||||
/**
|
||||
* Тестирует исключение при попытке передать пустой логин в конструктор
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\KktMonitor::setLogin
|
||||
* @covers \AtolOnline\Api\Monitor::__construct
|
||||
* @covers \AtolOnline\Api\Monitor::setLogin
|
||||
* @covers \AtolOnline\Exceptions\EmptyLoginException
|
||||
*/
|
||||
public function testEmptyLoginException(): void
|
||||
{
|
||||
$this->expectException(EmptyLoginException::class);
|
||||
new KktMonitor(login: '');
|
||||
new Monitor(login: '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует исключение при попытке передать слишком длинный логин в конструктор
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\KktMonitor::setLogin
|
||||
* @covers \AtolOnline\Api\Monitor::__construct
|
||||
* @covers \AtolOnline\Api\Monitor::setLogin
|
||||
* @covers \AtolOnline\Exceptions\TooLongLoginException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -129,24 +130,24 @@ class KktMonitorTest extends BasicTestCase
|
||||
public function testTooLongLoginException(): void
|
||||
{
|
||||
$this->expectException(TooLongLoginException::class);
|
||||
new KktMonitor(login: Helpers::randomStr(101));
|
||||
new Monitor(login: Helpers::randomStr(101));
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует установку и возврат пароля
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\KktMonitor::getPassword
|
||||
* @covers \AtolOnline\Api\KktMonitor::setPassword
|
||||
* @covers \AtolOnline\Api\Monitor::__construct
|
||||
* @covers \AtolOnline\Api\Monitor::getPassword
|
||||
* @covers \AtolOnline\Api\Monitor::setPassword
|
||||
* @throws EmptyPasswordException
|
||||
* @throws TooLongPasswordException
|
||||
*/
|
||||
public function testPassword(): void
|
||||
{
|
||||
$client = new KktMonitor(false, password: 'password');
|
||||
$client = new Monitor(false, password: 'password');
|
||||
$this->assertEquals('password', $client->getPassword());
|
||||
|
||||
$client = new KktMonitor();
|
||||
$client = new Monitor();
|
||||
$this->assertEquals(TestEnvParams::FFD105()['password'], $client->getPassword());
|
||||
|
||||
$client->setPassword('password');
|
||||
@ -156,21 +157,21 @@ class KktMonitorTest extends BasicTestCase
|
||||
/**
|
||||
* Тестирует исключение при попытке передать пустой пароль в конструктор
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\KktMonitor::setPassword
|
||||
* @covers \AtolOnline\Api\Monitor::__construct
|
||||
* @covers \AtolOnline\Api\Monitor::setPassword
|
||||
* @covers \AtolOnline\Exceptions\EmptyPasswordException
|
||||
*/
|
||||
public function testEmptyPasswordException(): void
|
||||
{
|
||||
$this->expectException(EmptyPasswordException::class);
|
||||
new KktMonitor(password: '');
|
||||
new Monitor(password: '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует исключение при попытке передать слишком длинный пароль в конструктор
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\KktMonitor::setPassword
|
||||
* @covers \AtolOnline\Api\Monitor::__construct
|
||||
* @covers \AtolOnline\Api\Monitor::setPassword
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
* @throws TooLongLoginException
|
||||
@ -179,34 +180,34 @@ class KktMonitorTest extends BasicTestCase
|
||||
public function testConstructorWithLongPassword(): void
|
||||
{
|
||||
$this->expectException(TooLongPasswordException::class);
|
||||
new KktMonitor(password: Helpers::randomStr(101));
|
||||
new Monitor(password: Helpers::randomStr(101));
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует установку тестового режима
|
||||
*
|
||||
* @covers \AtolOnline\Api\KktMonitor::__construct
|
||||
* @covers \AtolOnline\Api\KktMonitor::isTestMode
|
||||
* @covers \AtolOnline\Api\KktMonitor::setTestMode
|
||||
* @covers \AtolOnline\Api\Monitor::__construct
|
||||
* @covers \AtolOnline\Api\Monitor::isTestMode
|
||||
* @covers \AtolOnline\Api\Monitor::setTestMode
|
||||
*/
|
||||
public function testTestMode(): void
|
||||
{
|
||||
$client = new KktMonitor();
|
||||
$client = new Monitor();
|
||||
$this->assertTrue($client->isTestMode());
|
||||
|
||||
$client = new KktMonitor(true);
|
||||
$client = new Monitor(true);
|
||||
$this->assertTrue($client->isTestMode());
|
||||
|
||||
$client = new KktMonitor(false);
|
||||
$client = new Monitor(false);
|
||||
$this->assertFalse($client->isTestMode());
|
||||
|
||||
$client = (new KktMonitor())->setTestMode();
|
||||
$client = (new Monitor())->setTestMode();
|
||||
$this->assertTrue($client->isTestMode());
|
||||
|
||||
$client = (new KktMonitor())->setTestMode(true);
|
||||
$client = (new Monitor())->setTestMode(true);
|
||||
$this->assertTrue($client->isTestMode());
|
||||
|
||||
$client = (new KktMonitor())->setTestMode(false);
|
||||
$client = (new Monitor())->setTestMode(false);
|
||||
$this->assertFalse($client->isTestMode());
|
||||
}
|
||||
|
||||
@ -214,10 +215,10 @@ class KktMonitorTest extends BasicTestCase
|
||||
* Тестирует авторизацию
|
||||
*
|
||||
* @covers \AtolOnline\Api\AtolClient::getHeaders
|
||||
* @covers \AtolOnline\Api\KktMonitor::sendRequest
|
||||
* @covers \AtolOnline\Api\KktMonitor::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\KktMonitor::doAuth
|
||||
* @covers \AtolOnline\Api\KktMonitor::auth
|
||||
* @covers \AtolOnline\Api\Monitor::sendRequest
|
||||
* @covers \AtolOnline\Api\Monitor::getAuthEndpoint
|
||||
* @covers \AtolOnline\Api\Monitor::doAuth
|
||||
* @covers \AtolOnline\Api\Monitor::auth
|
||||
* @covers \AtolOnline\Exceptions\AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
* @throws EmptyPasswordException
|
||||
@ -237,8 +238,8 @@ class KktMonitorTest extends BasicTestCase
|
||||
* Тестирует возврат токена после авторизации
|
||||
*
|
||||
* @depends testAuth
|
||||
* @covers \AtolOnline\Api\KktMonitor::setToken
|
||||
* @covers \AtolOnline\Api\KktMonitor::getToken
|
||||
* @covers \AtolOnline\Api\Monitor::setToken
|
||||
* @covers \AtolOnline\Api\Monitor::getToken
|
||||
* @covers \AtolOnline\Exceptions\AuthFailedException
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
@ -249,7 +250,7 @@ class KktMonitorTest extends BasicTestCase
|
||||
*/
|
||||
public function testGetToken(): void
|
||||
{
|
||||
$client = new KktMonitor();
|
||||
$client = new Monitor();
|
||||
$this->assertNull($client->getToken());
|
||||
|
||||
$this->skipIfMonitoringIsOffline();
|
||||
@ -262,7 +263,7 @@ class KktMonitorTest extends BasicTestCase
|
||||
* Тестирует возврат объекта последнего ответа от API
|
||||
*
|
||||
* @depends testAuth
|
||||
* @covers \AtolOnline\Api\KktMonitor::getLastResponse
|
||||
* @covers \AtolOnline\Api\Monitor::getLastResponse
|
||||
* @covers \AtolOnline\Exceptions\AuthFailedException
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
@ -276,17 +277,17 @@ class KktMonitorTest extends BasicTestCase
|
||||
$this->skipIfMonitoringIsOffline();
|
||||
$client = $this->newTestClient();
|
||||
$client->auth();
|
||||
$this->assertIsSameClass(KktResponse::class, $client->getLastResponse());
|
||||
$this->assertIsSameClass(AtolResponse::class, $client->getLastResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* [Мониторинг] Тестирует получение данных о всех ККТ
|
||||
*
|
||||
* @depends testAuth
|
||||
* @covers \AtolOnline\Api\KktMonitor::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\Monitor::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\AtolClient::getUrlToMethod
|
||||
* @covers \AtolOnline\Api\KktMonitor::fetchAll
|
||||
* @covers \AtolOnline\Api\KktMonitor::getAll
|
||||
* @covers \AtolOnline\Api\Monitor::fetchAll
|
||||
* @covers \AtolOnline\Api\Monitor::getAll
|
||||
* @covers \AtolOnline\Exceptions\AuthFailedException
|
||||
* @throws AuthFailedException
|
||||
* @throws EmptyLoginException
|
||||
@ -312,10 +313,10 @@ class KktMonitorTest extends BasicTestCase
|
||||
* [Мониторинг] Тестирует получение данных о конкретной ККТ
|
||||
*
|
||||
* @depends testAuth
|
||||
* @covers \AtolOnline\Api\KktMonitor::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\Monitor::getMainEndpoint
|
||||
* @covers \AtolOnline\Api\AtolClient::getUrlToMethod
|
||||
* @covers \AtolOnline\Api\KktMonitor::fetchOne
|
||||
* @covers \AtolOnline\Api\KktMonitor::getOne
|
||||
* @covers \AtolOnline\Api\Monitor::fetchOne
|
||||
* @covers \AtolOnline\Api\Monitor::getOne
|
||||
* @covers \AtolOnline\Entities\Kkt::__construct
|
||||
* @covers \AtolOnline\Entities\Kkt::__get
|
||||
* @covers \AtolOnline\Entities\Kkt::jsonSerialize
|
Loading…
Reference in New Issue
Block a user