chore: initial import for test contour
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Service;
|
||||
|
||||
use App\Service\Client\Interfaces\InfoclinicaClientServiceInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Prophecy\Prophet;
|
||||
|
||||
|
||||
class InfoclinicaClientServiceTest extends TestCase
|
||||
{
|
||||
private $clientServiceMock;
|
||||
private $prophet;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->prophet = new Prophet();
|
||||
$this->clientServiceMock = $this->prophet->prophesize(InfoclinicaClientServiceInterface::class);
|
||||
}
|
||||
|
||||
private function expectedResult()
|
||||
{
|
||||
return [
|
||||
'schedule' => [
|
||||
'990000082' => [
|
||||
'20250520' => [
|
||||
'schedident' => 30240229,
|
||||
'rnum' => '2.06',
|
||||
'dcode' => 30001414,
|
||||
'filial' => 3,
|
||||
'intervals' => [
|
||||
[
|
||||
'time' => '14:30-15:00',
|
||||
'isFree' => false
|
||||
],
|
||||
[
|
||||
'time' => '15:00-15:30',
|
||||
'isFree' => false
|
||||
],
|
||||
[
|
||||
'time' => '15:30-16:00',
|
||||
'isFree' => false
|
||||
]
|
||||
],
|
||||
'depnum' => 990000082,
|
||||
'isFree' => false
|
||||
],
|
||||
]
|
||||
],
|
||||
'nearestDate' => []
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetSchedule(): void
|
||||
{
|
||||
// Подготовка данных
|
||||
$queryString = '?st=20250516&en=20250530&dcode=30001414&onlineMode=0&filial=3';
|
||||
|
||||
// Настройка мок-объекта
|
||||
$this->clientServiceMock
|
||||
->getSchedule($queryString)
|
||||
->willReturn($this->expectedResult());
|
||||
|
||||
$service = $this->clientServiceMock->reveal();
|
||||
|
||||
$result = $service->getSchedule($queryString);
|
||||
|
||||
$this->assertEquals($this->expectedResult(), $result);
|
||||
}
|
||||
|
||||
public function testGetScheduleWithEmptyQuery(): void
|
||||
{
|
||||
$queryString = '';
|
||||
$expectedExceptionMessage = 'Query string cannot be empty';
|
||||
|
||||
$this->clientServiceMock
|
||||
->getSchedule($queryString)
|
||||
->willThrow(new \InvalidArgumentException($expectedExceptionMessage));
|
||||
|
||||
$service = $this->clientServiceMock->reveal();
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage($expectedExceptionMessage);
|
||||
|
||||
$service->getSchedule($queryString);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user