2016-03-25 01:18:05 -07:00
|
|
|
|
<?php
|
2021-11-30 20:09:29 -08:00
|
|
|
|
namespace Tests\Unit;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
|
use App\Models\CustomField;
|
2023-03-07 16:57:55 -08:00
|
|
|
|
use Tests\TestCase;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
2017-01-26 16:57:23 -08:00
|
|
|
|
/*
|
|
|
|
|
* Test strings for db column names gathered from
|
|
|
|
|
* http://www.omniglot.com/language/phrases/hovercraft.htm
|
|
|
|
|
*/
|
2023-03-07 16:57:55 -08:00
|
|
|
|
class CustomFieldTest extends TestCase
|
2016-03-25 01:18:05 -07:00
|
|
|
|
{
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testFormat()
|
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
|
$customfield = CustomField::factory()->make(['format' => 'IP']);
|
2018-12-06 20:05:04 -08:00
|
|
|
|
$this->assertEquals($customfield->getAttributes()['format'], CustomField::PREDEFINED_FORMATS['IP']); //this seems undocumented...
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->format, 'IP');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testDbNameAscii()
|
|
|
|
|
{
|
|
|
|
|
$customfield = new CustomField();
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$customfield->name = 'My hovercraft is full of eels';
|
2017-03-14 08:39:03 -07:00
|
|
|
|
$customfield->id = 1337;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_my_hovercraft_is_full_of_eels_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
2017-01-26 16:57:23 -08:00
|
|
|
|
// Western Europe
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testDbNameLatin()
|
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$customfield = new CustomField();
|
|
|
|
|
$customfield->name = 'My hovercraft is full of eels';
|
2017-01-26 16:57:23 -08:00
|
|
|
|
$customfield->id = 1337;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_my_hovercraft_is_full_of_eels_1337');
|
2017-01-26 16:57:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Asian
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testDbNameChinese()
|
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$customfield = new CustomField();
|
|
|
|
|
$customfield->name = '我的氣墊船裝滿了鱔魚';
|
2017-01-26 16:57:23 -08:00
|
|
|
|
$customfield->id = 1337;
|
2017-03-14 08:39:03 -07:00
|
|
|
|
if (function_exists('transliterator_transliterate')) {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_wo_de_qi_dian_chuan_zhuang_man_le_shan_yu_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
} else {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_aecsae0ase1eaeaeoees_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
}
|
2017-01-26 16:57:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testDbNameJapanese()
|
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$customfield = new CustomField();
|
|
|
|
|
$customfield->name = '私のホバークラフトは鰻でいっぱいです';
|
2017-01-26 16:57:23 -08:00
|
|
|
|
$customfield->id = 1337;
|
2017-03-14 08:39:03 -07:00
|
|
|
|
if (function_exists('transliterator_transliterate')) {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_sinohohakurafutoha_manteihhaitesu_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
} else {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_caafafafaafcafafae0aaaaaaa_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
}
|
2017-01-26 16:57:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testDbNameKorean()
|
|
|
|
|
{
|
|
|
|
|
$customfield = new CustomField();
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$customfield->name = '내 호버크라프트는 장어로 가득 차 있어요';
|
2017-01-26 16:57:23 -08:00
|
|
|
|
$customfield->id = 1337;
|
2017-03-14 08:39:03 -07:00
|
|
|
|
if (function_exists('transliterator_transliterate')) {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_nae_hobeokeulapeuteuneun_jang_eolo_gadeug_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
} else {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_e_ie2ieiises_izieoe_e0e_i0_iziis_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
}
|
2017-01-26 16:57:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Nordic languages
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testDbNameNonLatinEuro()
|
|
|
|
|
{
|
|
|
|
|
$customfield = new CustomField();
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$customfield->name = 'Mój poduszkowiec jest pełen węgorzy';
|
2017-01-26 16:57:23 -08:00
|
|
|
|
$customfield->id = 1337;
|
2017-03-14 08:39:03 -07:00
|
|
|
|
if (function_exists('transliterator_transliterate')) {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_moj_poduszkowiec_jest_pelen_wegorzy_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
} else {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_ma3j_poduszkowiec_jest_peaen_waegorzy_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
}
|
2017-01-26 16:57:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testDbNameTurkish()
|
|
|
|
|
{
|
|
|
|
|
$customfield = new CustomField();
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$customfield->name = 'Hoverkraftım yılan balığı dolu';
|
2017-01-26 16:57:23 -08:00
|
|
|
|
$customfield->id = 1337;
|
2017-03-14 08:39:03 -07:00
|
|
|
|
if (function_exists('transliterator_transliterate')) {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_hoverkraftim_yilan_baligi_dolu_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
} else {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_hoverkraftaem_yaelan_balaeaeyae_dolu_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
}
|
2017-01-26 16:57:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 08:39:03 -07:00
|
|
|
|
public function testDbNameArabic()
|
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$customfield = new CustomField();
|
|
|
|
|
$customfield->name = 'حَوّامتي مُمْتِلئة بِأَنْقَلَيْسون';
|
2017-01-26 16:57:23 -08:00
|
|
|
|
$customfield->id = 1337;
|
2017-03-14 08:39:03 -07:00
|
|
|
|
if (function_exists('transliterator_transliterate')) {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_hwamty_mmtlyt_banqlyswn_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
} else {
|
2021-06-10 13:15:52 -07:00
|
|
|
|
$this->assertEquals($customfield->convertUnicodeDbSlug(), '_snipeit_ouzuuouoaus_uuuuoauuooc_ououzuuuuzuuzusuo_1337');
|
2017-03-14 08:39:03 -07:00
|
|
|
|
}
|
2017-01-26 16:57:23 -08:00
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
|
}
|