chore: initial import for test contour

This commit is contained in:
sova-bootstrap
2026-05-27 19:36:32 +03:00
commit 166cdb148e
282 changed files with 84872 additions and 0 deletions
@@ -0,0 +1,16 @@
<?php
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class CalltouchControllerTest extends WebTestCase
{
public function testIndex(): void
{
$client = static::createClient();
$client->request('GET', '/calltouch');
self::assertResponseIsSuccessful();
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class CertificateControllerTest extends WebTestCase
{
public function testIndex(): void
{
$client = static::createClient();
$client->request('GET', '/certificate');
self::assertResponseIsSuccessful();
}
}
@@ -0,0 +1,88 @@
<?php
namespace App\Tests\Controller;
use App\Entity\User;
use App\Service\DecoderJWT\Interfaces\JWTDecoderServiceInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
final class InfoclinicaControllerTest extends WebTestCase
{
public function testClvisitsovacheckpassWithoutFilial(): void
{
$client = static::createClient();
// Тестируем GET запрос без filial - должен вернуть 404
$client->request('GET', '/infoclinica/clvisitsovacheckpass');
self::assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
}
public function testClvisitsovacheckpassWithInvalidFilial(): void
{
$client = static::createClient();
// Тестируем GET запрос с невалидным filial (не число) - должен вернуть 404
// requirements: ['filial' => '\d+'] требует только цифры
$client->request('GET', '/infoclinica/clvisitsovacheckpass/abc');
self::assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
}
public function testClvisitsovacheckpassWithPostMethod(): void
{
$client = static::createClient();
// Тестируем POST запрос - должен вернуть 405 Method Not Allowed
// так как эндпоинт принимает только GET
$client->request('POST', '/infoclinica/clvisitsovacheckpass/123');
self::assertResponseStatusCodeSame(Response::HTTP_METHOD_NOT_ALLOWED);
}
public function testClvisitsovacheckpassWithValidFilial(): void
{
$client = static::createClient();
// Мокируем JWTDecoderService через контейнер
$container = static::getContainer();
$jwtDecoderServiceMock = $this->createMock(JWTDecoderServiceInterface::class);
$user = $this->createMock(User::class);
$jwtDecoderServiceMock->method('getUser')->willReturn($user);
// Заменяем сервис в контейнере
$container->set(JWTDecoderServiceInterface::class, $jwtDecoderServiceMock);
// Тестируем GET запрос с валидным filial
$client->request('GET', '/infoclinica/clvisitsovacheckpass/123');
self::assertResponseIsSuccessful();
self::assertResponseHeaderSame('content-type', 'application/json');
$responseData = json_decode($client->getResponse()->getContent(), true);
self::assertTrue($responseData);
}
public function testClvisitsovacheckpassWithoutAuth(): void
{
$client = static::createClient();
// Мокируем JWTDecoderService чтобы вернуть null (нет пользователя)
$container = static::getContainer();
$jwtDecoderServiceMock = $this->createMock(JWTDecoderServiceInterface::class);
$jwtDecoderServiceMock->method('getUser')->willReturn(null);
// Заменяем сервис в контейнере
$container->set(JWTDecoderServiceInterface::class, $jwtDecoderServiceMock);
// Тестируем GET запрос без авторизации
$client->request('GET', '/infoclinica/clvisitsovacheckpass/123');
self::assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED);
$responseData = json_decode($client->getResponse()->getContent(), true);
self::assertArrayHasKey('error', $responseData);
self::assertEquals('Пользователь не найден', $responseData['error']);
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class InfoclinicaDoctorControllerTest extends WebTestCase
{
public function testIndex(): void
{
$client = static::createClient();
$client->request('GET', '/infoclinica/doctor');
self::assertResponseIsSuccessful();
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class LocationControllerTest extends WebTestCase
{
public function testIndex(): void
{
$client = static::createClient();
$client->request('GET', '/location');
self::assertResponseIsSuccessful();
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class ServiceControllerTest extends WebTestCase
{
public function testIndex(): void
{
$client = static::createClient();
$client->request('GET', '/service');
self::assertResponseIsSuccessful();
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class StockControllerTest extends WebTestCase
{
public function testIndex(): void
{
$client = static::createClient();
$client->request('GET', '/stock');
self::assertResponseIsSuccessful();
}
}