chore: initial import for test contour with k3s CI
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class OnlineSpecialistsControllerTest extends WebTestCase
|
||||
{
|
||||
private const BROWSER_HEADERS = ['HTTP_USER_AGENT' => 'PHPUnit/OnlineConsultationTest'];
|
||||
|
||||
public function testOnlineSpecialistsRequiresAuthentication(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/online-specialists', [], [], self::BROWSER_HEADERS);
|
||||
|
||||
$this->assertTrue(
|
||||
$client->getResponse()->isRedirect() || $client->getResponse()->getStatusCode() === 401,
|
||||
'Online specialists page must require authentication'
|
||||
);
|
||||
}
|
||||
|
||||
public function testOfflineSpecialistsListIsPublic(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/specialists', [], [], self::BROWSER_HEADERS);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testIntervalApiRequiresParameters(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/api/interval', [], [], self::BROWSER_HEADERS);
|
||||
|
||||
$this->assertGreaterThanOrEqual(400, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Unit\Support;
|
||||
|
||||
use App\Support\OnlineMode;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class OnlineModeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider onlineValuesProvider
|
||||
*/
|
||||
public function testIsOnline(mixed $input, bool $expected): void
|
||||
{
|
||||
$this->assertSame($expected, OnlineMode::isOnline($input));
|
||||
$this->assertSame($expected ? 1 : 0, OnlineMode::toInt($input));
|
||||
}
|
||||
|
||||
public function onlineValuesProvider(): array
|
||||
{
|
||||
return [
|
||||
'int 1' => [1, true],
|
||||
'int 0' => [0, false],
|
||||
'string 1' => ['1', true],
|
||||
'string 0' => ['0', false],
|
||||
'true bool' => [true, true],
|
||||
'false bool' => [false, false],
|
||||
'true string' => ['true', true],
|
||||
'false string' => ['false', false],
|
||||
'yes' => ['yes', true],
|
||||
'empty' => ['', false],
|
||||
'null' => [null, false],
|
||||
'garbage' => ['maybe', false],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
|
||||
require dirname(__DIR__).'/config/bootstrap.php';
|
||||
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
|
||||
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
|
||||
}
|
||||
Reference in New Issue
Block a user