Files
upstream-espocrm/tests/unit/Espo/Tools/LeadCapture/ThemeDirectionDetectorTest.php
upstream-mirror 7cc7e6b4f3
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 1s
Test Integration on MySQL / Test on PHP 8.5 (push) Failing after 1s
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
snapshot of https://github.com/espocrm/espocrm.git (master, 2026-09-18; blobs > 131072B omitted)
2026-09-18 04:19:15 +05:00

47 lines
1.3 KiB
PHP

<?php
namespace tests\unit\Espo\Tools\LeadCapture;
use Espo\Core\Utils\Language;
use Espo\Core\Utils\Theme\Direction;
use Espo\Entities\LeadCapture;
use Espo\Tools\LeadCapture\ThemeDirectionDetector;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class ThemeDirectionDetectorTest extends TestCase
{
/**
* @return iterable<string, array{string, Direction}>
*/
public static function directionProvider(): iterable
{
yield ['ar_AR', Direction::Rtl];
yield ['fa_IR', Direction::Rtl];
yield ['he_IL', Direction::Rtl];
yield ['ur_IN', Direction::Rtl];
yield ['en_US', Direction::Ltr];
yield ['tr_TR', Direction::Ltr];
}
#[DataProvider('directionProvider')]
public function testDirectionFromFormLanguage(string $language, Direction $expected): void
{
$leadCapture = $this->createMock(LeadCapture::class);
$leadCapture
->method('getFormLanguage')
->willReturn($language);
$language = $this->createMock(Language::class);
$language
->method('getLanguage')
->willReturn('en_US');
$detector = new ThemeDirectionDetector(
language: $language,
);
$this->assertEquals($expected, $detector->detect($leadCapture));
}
}