Compare commits

..

No commits in common. "6551366d84037784c0341d154be71abda143775a" and "92a2c6cc48acb09d7d9e5e59112f9dd8f4fae13b" have entirely different histories.

3 changed files with 14 additions and 83 deletions

View File

@ -12,7 +12,6 @@ declare(strict_types = 1);
namespace AtolOnline\Api;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Collection;
use stdClass;
/**
@ -79,13 +78,13 @@ class KktMonitor extends AtolClient
*
* @param int|null $limit
* @param int|null $offset
* @return Collection
* @return KktResponse
* @throws GuzzleException
* @see https://online.atol.ru/files/API_service_information.pdf Документация, стр 9
*/
public function getAll(?int $limit = null, ?int $offset = null): Collection
public function getAll(?int $limit = null, ?int $offset = null): KktResponse
{
return collect($this->fetchAll($limit, $offset)->getContent());
return $this->fetchAll($limit, $offset);
}
/**

View File

@ -28,17 +28,12 @@ class BasicTestCase extends TestCase
* @param string $url
* @param int $code
* @return bool
* @throws GuzzleException
*/
protected function ping(string $url, int $code): bool
{
try {
$result = (new Client([
'http_errors' => false,
'timeout' => 3,
]))->request('GET', $url);
} catch (GuzzleException) {
return false;
}
$result = (new Client(['http_errors' => false]))->request('GET', $url);
//$this->assertEquals(200, $result->getStatusCode());
return $result->getStatusCode() === $code;
}

View File

@ -40,10 +40,6 @@ class KktMonitorTest extends BasicTestCase
* @covers \AtolOnline\Api\KktMonitor::getLogin
* @covers \AtolOnline\Api\KktMonitor::setPassword
* @covers \AtolOnline\Api\KktMonitor::getPassword
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws TooLongLoginException
* @throws TooLongPasswordException
*/
public function testConstructorWithArgs()
{
@ -59,8 +55,6 @@ class KktMonitorTest extends BasicTestCase
* @covers \AtolOnline\Api\KktMonitor::__construct
* @covers \AtolOnline\Api\KktMonitor::getLogin
* @covers \AtolOnline\Api\KktMonitor::setLogin
* @throws EmptyLoginException
* @throws TooLongLoginException
*/
public function testLogin()
{
@ -93,10 +87,6 @@ class KktMonitorTest extends BasicTestCase
* @covers \AtolOnline\Api\KktMonitor::__construct
* @covers \AtolOnline\Api\KktMonitor::setLogin
* @covers \AtolOnline\Exceptions\TooLongLoginException
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws TooLongLoginException
* @throws TooLongPasswordException
*/
public function testTooLongLoginException()
{
@ -110,8 +100,6 @@ class KktMonitorTest extends BasicTestCase
* @covers \AtolOnline\Api\KktMonitor::__construct
* @covers \AtolOnline\Api\KktMonitor::getPassword
* @covers \AtolOnline\Api\KktMonitor::setPassword
* @throws EmptyPasswordException
* @throws TooLongPasswordException
*/
public function testPassword()
{
@ -143,10 +131,6 @@ class KktMonitorTest extends BasicTestCase
*
* @covers \AtolOnline\Api\KktMonitor::__construct
* @covers \AtolOnline\Api\KktMonitor::setPassword
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws TooLongLoginException
* @throws TooLongPasswordException
*/
public function testConstructorWithLongPassword()
{
@ -191,7 +175,7 @@ class KktMonitorTest extends BasicTestCase
* @throws TooLongLoginException
* @throws TooLongPasswordException
*/
private function newTestClient(): KktMonitor
private function newTestClient(): AtolClient
{
$credentials = TestEnvParams::FFD105();
return (new KktMonitor(true))
@ -224,9 +208,8 @@ class KktMonitorTest extends BasicTestCase
/**
* Тестирует возврат токена после авторизации
*
* @depends testAuth
* @covers \AtolOnline\Api\KktMonitor::setToken
* @covers \AtolOnline\Api\KktMonitor::getToken
* @covers \AtolOnline\Api\KktMonitor::setToken
* @covers \AtolOnline\Api\KktMonitor::getToken
* @throws AuthFailedException
* @throws EmptyLoginException
* @throws EmptyPasswordException
@ -248,8 +231,7 @@ class KktMonitorTest extends BasicTestCase
/**
* Тестирует возврат объекта последнего ответа от API
*
* @depends testAuth
* @covers \AtolOnline\Api\KktMonitor::getResponse
* @covers \AtolOnline\Api\KktMonitor::getResponse
* @throws AuthFailedException
* @throws EmptyLoginException
* @throws EmptyPasswordException
@ -265,58 +247,13 @@ class KktMonitorTest extends BasicTestCase
$this->assertIsSameClass(KktResponse::class, $client->getResponse());
}
/**
* [Мониторинг] Тестирует получение данных о всех ККТ
*
* @depends testAuth
* @covers \AtolOnline\Api\KktMonitor::getMainEndpoint
* @covers \AtolOnline\Api\AtolClient::getUrlToMethod
* @covers \AtolOnline\Api\KktMonitor::fetchAll
* @covers \AtolOnline\Api\KktMonitor::getAll
* @throws AuthFailedException
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws GuzzleException
* @throws TooLongLoginException
* @throws TooLongPasswordException
*/
public function testMonitorGetAll()
public function todo_testGetAll()
{
$this->skipIfMonitoringIsOffline();
$client = $this->newTestClient();
$client->auth();
$kkts = $client->getAll();
$this->assertNotEmpty($client->getResponse()->getContent());
$this->assertIsCollection($kkts);
$this->assertTrue($kkts->count() > 0);
}
/**
* [Мониторинг] Тестирует получение данных о конкретной ККТ
*
* @depends testAuth
* @covers \AtolOnline\Api\KktMonitor::getMainEndpoint
* @covers \AtolOnline\Api\AtolClient::getUrlToMethod
* @covers \AtolOnline\Api\KktMonitor::fetchOne
* @covers \AtolOnline\Api\KktMonitor::getOne
* @throws AuthFailedException
* @throws EmptyLoginException
* @throws EmptyPasswordException
* @throws GuzzleException
* @throws TooLongLoginException
* @throws TooLongPasswordException
*/
public function testGetOne()
public function todo_testGetOne()
{
$this->skipIfMonitoringIsOffline();
$client = $this->newTestClient();
$client->auth();
$kkts = $client->getAll();
$serial_number = $kkts->first()->serialNumber;
$client->getOne($serial_number);
$this->assertIsSameClass(KktResponse::class, $client->getResponse());
$this->assertNotEmpty($client->getResponse());
$this->assertNotNull($client->getResponse()->data->serialNumber);
$this->assertEquals($serial_number, $client->getResponse()->data->serialNumber);
}
}