Bicycle/tests/Unit/CoreTest.php
Egor Isaev b516ca07dc Initial commit: Bicycle PHP MVC micro-framework
Core MVC, HTTP client, Session, Cookie, Config, HTTPException — 111 PHPUnit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 10:04:19 +03:00

77 lines
2.1 KiB
PHP

<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
use System\Classes\Core;
class CoreTest extends TestCase
{
public function testFindFileInSyspath(): void
{
$path = Core::findFile('view/errors', '404', 'html');
$this->assertIsString($path);
$this->assertStringEndsWith('view/errors/404.html', $path);
$this->assertStringContainsString('System', $path);
}
public function testFindFileInApppath(): void
{
$path = Core::findFile('view/Index', 'index', 'html');
$this->assertIsString($path);
$this->assertStringEndsWith('index.html', $path);
$this->assertStringContainsString('App', $path);
}
public function testFindFileReturnsFalseWhenNotFound(): void
{
$result = Core::findFile('view', 'nonexistent_xyz_file', 'html');
$this->assertFalse($result);
}
public function testFindFileWithDefaultExtension(): void
{
// EXT = '.php', findFile без третьего аргумента ищет .php
$path = Core::findFile('Classes', 'Core');
$this->assertIsString($path);
$this->assertStringEndsWith('Classes/Core.php', $path);
}
public function testFindFileReturnsFullPath(): void
{
$path = Core::findFile('view/errors', '404', 'html');
$this->assertStringStartsWith(SYSPATH, $path);
$this->assertFileExists($path);
}
public function testGetConstProduction(): void
{
$this->assertSame(10, Core::getConst('PRODUCTION'));
}
public function testGetConstStaging(): void
{
$this->assertSame(20, Core::getConst('STAGING'));
}
public function testGetConstTesting(): void
{
$this->assertSame(30, Core::getConst('TESTING'));
}
public function testGetConstDevelopment(): void
{
$this->assertSame(40, Core::getConst('DEVELOPMENT'));
}
public function testDefaultEnvironmentIsDevelopment(): void
{
$this->assertSame(Core::DEVELOPMENT, Core::$environment);
}
public function testCharsetIsUtf8(): void
{
$this->assertSame('utf-8', Core::$charset);
}
}