You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace Tests\Unit;
use App\Support\PortalLocale;
use App\Support\SignupDisplay;
use App\Support\SignupOptionCatalog;
use Tests\TestCase;
class SignupOptionCatalogTest extends TestCase
{
public function test_event_location_aliases_cover_chinese_and_english(): void
{
$this->assertSame('suzhou', SignupOptionCatalog::normalize('event_location', '苏州'));
$this->assertSame('suzhou', SignupOptionCatalog::normalize('event_location', 'Suzhou'));
$this->assertSame('suzhou', SignupOptionCatalog::normalize('event_location', 'suzhou'));
$this->assertSame('suzhou', SignupOptionCatalog::normalize('event_location', 'SUZHOU'));
$this->assertTrue(SignupOptionCatalog::same('event_location', '苏州', 'suzhou'));
$this->assertTrue(SignupOptionCatalog::same('event_location', 'Suzhou', 'suzhou'));
$this->assertFalse(SignupOptionCatalog::same('event_location', '苏州', 'shanghai'));
$aliases = SignupOptionCatalog::expandAliases('event_location', ['suzhou']);
$this->assertContains('suzhou', $aliases);
$this->assertContains('苏州', $aliases);
$this->assertContains('Suzhou', $aliases);
}
public function test_catalog_label_uses_chinese_for_admin_display(): void
{
$this->assertSame('本科', SignupDisplay::catalogLabel('degree', 'bachelor'));
$this->assertSame('中国', SignupDisplay::catalogLabel('location_country', 'cn'));
$this->assertSame('苏州', SignupDisplay::catalogLabel('event_location', 'suzhou'));
$this->assertSame('本科', SignupDisplay::catalogLabel('degree', '本科'));
$this->assertSame('Bachelor’s Degree', SignupDisplay::catalogLabel('degree', 'bachelor', PortalLocale::EN));
$this->assertSame('China', SignupDisplay::catalogLabel('location_country', 'cn', PortalLocale::EN));
$this->assertSame('Suzhou', SignupDisplay::catalogLabel('event_location', 'suzhou', PortalLocale::EN));
}
}