2020-01-11 06:30:25 +00:00
|
|
|
<?php
|
2021-11-18 04:24:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
2020-01-11 06:30:25 +00:00
|
|
|
*
|
|
|
|
* This code is licensed under MIT.
|
|
|
|
* Этот код распространяется по лицензии MIT.
|
|
|
|
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
|
|
|
*/
|
|
|
|
|
2021-11-18 04:24:30 +00:00
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
namespace AtolOnline\Tests;
|
|
|
|
|
2020-04-17 12:10:50 +00:00
|
|
|
use AtolOnline\Entities\Entity;
|
2020-01-11 06:30:25 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class BasicTestCase
|
|
|
|
*/
|
|
|
|
class BasicTestCase extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
2021-11-18 04:24:30 +00:00
|
|
|
* @todo требуется рефакторинг
|
2020-01-11 06:30:25 +00:00
|
|
|
*/
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
//parent::setUp();
|
|
|
|
defined('ATOL_KKT_GROUP') ?: define('ATOL_KKT_GROUP', 'v4-online-atol-ru_4179');
|
|
|
|
defined('ATOL_KKT_LOGIN') ?: define('ATOL_KKT_LOGIN', 'v4-online-atol-ru');
|
|
|
|
defined('ATOL_KKT_PASS') ?: define('ATOL_KKT_PASS', 'iGFFuihss');
|
|
|
|
defined('ATOL_CALLBACK_URL') ?: define('ATOL_CALLBACK_URL', 'http://example.com/callback');
|
|
|
|
}
|
2021-11-18 04:24:30 +00:00
|
|
|
|
2020-01-11 06:30:25 +00:00
|
|
|
/**
|
2021-11-18 04:24:30 +00:00
|
|
|
* Тестирует является ли объект приводимым к json-строке согласно схеме АТОЛ Онлайн
|
|
|
|
*
|
2020-04-17 12:10:50 +00:00
|
|
|
* @param Entity $entity
|
2021-11-18 04:24:30 +00:00
|
|
|
* @param array $json_structure
|
|
|
|
* @covers \AtolOnline\Entities\Entity::jsonSerialize
|
|
|
|
* @covers \AtolOnline\Entities\Entity::__toString
|
2020-01-11 06:30:25 +00:00
|
|
|
*/
|
2021-11-18 04:24:30 +00:00
|
|
|
public function assertAtolable(Entity $entity, array $json_structure = []): void
|
2020-01-11 06:30:25 +00:00
|
|
|
{
|
2021-11-18 04:24:30 +00:00
|
|
|
$this->assertIsObject($entity);
|
|
|
|
$this->assertIsObject($entity->jsonSerialize());
|
|
|
|
$this->assertIsString((string)$entity);
|
2020-01-11 06:30:25 +00:00
|
|
|
$this->assertJson((string)$entity);
|
2021-11-18 04:24:30 +00:00
|
|
|
if ($json_structure) {
|
|
|
|
$this->assertEquals(json_encode($json_structure), (string)$entity);
|
|
|
|
}
|
2020-01-11 06:30:25 +00:00
|
|
|
}
|
2021-11-18 04:24:30 +00:00
|
|
|
|
2020-01-11 06:30:25 +00:00
|
|
|
/**
|
2021-11-18 04:24:30 +00:00
|
|
|
* Провайдер валидных телефонов
|
2020-01-11 06:30:25 +00:00
|
|
|
*
|
2021-11-18 04:24:30 +00:00
|
|
|
* @return array<array<string, string>>
|
2020-01-11 06:30:25 +00:00
|
|
|
*/
|
2021-11-18 04:24:30 +00:00
|
|
|
public function providerValidPhones(): array
|
2020-01-11 06:30:25 +00:00
|
|
|
{
|
2021-11-18 04:24:30 +00:00
|
|
|
return [
|
|
|
|
['+79991234567', '+79991234567'],
|
|
|
|
['79991234567', '+79991234567'],
|
|
|
|
['89991234567', '+89991234567'],
|
|
|
|
['+7 999 123 45 67', '+79991234567'],
|
|
|
|
['+7 (999) 123-45-67', '+79991234567'],
|
|
|
|
["+7 %(?9:9\"9')abc\r123\n45\t67\0", '+79991234567'],
|
|
|
|
];
|
2020-01-11 06:30:25 +00:00
|
|
|
}
|
2021-11-18 04:24:30 +00:00
|
|
|
|
2020-05-29 14:24:15 +00:00
|
|
|
/**
|
2021-11-18 04:24:30 +00:00
|
|
|
* Провайдер валидных email-ов
|
2020-05-29 14:24:15 +00:00
|
|
|
*
|
2021-11-18 04:24:30 +00:00
|
|
|
* @return array<array<string>>
|
2020-05-29 14:24:15 +00:00
|
|
|
*/
|
2021-11-18 04:24:30 +00:00
|
|
|
public function providerValidEmails(): array
|
2020-05-29 14:24:15 +00:00
|
|
|
{
|
2021-11-18 04:24:30 +00:00
|
|
|
return [
|
|
|
|
['abc@mail.com'],
|
|
|
|
['abc-d@mail.com'],
|
|
|
|
['abc.def@mail.com'],
|
|
|
|
['abc.def@mail.org'],
|
|
|
|
['abc.def@mail-archive.com'],
|
|
|
|
];
|
2020-05-29 14:24:15 +00:00
|
|
|
}
|
2020-01-11 06:30:25 +00:00
|
|
|
}
|