2021-12-18 06:45:00 +00:00
|
|
|
|
<?php
|
2022-12-14 16:19:55 +00:00
|
|
|
|
|
2021-12-18 06:45:00 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
|
|
|
|
*
|
|
|
|
|
* This code is licensed under MIT.
|
|
|
|
|
* Этот код распространяется по лицензии MIT.
|
|
|
|
|
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace AtolOnline\Tests\Api;
|
|
|
|
|
|
|
|
|
|
use AtolOnline\{
|
2022-12-14 16:19:55 +00:00
|
|
|
|
Constraints,
|
2021-12-18 06:45:00 +00:00
|
|
|
|
Helpers,
|
|
|
|
|
TestEnvParams,
|
|
|
|
|
Tests\BasicTestCase};
|
|
|
|
|
use AtolOnline\Api\{
|
|
|
|
|
AtolClient,
|
2021-12-19 14:29:17 +00:00
|
|
|
|
Fiscalizer};
|
2021-12-18 06:45:00 +00:00
|
|
|
|
use AtolOnline\Exceptions\{
|
|
|
|
|
AuthFailedException,
|
|
|
|
|
EmptyCorrectionNumberException,
|
|
|
|
|
EmptyGroupException,
|
|
|
|
|
EmptyItemNameException,
|
|
|
|
|
EmptyItemsException,
|
|
|
|
|
EmptyLoginException,
|
|
|
|
|
EmptyPasswordException,
|
|
|
|
|
InvalidCallbackUrlException,
|
|
|
|
|
InvalidCorrectionDateException,
|
|
|
|
|
InvalidEntityInCollectionException,
|
|
|
|
|
InvalidEnumValueException,
|
|
|
|
|
InvalidInnLengthException,
|
|
|
|
|
InvalidPaymentAddressException,
|
|
|
|
|
InvalidUuidException,
|
|
|
|
|
NegativeItemPriceException,
|
|
|
|
|
NegativeItemQuantityException,
|
|
|
|
|
NegativePaymentSumException,
|
|
|
|
|
TooHighItemPriceException,
|
|
|
|
|
TooHighPaymentSumException,
|
|
|
|
|
TooLongCallbackUrlException,
|
|
|
|
|
TooLongItemNameException,
|
|
|
|
|
TooLongPaymentAddressException,
|
|
|
|
|
TooManyException};
|
|
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Набор тестов для проверки работы фискализатора
|
|
|
|
|
*/
|
2021-12-19 14:29:17 +00:00
|
|
|
|
class FiscalizerTest extends BasicTestCase
|
2021-12-18 06:45:00 +00:00
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var array Массив UUID-ов результатов регистрации документов для переиспользования
|
|
|
|
|
* в тестах получения их статусов фискализации
|
|
|
|
|
*/
|
|
|
|
|
private static array $registered_uuids = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует успешное создание объекта фискализатора без аргументов конструктора
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer
|
2021-12-18 06:45:00 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testConstructorWithourArgs(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc = new Fiscalizer();
|
2021-12-18 06:45:00 +00:00
|
|
|
|
$this->assertIsObject($fisc);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$this->assertIsSameClass(Fiscalizer::class, $fisc);
|
2021-12-18 06:45:00 +00:00
|
|
|
|
$this->assertExtendsClasses([AtolClient::class], $fisc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует установку и возврат группы ККТ
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer
|
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::getGroup
|
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::setGroup
|
2021-12-18 06:45:00 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testGroup(): void
|
|
|
|
|
{
|
|
|
|
|
// test mode
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame(
|
2021-12-18 06:45:00 +00:00
|
|
|
|
TestEnvParams::FFD105()['group'],
|
2021-12-19 14:29:17 +00:00
|
|
|
|
(new Fiscalizer(group: 'group'))->getGroup()
|
2021-12-18 06:45:00 +00:00
|
|
|
|
);
|
|
|
|
|
// prod mode
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('group', (new Fiscalizer(false, group: 'group'))->getGroup());
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$this->assertNull((new Fiscalizer(false))->getGroup());
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует выброс исключения при попытке передать пустую группу ККТ в конструктор
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer
|
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::setGroup
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\EmptyGroupException
|
|
|
|
|
*/
|
|
|
|
|
public function testEmptyGroupException(): void
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(EmptyGroupException::class);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
new Fiscalizer(group: "\n\r \0\t");
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует выброс исключения при попытке установить слишком длинный адрес колбека
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::setCallbackUrl
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\TooLongCallbackUrlException
|
|
|
|
|
* @throws InvalidCallbackUrlException
|
|
|
|
|
* @throws TooLongCallbackUrlException
|
|
|
|
|
*/
|
|
|
|
|
public function testTooLongCallbackUrlException(): void
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooLongCallbackUrlException::class);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
(new Fiscalizer())->setCallbackUrl(Helpers::randomStr(Constraints::MAX_LENGTH_CALLBACK_URL + 1));
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует выброс исключения при попытке установить слишком длинный адрес колбека
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::setCallbackUrl
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\InvalidCallbackUrlException
|
|
|
|
|
* @throws InvalidCallbackUrlException
|
|
|
|
|
* @throws TooLongCallbackUrlException
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidCallbackUrlException(): void
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(InvalidCallbackUrlException::class);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
(new Fiscalizer())->setCallbackUrl(Helpers::randomStr());
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует обнуление адреса колбека
|
|
|
|
|
*
|
|
|
|
|
* @param mixed $param
|
|
|
|
|
* @return void
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::setCallbackUrl
|
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::getCallbackUrl
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @dataProvider providerNullableStrings
|
|
|
|
|
* @throws InvalidCallbackUrlException
|
|
|
|
|
* @throws TooLongCallbackUrlException
|
|
|
|
|
*/
|
|
|
|
|
public function testNullableCallbackUrl(mixed $param): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$this->assertNull((new Fiscalizer())->setCallbackUrl($param)->getCallbackUrl());
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует регистрацию документа прихода
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @covers \AtolOnline\Entities\Receipt::sell
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @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
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyItemNameException
|
|
|
|
|
* @throws EmptyItemsException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws NegativeItemPriceException
|
|
|
|
|
* @throws NegativeItemQuantityException
|
|
|
|
|
* @throws NegativePaymentSumException
|
|
|
|
|
* @throws TooHighItemPriceException
|
|
|
|
|
* @throws TooHighPaymentSumException
|
|
|
|
|
* @throws TooLongItemNameException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
* @throws TooManyException
|
|
|
|
|
* @throws GuzzleException
|
2022-12-14 16:19:55 +00:00
|
|
|
|
* @throws InvalidEnumValueException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testSell(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc_result = $this->newReceipt()->sell(new Fiscalizer());
|
|
|
|
|
$this->assertTrue($fisc_result->isSuccessful());
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('wait', $fisc_result->getContent()->status);
|
2021-12-18 06:45:00 +00:00
|
|
|
|
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует регистрацию документа возврата прихода
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @covers \AtolOnline\Entities\Receipt::sellRefund
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @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
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyItemNameException
|
|
|
|
|
* @throws EmptyItemsException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws NegativeItemPriceException
|
|
|
|
|
* @throws NegativeItemQuantityException
|
|
|
|
|
* @throws NegativePaymentSumException
|
|
|
|
|
* @throws TooHighItemPriceException
|
|
|
|
|
* @throws TooHighPaymentSumException
|
|
|
|
|
* @throws TooLongItemNameException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
* @throws TooManyException
|
|
|
|
|
* @throws GuzzleException
|
2022-12-14 16:19:55 +00:00
|
|
|
|
* @throws InvalidEnumValueException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testSellRefund(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc_result = $this->newReceipt()->sellRefund(new Fiscalizer());
|
|
|
|
|
$this->assertTrue($fisc_result->isSuccessful());
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('wait', $fisc_result->getContent()->status);
|
2021-12-18 06:45:00 +00:00
|
|
|
|
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует регистрацию документа возврата прихода
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @covers \AtolOnline\Entities\Correction::sellCorrect
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @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
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws NegativePaymentSumException
|
|
|
|
|
* @throws TooHighPaymentSumException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
* @throws EmptyCorrectionNumberException
|
|
|
|
|
* @throws InvalidCorrectionDateException
|
2022-12-14 16:19:55 +00:00
|
|
|
|
* @throws InvalidEnumValueException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testSellCorrect(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc_result = $this->newCorrection()->sellCorrect(new Fiscalizer());
|
|
|
|
|
$this->assertTrue($fisc_result->isSuccessful());
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('wait', $fisc_result->getContent()->status);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует регистрацию документа расхода
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @covers \AtolOnline\Entities\Receipt::buy
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @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
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyItemNameException
|
|
|
|
|
* @throws EmptyItemsException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws NegativeItemPriceException
|
|
|
|
|
* @throws NegativeItemQuantityException
|
|
|
|
|
* @throws NegativePaymentSumException
|
|
|
|
|
* @throws TooHighItemPriceException
|
|
|
|
|
* @throws TooHighPaymentSumException
|
|
|
|
|
* @throws TooLongItemNameException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
* @throws TooManyException
|
|
|
|
|
* @throws GuzzleException
|
2022-12-14 16:19:55 +00:00
|
|
|
|
* @throws InvalidEnumValueException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testBuy(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc_result = $this->newReceipt()->buy(new Fiscalizer());
|
|
|
|
|
$this->assertTrue($fisc_result->isSuccessful());
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('wait', $fisc_result->getContent()->status);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует регистрацию документа возврата расхода
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @covers \AtolOnline\Entities\Receipt::buyRefund
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @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
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyItemNameException
|
|
|
|
|
* @throws EmptyItemsException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws NegativeItemPriceException
|
|
|
|
|
* @throws NegativeItemQuantityException
|
|
|
|
|
* @throws NegativePaymentSumException
|
|
|
|
|
* @throws TooHighItemPriceException
|
|
|
|
|
* @throws TooHighPaymentSumException
|
|
|
|
|
* @throws TooLongItemNameException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
* @throws TooManyException
|
|
|
|
|
* @throws GuzzleException
|
2022-12-14 16:19:55 +00:00
|
|
|
|
* @throws InvalidEnumValueException
|
2021-12-18 06:45:00 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testBuyRefund(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc_result = $this->newReceipt()->buyRefund(new Fiscalizer());
|
|
|
|
|
$this->assertTrue($fisc_result->isSuccessful());
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('wait', $fisc_result->getContent()->status);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует регистрацию документа возврата прихода
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @covers \AtolOnline\Entities\Correction::buyCorrect
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @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
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidEntityInCollectionException
|
|
|
|
|
* @throws InvalidEnumValueException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws NegativePaymentSumException
|
|
|
|
|
* @throws TooHighPaymentSumException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
|
|
|
|
* @throws EmptyCorrectionNumberException
|
|
|
|
|
* @throws InvalidCorrectionDateException
|
|
|
|
|
*/
|
|
|
|
|
public function testBuyCorrect(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc_result = $this->newCorrection()->buyCorrect(new Fiscalizer());
|
|
|
|
|
$this->assertTrue($fisc_result->isSuccessful());
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('wait', $fisc_result->getContent()->status);
|
2021-12-19 14:29:17 +00:00
|
|
|
|
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует разовое получение статуса фискализации документа
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::getDocumentStatus
|
|
|
|
|
* @depends testSell
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidUuidException
|
|
|
|
|
*/
|
|
|
|
|
public function testGetDocumentStatus(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc_status = (new Fiscalizer())->getDocumentStatus(array_shift(self::$registered_uuids));
|
2021-12-19 15:06:12 +00:00
|
|
|
|
//$this->assertTrue($fisc_status->isSuccessful());
|
2021-12-18 06:45:00 +00:00
|
|
|
|
$this->assertTrue(in_array($fisc_status->getContent()->status, ['wait', 'done']));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует опрос API на получение статуса фискализации документа
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2021-12-19 14:29:17 +00:00
|
|
|
|
* @covers \AtolOnline\Api\Fiscalizer::pollDocumentStatus
|
|
|
|
|
* @depends testSellRefund
|
2021-12-18 06:45:00 +00:00
|
|
|
|
* @throws AuthFailedException
|
|
|
|
|
* @throws EmptyLoginException
|
|
|
|
|
* @throws EmptyPasswordException
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
* @throws InvalidUuidException
|
|
|
|
|
*/
|
|
|
|
|
public function testPollDocumentStatus(): void
|
|
|
|
|
{
|
2021-12-19 14:29:17 +00:00
|
|
|
|
$fisc_status = (new Fiscalizer())->pollDocumentStatus(array_shift(self::$registered_uuids));
|
2021-12-19 15:06:12 +00:00
|
|
|
|
//$this->assertTrue($fisc_status->isSuccessful());
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$this->assertSame('done', $fisc_status->getContent()->status);
|
2021-12-18 06:45:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|