snapshot of https://github.com/espocrm/espocrm.git (master, 2026-09-18; blobs > 131072B omitted)
Some checks failed
Test / Test on PHP 8.3 (push) Failing after 5s
Test / Test on PHP 8.4 (push) Failing after 4s
Test / Test on PHP 8.5 (push) Failing after 3s
TypeScript static analysis / TypeScript check (push) Failing after 14s
Test Integration on MySQL / Test on PHP 8.3 (push) Failing after 2s
Test Integration on MySQL / Test on PHP 8.5 (push) Failing after 0s
Test Integration on PostgreSQL / Test on PHP 8.4 fix (push) Failing after 1s
Test Integration on PostgreSQL / Test on PHP 8.4 master (push) Failing after 1s
Some checks failed
Test / Test on PHP 8.3 (push) Failing after 5s
Test / Test on PHP 8.4 (push) Failing after 4s
Test / Test on PHP 8.5 (push) Failing after 3s
TypeScript static analysis / TypeScript check (push) Failing after 14s
Test Integration on MySQL / Test on PHP 8.3 (push) Failing after 2s
Test Integration on MySQL / Test on PHP 8.5 (push) Failing after 0s
Test Integration on PostgreSQL / Test on PHP 8.4 fix (push) Failing after 1s
Test Integration on PostgreSQL / Test on PHP 8.4 master (push) Failing after 1s
This commit is contained in:
82
tests/unit/Espo/Core/Utils/ThemeManagerTest.php
Normal file
82
tests/unit/Espo/Core/Utils/ThemeManagerTest.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace tests\unit\Espo\Core\Utils;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Utils\Theme\Direction;
|
||||
use Espo\Core\Utils\Theme\MetadataProvider;
|
||||
use Espo\Core\Utils\ThemeManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ThemeManagerTest extends TestCase
|
||||
{
|
||||
public function testDirectionFromConfig(): void
|
||||
{
|
||||
$manager = $this->createManager(
|
||||
configValues: [
|
||||
'theme' => 'Espo',
|
||||
'themeParams.direction' => 'rtl',
|
||||
],
|
||||
);
|
||||
|
||||
$this->assertSame(Direction::Rtl, $manager->getDirection());
|
||||
}
|
||||
|
||||
public function testDirectionFromThemeDefault(): void
|
||||
{
|
||||
$manager = $this->createManager(
|
||||
configValues: [
|
||||
'theme' => 'Custom',
|
||||
'themeParams.direction' => 'invalid',
|
||||
],
|
||||
metadataValues: [
|
||||
'themes.Custom.params.direction.default' => 'rtl',
|
||||
],
|
||||
);
|
||||
|
||||
$this->assertSame(Direction::Rtl, $manager->getDirection());
|
||||
}
|
||||
|
||||
public function testInvalidDirectionFallsBackToLtr(): void
|
||||
{
|
||||
$manager = $this->createManager(
|
||||
configValues: [
|
||||
'theme' => 'Espo',
|
||||
'themeParams.direction' => 'invalid',
|
||||
],
|
||||
metadataValues: [
|
||||
'themes.Espo.params.direction.default' => 'invalid',
|
||||
],
|
||||
);
|
||||
|
||||
$this->assertSame(Direction::Ltr, $manager->getDirection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $configValues
|
||||
* @param array<string, mixed> $metadataValues
|
||||
*/
|
||||
private function createManager(array $configValues, array $metadataValues = []): ThemeManager
|
||||
{
|
||||
$config = $this->createMock(Config::class);
|
||||
$config
|
||||
->method('get')
|
||||
->willReturnCallback(fn (string $key) => $configValues[$key] ?? null);
|
||||
|
||||
$metadata = $this->createMock(Metadata::class);
|
||||
$metadata
|
||||
->method('get')
|
||||
->willReturnCallback(function (array|string $path) use ($metadataValues) {
|
||||
$key = is_array($path) ? implode('.', $path) : $path;
|
||||
|
||||
return $metadataValues[$key] ?? null;
|
||||
});
|
||||
|
||||
return new ThemeManager(
|
||||
$config,
|
||||
$metadata,
|
||||
$this->createMock(MetadataProvider::class),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user