37 lines
994 B
PHP
37 lines
994 B
PHP
<?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],
|
|
];
|
|
}
|
|
}
|