Миграция на php8.1

* enum-ы теперь enum-ы, а не говно -- теперь всё переведено на них, где это было возможно
* некоторые свойства классов объявлены в конструкторе
* некоторые классы перемещены в корневой неймспейс
* исправлен код-стайл, вычищен некоторый мусор, выправлены тесты... работы над этим продолжаются
This commit is contained in:
2022-12-15 00:19:55 +08:00
parent 692ae43f9f
commit 4157ab68f5
120 changed files with 1098 additions and 1401 deletions

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -10,7 +11,7 @@
namespace AtolOnline\Tests\Api;
use AtolOnline\{
Constants\Constraints,
Constraints,
Helpers,
TestEnvParams,
Tests\BasicTestCase};
@@ -79,12 +80,12 @@ class FiscalizerTest extends BasicTestCase
public function testGroup(): void
{
// test mode
$this->assertEquals(
$this->assertSame(
TestEnvParams::FFD105()['group'],
(new Fiscalizer(group: 'group'))->getGroup()
);
// prod mode
$this->assertEquals('group', (new Fiscalizer(false, group: 'group'))->getGroup());
$this->assertSame('group', (new Fiscalizer(false, group: 'group'))->getGroup());
$this->assertNull((new Fiscalizer(false))->getGroup());
}
@@ -164,7 +165,6 @@ class FiscalizerTest extends BasicTestCase
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws InvalidEntityInCollectionException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws NegativeItemPriceException
@@ -176,12 +176,13 @@ class FiscalizerTest extends BasicTestCase
* @throws TooLongPaymentAddressException
* @throws TooManyException
* @throws GuzzleException
* @throws InvalidEnumValueException
*/
public function testSell(): void
{
$fisc_result = $this->newReceipt()->sell(new Fiscalizer());
$this->assertTrue($fisc_result->isSuccessful());
$this->assertEquals('wait', $fisc_result->getContent()->status);
$this->assertSame('wait', $fisc_result->getContent()->status);
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
}
@@ -201,7 +202,6 @@ class FiscalizerTest extends BasicTestCase
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws InvalidEntityInCollectionException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws NegativeItemPriceException
@@ -213,12 +213,13 @@ class FiscalizerTest extends BasicTestCase
* @throws TooLongPaymentAddressException
* @throws TooManyException
* @throws GuzzleException
* @throws InvalidEnumValueException
*/
public function testSellRefund(): void
{
$fisc_result = $this->newReceipt()->sellRefund(new Fiscalizer());
$this->assertTrue($fisc_result->isSuccessful());
$this->assertEquals('wait', $fisc_result->getContent()->status);
$this->assertSame('wait', $fisc_result->getContent()->status);
self::$registered_uuids[] = $fisc_result->getContent()->uuid;
}
@@ -237,7 +238,6 @@ class FiscalizerTest extends BasicTestCase
* @throws EmptyPasswordException
* @throws GuzzleException
* @throws InvalidEntityInCollectionException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws NegativePaymentSumException
@@ -245,12 +245,13 @@ class FiscalizerTest extends BasicTestCase
* @throws TooLongPaymentAddressException
* @throws EmptyCorrectionNumberException
* @throws InvalidCorrectionDateException
* @throws InvalidEnumValueException
*/
public function testSellCorrect(): void
{
$fisc_result = $this->newCorrection()->sellCorrect(new Fiscalizer());
$this->assertTrue($fisc_result->isSuccessful());
$this->assertEquals('wait', $fisc_result->getContent()->status);
$this->assertSame('wait', $fisc_result->getContent()->status);
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
}
@@ -270,7 +271,6 @@ class FiscalizerTest extends BasicTestCase
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws InvalidEntityInCollectionException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws NegativeItemPriceException
@@ -282,12 +282,13 @@ class FiscalizerTest extends BasicTestCase
* @throws TooLongPaymentAddressException
* @throws TooManyException
* @throws GuzzleException
* @throws InvalidEnumValueException
*/
public function testBuy(): void
{
$fisc_result = $this->newReceipt()->buy(new Fiscalizer());
$this->assertTrue($fisc_result->isSuccessful());
$this->assertEquals('wait', $fisc_result->getContent()->status);
$this->assertSame('wait', $fisc_result->getContent()->status);
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
}
@@ -307,7 +308,6 @@ class FiscalizerTest extends BasicTestCase
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws InvalidEntityInCollectionException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws NegativeItemPriceException
@@ -319,12 +319,13 @@ class FiscalizerTest extends BasicTestCase
* @throws TooLongPaymentAddressException
* @throws TooManyException
* @throws GuzzleException
* @throws InvalidEnumValueException
*/
public function testBuyRefund(): void
{
$fisc_result = $this->newReceipt()->buyRefund(new Fiscalizer());
$this->assertTrue($fisc_result->isSuccessful());
$this->assertEquals('wait', $fisc_result->getContent()->status);
$this->assertSame('wait', $fisc_result->getContent()->status);
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
}
@@ -356,7 +357,7 @@ class FiscalizerTest extends BasicTestCase
{
$fisc_result = $this->newCorrection()->buyCorrect(new Fiscalizer());
$this->assertTrue($fisc_result->isSuccessful());
$this->assertEquals('wait', $fisc_result->getContent()->status);
$this->assertSame('wait', $fisc_result->getContent()->status);
//self::$registered_uuids[] = $fisc_result->getContent()->uuid;
}
@@ -395,6 +396,6 @@ class FiscalizerTest extends BasicTestCase
{
$fisc_status = (new Fiscalizer())->pollDocumentStatus(array_shift(self::$registered_uuids));
//$this->assertTrue($fisc_status->isSuccessful());
$this->assertEquals('done', $fisc_status->getContent()->status);
$this->assertSame('done', $fisc_status->getContent()->status);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -94,13 +95,13 @@ class MonitorTest extends BasicTestCase
public function testLogin(): void
{
$client = new Monitor(false, login: 'login');
$this->assertEquals('login', $client->getLogin());
$this->assertSame('login', $client->getLogin());
$client = new Monitor();
$this->assertEquals(TestEnvParams::FFD105()['login'], $client->getLogin());
$this->assertSame(TestEnvParams::FFD105()['login'], $client->getLogin());
$client->setLogin('login');
$this->assertEquals(TestEnvParams::FFD105()['login'], $client->getLogin());
$this->assertSame(TestEnvParams::FFD105()['login'], $client->getLogin());
}
/**
@@ -145,13 +146,13 @@ class MonitorTest extends BasicTestCase
public function testPassword(): void
{
$client = new Monitor(false, password: 'password');
$this->assertEquals('password', $client->getPassword());
$this->assertSame('password', $client->getPassword());
$client = new Monitor();
$this->assertEquals(TestEnvParams::FFD105()['password'], $client->getPassword());
$this->assertSame(TestEnvParams::FFD105()['password'], $client->getPassword());
$client->setPassword('password');
$this->assertEquals(TestEnvParams::FFD105()['password'], $client->getPassword());
$this->assertSame(TestEnvParams::FFD105()['password'], $client->getPassword());
}
/**
@@ -204,9 +205,6 @@ class MonitorTest extends BasicTestCase
$client = (new Monitor())->setTestMode();
$this->assertTrue($client->isTestMode());
$client = (new Monitor())->setTestMode(true);
$this->assertTrue($client->isTestMode());
$client = (new Monitor())->setTestMode(false);
$this->assertFalse($client->isTestMode());
}
@@ -302,7 +300,6 @@ class MonitorTest extends BasicTestCase
$client = $this->newTestClient();
$client->auth();
$kkts = $client->getAll();
$sss = $kkts->where('deviceNumber', 'KKT014034');
$this->assertNotEmpty($client->getLastResponse()->getContent());
$this->assertIsCollection($kkts);
$this->assertTrue($kkts->count() > 0);
@@ -342,6 +339,6 @@ class MonitorTest extends BasicTestCase
$this->assertIsSameClass(Kkt::class, $kkt);
$this->assertIsAtolable($kkt);
$this->assertNotNull($kkt->serialNumber);
$this->assertEquals($serial_number, $kkt->serialNumber);
$this->assertSame($serial_number, $kkt->serialNumber);
}
}