mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-10-28 19:18:58 -04:00
- Rename tests/helpers/ to tests/Helpers/ and add Tests\Helpers namespace - Move CI3SecretConverterTest into tests/Libraries/ to eliminate duplicate case-conflict directory - Map Config\ in composer.json PSR-4 autoloading - Remove obsolete PHP 7 polyfill (random_compat) and redundant laminas-escaper - Clean up unused dev dependencies (fakerphp, vfsstream, predis) and update tooling - Safeguard table prefix restoration in migration_helper and reset config mock in LocaleHelperTest
68 lines
1.6 KiB
PHP
68 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Helpers;
|
|
|
|
use CodeIgniter\Config\Factories;
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
|
use Config\OSPOS;
|
|
|
|
class LocaleHelperTest extends CIUnitTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
require_once __DIR__ . '/../../app/Helpers/locale_helper.php';
|
|
|
|
$config = new OSPOS();
|
|
$config->settings = ['dateformat' => 'Y-m-d'];
|
|
Factories::injectMock('config', OSPOS::class, $config);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
Factories::reset();
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function testValidDateReturnsTrue(): void
|
|
{
|
|
$this->assertTrue(isValidDate('2024-06-10'));
|
|
}
|
|
|
|
public function testInvalidDateFormatReturnsFalse(): void
|
|
{
|
|
$this->assertFalse(isValidDate('10/06/2024'));
|
|
}
|
|
|
|
public function testImpossibleDateReturnsFalse(): void
|
|
{
|
|
$this->assertFalse(isValidDate('2024-13-01'));
|
|
}
|
|
|
|
public function testPhpDateOverflowReturnsFalse(): void
|
|
{
|
|
// PHP silently overflows Feb 30 → Mar 1; the format()===candidate check catches this
|
|
$this->assertFalse(isValidDate('2024-02-30'));
|
|
}
|
|
|
|
public function testEmptyStringReturnsFalse(): void
|
|
{
|
|
$this->assertFalse(isValidDate(''));
|
|
}
|
|
|
|
public function testLeapDayValidReturnsTrue(): void
|
|
{
|
|
$this->assertTrue(isValidDate('2024-02-29'));
|
|
}
|
|
|
|
public function testLeapDayInvalidYearReturnsFalse(): void
|
|
{
|
|
$this->assertFalse(isValidDate('2023-02-29'));
|
|
}
|
|
|
|
public function testPartialDateReturnsFalse(): void
|
|
{
|
|
$this->assertFalse(isValidDate('2024-06'));
|
|
}
|
|
}
|