Compare commits

...

7 Commits

Author SHA1 Message Date
XGUI
1eaeeb502b N° 5874 - Quick create: improvement for newcomer
Hide Popular section when empty
2024-11-28 16:55:44 +01:00
xavier.guiboud-ribaud@combodo.com
e7a3e7de90 N°5874 - Quick create: improvement for newcomer
Fix tests
2024-11-27 08:18:49 +01:00
xavier.guiboud-ribaud@combodo.com
d16757f8f0 N°5874 - Quick create: improvement for newcomer
Rework tests for readability
2024-11-27 08:01:30 +01:00
xavier.guiboud-ribaud@combodo.com
b9ad9dcded 5874
Add comments to tests for clarity
Add setUp and tearDown methods on tests
Add classes on history and popular sections
2024-11-25 12:10:10 +01:00
xavier.guiboud-ribaud@combodo.com
44fa08278d 5874
Add comments to tests for clarity
2024-11-22 16:34:09 +01:00
xavier.guiboud-ribaud@combodo.com
585072a478 5874
Change description of parameters and functions
Add comments in twig for clarity
Add default popular category to UserRequest and FunctionalCI classes
Add comments to tests for clarity
2024-11-22 14:02:39 +01:00
XavierGR
dc2064450b N°5874 - Quick create: improvement for newcomer 2024-11-21 15:11:55 +01:00
26 changed files with 364 additions and 170 deletions

View File

@@ -1436,6 +1436,14 @@ class Config
'quick_create.max_history_results' => [ 'quick_create.max_history_results' => [
'type' => 'integer', 'type' => 'integer',
'description' => 'Max. number of elements in the history', 'description' => 'Max. number of elements in the history',
'default' => 5,
'value' => 5,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'quick_create.max_popular_results' => [
'type' => 'integer',
'description' => 'Max. number of elements in the popular classes section',
'default' => 10, 'default' => 10,
'value' => 10, 'value' => 10,
'source_of_value' => '', 'source_of_value' => '',

View File

@@ -4,7 +4,7 @@
<class id="FunctionalCI" _delta="define"> <class id="FunctionalCI" _delta="define">
<parent>cmdbAbstractObject</parent> <parent>cmdbAbstractObject</parent>
<properties> <properties>
<category>bizmodel,searchable</category> <category>bizmodel,searchable,popular</category>
<abstract>true</abstract> <abstract>true</abstract>
<key_type>autoincrement</key_type> <key_type>autoincrement</key_type>
<db_table>functionalci</db_table> <db_table>functionalci</db_table>

View File

@@ -10,7 +10,7 @@
* @copyright Copyright (C) 2010-2024 Combodo SAS * @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0 * @license http://opensource.org/licenses/AGPL-3.0
*/]]></comment> */]]></comment>
<category>bizmodel,searchable,requestmgmt</category> <category>bizmodel,searchable,requestmgmt,popular</category>
<abstract>false</abstract> <abstract>false</abstract>
<key_type>autoincrement</key_type> <key_type>autoincrement</key_type>
<db_table>ticket_request</db_table> <db_table>ticket_request</db_table>

View File

@@ -10,7 +10,7 @@
* @copyright Copyright (C) 2010-2024 Combodo SAS * @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0 * @license http://opensource.org/licenses/AGPL-3.0
*/]]></comment> */]]></comment>
<category>bizmodel,searchable,requestmgmt</category> <category>bizmodel,searchable,requestmgmt,popular</category>
<abstract>false</abstract> <abstract>false</abstract>
<key_type>autoincrement</key_type> <key_type>autoincrement</key_type>
<db_table>ticket_request</db_table> <db_table>ticket_request</db_table>

View File

@@ -15,5 +15,6 @@ Dict::Add('CS CZ', 'Czech', 'Čeština', [
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~',
'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~',
'UI:Component:QuickCreate:MostPopular:Title' => 'Populární',
'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('DA DA', 'Danish', 'Dansk', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~', 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~',
'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular~~',
'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~',
'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('DE DE', 'German', 'Deutsch', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Wählen Sie einen Objekttyp aus...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Wählen Sie einen Objekttyp aus...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Quick-Create-Menu öffnen', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Quick-Create-Menu öffnen',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Sie haben noch keine Objekte erstellt', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Sie haben noch keine Objekte erstellt',
'UI:Component:QuickCreate:MostPopular:Title' => 'Am beliebtesten',
'UI:Component:QuickCreate:Recents:Title' => 'Letzte', 'UI:Component:QuickCreate:Recents:Title' => 'Letzte',
'UI:Component:QuickCreate:Tooltip' => 'Erstellen Sie schnell jeden Typ von Objekt', 'UI:Component:QuickCreate:Tooltip' => 'Erstellen Sie schnell jeden Typ von Objekt',
]); ]);

View File

@@ -23,6 +23,7 @@ Dict::Add('EN US', 'English', 'English', array(
'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...',
'UI:Component:QuickCreate:Recents:Title' => 'Recents', 'UI:Component:QuickCreate:Recents:Title' => 'Recents',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet',
'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular',
'UI:Component:QuickCreate:HistoryDisabled' => 'History is disabled', 'UI:Component:QuickCreate:HistoryDisabled' => 'History is disabled',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create',
)); ));

View File

@@ -10,6 +10,7 @@ Dict::Add('EN GB', 'British English', 'British English', array(
'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...',
'UI:Component:QuickCreate:Recents:Title' => 'Recents', 'UI:Component:QuickCreate:Recents:Title' => 'Recents',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet',
'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular',
'UI:Component:QuickCreate:HistoryDisabled' => 'History is disabled', 'UI:Component:QuickCreate:HistoryDisabled' => 'History is disabled',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create',
)); ));

View File

@@ -12,6 +12,7 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Seleccionar tipo de objeto...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Seleccionar tipo de objeto...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Abrir creación rápida', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Abrir creación rápida',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Aún no has creado ningún objeto.', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Aún no has creado ningún objeto.',
'UI:Component:QuickCreate:MostPopular:Title' => 'Más popular',
'UI:Component:QuickCreate:Recents:Title' => 'Recientes', 'UI:Component:QuickCreate:Recents:Title' => 'Recientes',
'UI:Component:QuickCreate:Tooltip' => 'Crear rápidamente cualquier tipo de objeto', 'UI:Component:QuickCreate:Tooltip' => 'Crear rápidamente cualquier tipo de objeto',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('FR FR', 'French', 'Français', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Type d\'objet...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Type d\'objet...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Ouvrir la création rapide', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Ouvrir la création rapide',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Vous n\'avez pas encore créé d\'objet', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Vous n\'avez pas encore créé d\'objet',
'UI:Component:QuickCreate:MostPopular:Title' => 'Populaires',
'UI:Component:QuickCreate:Recents:Title' => 'Types récents', 'UI:Component:QuickCreate:Recents:Title' => 'Types récents',
'UI:Component:QuickCreate:Tooltip' => 'Création rapide de n\'importe quel objet', 'UI:Component:QuickCreate:Tooltip' => 'Création rapide de n\'importe quel objet',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('HU HU', 'Hungarian', 'Magyar', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Objektumtípus kiválasztása...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Objektumtípus kiválasztása...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Gyors létrehozás megnyitása', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Gyors létrehozás megnyitása',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Még nem hozott létre objektumot', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Még nem hozott létre objektumot',
'UI:Component:QuickCreate:MostPopular:Title' => 'Legnépszerűbb',
'UI:Component:QuickCreate:Recents:Title' => 'Legutóbbiak', 'UI:Component:QuickCreate:Recents:Title' => 'Legutóbbiak',
'UI:Component:QuickCreate:Tooltip' => 'Bármilyen típusú objektum gyors létrehozása', 'UI:Component:QuickCreate:Tooltip' => 'Bármilyen típusú objektum gyors létrehozása',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('IT IT', 'Italian', 'Italiano', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Seleziona il tipo di oggetto...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Seleziona il tipo di oggetto...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Apri la creazione rapida', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Apri la creazione rapida',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Non hai ancora creato alcun oggetto', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Non hai ancora creato alcun oggetto',
'UI:Component:QuickCreate:MostPopular:Title' => 'Più popolari',
'UI:Component:QuickCreate:Recents:Title' => 'Recenti', 'UI:Component:QuickCreate:Recents:Title' => 'Recenti',
'UI:Component:QuickCreate:Tooltip' => 'Crea rapidamente qualsiasi tipo di oggetto', 'UI:Component:QuickCreate:Tooltip' => 'Crea rapidamente qualsiasi tipo di oggetto',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('JA JP', 'Japanese', '日本語', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~', 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~',
'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular~~',
'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~',
'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Selecteer een objectsoort…', 'UI:Component:QuickCreate:Input:Placeholder' => 'Selecteer een objectsoort…',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open snel object aanmaken', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open snel object aanmaken',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Je hebt nog geen objecten gemaakt', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Je hebt nog geen objecten gemaakt',
'UI:Component:QuickCreate:MostPopular:Title' => 'Meest populair',
'UI:Component:QuickCreate:Recents:Title' => 'Recente', 'UI:Component:QuickCreate:Recents:Title' => 'Recente',
'UI:Component:QuickCreate:Tooltip' => 'Snel een object aanmaken', 'UI:Component:QuickCreate:Tooltip' => 'Snel een object aanmaken',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('PL PL', 'Polish', 'Polski', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Wybierz typ obiektu...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Wybierz typ obiektu...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Otwórz szybkie tworzenie', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Otwórz szybkie tworzenie',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Nie utworzyłeś jeszcze żadnego obiektu', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Nie utworzyłeś jeszcze żadnego obiektu',
'UI:Component:QuickCreate:MostPopular:Title' => 'Najbardziej popularne',
'UI:Component:QuickCreate:Recents:Title' => 'Ostatnie', 'UI:Component:QuickCreate:Recents:Title' => 'Ostatnie',
'UI:Component:QuickCreate:Tooltip' => 'Szybko utwórz dowolny rodzaj obiektu', 'UI:Component:QuickCreate:Tooltip' => 'Szybko utwórz dowolny rodzaj obiektu',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Selecione o tipo de objeto...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Selecione o tipo de objeto...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Abrir criação rápida', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Abrir criação rápida',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Você ainda não criou nenhum objeto', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Você ainda não criou nenhum objeto',
'UI:Component:QuickCreate:MostPopular:Title' => 'Mais popular',
'UI:Component:QuickCreate:Recents:Title' => 'Recentes', 'UI:Component:QuickCreate:Recents:Title' => 'Recentes',
'UI:Component:QuickCreate:Tooltip' => 'Crie rapidamente qualquer tipo de objeto', 'UI:Component:QuickCreate:Tooltip' => 'Crie rapidamente qualquer tipo de objeto',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('RU RU', 'Russian', 'Русский', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Выбрать тип объекта...', 'UI:Component:QuickCreate:Input:Placeholder' => 'Выбрать тип объекта...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Открыть быстрое создание объекта', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Открыть быстрое создание объекта',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Вы ещё не создавали объекты', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Вы ещё не создавали объекты',
'UI:Component:QuickCreate:MostPopular:Title' => 'Популярные',
'UI:Component:QuickCreate:Recents:Title' => 'Недавние', 'UI:Component:QuickCreate:Recents:Title' => 'Недавние',
'UI:Component:QuickCreate:Tooltip' => 'Быстрое создание объекта любого типа', 'UI:Component:QuickCreate:Tooltip' => 'Быстрое создание объекта любого типа',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('SK SK', 'Slovak', 'Slovenčina', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~', 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~',
'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular~~',
'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~',
'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', [
'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~', 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~',
'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular~~',
'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~',
'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~',
]); ]);

View File

@@ -14,6 +14,7 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', [
'UI:Component:QuickCreate:Input:Placeholder' => '请选择对象类型...', 'UI:Component:QuickCreate:Input:Placeholder' => '请选择对象类型...',
'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => '打开快速创建', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => '打开快速创建',
'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => '您尚未创建任何对象', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => '您尚未创建任何对象',
'UI:Component:QuickCreate:MostPopular:Title' => '最常用',
'UI:Component:QuickCreate:Recents:Title' => '最近', 'UI:Component:QuickCreate:Recents:Title' => '最近',
'UI:Component:QuickCreate:Tooltip' => '快速创建任意类型的对象', 'UI:Component:QuickCreate:Tooltip' => '快速创建任意类型的对象',
]); ]);

View File

@@ -59,10 +59,14 @@ class QuickCreate extends UIBlock implements iKeyboardShortcut
protected $aLastClasses; protected $aLastClasses;
/** @var int $iMaxAutocompleteResults Max. number of elements returned by the autocomplete */ /** @var int $iMaxAutocompleteResults Max. number of elements returned by the autocomplete */
protected $iMaxAutocompleteResults; protected $iMaxAutocompleteResults;
/** @var bool $bShowHistory Whether or not to display the elements in the history */ /** @var bool $bShowHistory Whether to display the elements in the history */
protected $bShowHistory; protected $bShowHistory;
/** @var int $iMaxHistoryResults Max. number of elements in the history */ /** @var int $iMaxHistoryResults Max. number of elements in the history */
protected $iMaxHistoryResults; protected $iMaxHistoryResults;
/** @var int $iMaxPopularResults Max. number of elements in the popular section */
protected $iMaxPopularResults;
/** @var array $aPopularClasses */
protected $aPopularClasses;
/** /**
* QuickCreate constructor. * QuickCreate constructor.
@@ -82,6 +86,8 @@ class QuickCreate extends UIBlock implements iKeyboardShortcut
$this->iMaxAutocompleteResults = (int) MetaModel::GetConfig()->Get('quick_create.max_autocomplete_results'); $this->iMaxAutocompleteResults = (int) MetaModel::GetConfig()->Get('quick_create.max_autocomplete_results');
$this->bShowHistory = (bool) MetaModel::GetConfig()->Get('quick_create.show_history'); $this->bShowHistory = (bool) MetaModel::GetConfig()->Get('quick_create.show_history');
$this->iMaxHistoryResults = (int) MetaModel::GetConfig()->Get('quick_create.max_history_results'); $this->iMaxHistoryResults = (int) MetaModel::GetConfig()->Get('quick_create.max_history_results');
$this->iMaxPopularResults = (int) MetaModel::GetConfig()->Get('quick_create.max_popular_results');
$this->aPopularClasses = QuickCreateHelper::GetPopularClasses();
} }
/** /**
@@ -89,7 +95,7 @@ class QuickCreate extends UIBlock implements iKeyboardShortcut
* If $bRelativeUrl is true, then $sEndpoint will be complete with the app_root_url * If $bRelativeUrl is true, then $sEndpoint will be complete with the app_root_url
* *
* @param string $sEndpoint URL to the endpoint * @param string $sEndpoint URL to the endpoint
* @param bool $bRelativeUrl Whether or not the $sEndpoint parameter is a relative URL * @param bool $bRelativeUrl Whether the $sEndpoint parameter is a relative URL
* *
* @return $this * @return $this
* @throws \Exception * @throws \Exception
@@ -203,6 +209,24 @@ class QuickCreate extends UIBlock implements iKeyboardShortcut
return $this->iMaxHistoryResults; return $this->iMaxHistoryResults;
} }
/**
* @see $aMaxPopularClasses
* @return array
*/
public function GetPopularClasses(): array
{
return $this->aPopularClasses;
}
/**
* @see $iMaxPopularResults
* @return int
*/
public function GetMaxPopularResults(): int
{
return $this->iMaxPopularResults;
}
public static function GetShortcutKeys(): array public static function GetShortcutKeys(): array
{ {
return [['id' => 'ibo-open-quick-create', 'label' => 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer', 'key' => 'c', 'event' => 'open_drawer']]; return [['id' => 'ibo-open-quick-create', 'label' => 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer', 'key' => 'c', 'event' => 'open_drawer']];

View File

@@ -24,6 +24,7 @@ use appUserPreferences;
use DBObject; use DBObject;
use MetaModel; use MetaModel;
use utils; use utils;
use UserRights;
/** /**
* Class QuickCreateHelper * Class QuickCreateHelper
@@ -71,7 +72,7 @@ class QuickCreateHelper
array_unshift($aHistoryEntries, $aNewEntry); array_unshift($aHistoryEntries, $aNewEntry);
// Truncate history // Truncate history
static::TruncateHistory($aHistoryEntries); static::Truncate($aHistoryEntries, 'quick_create.max_history_results');
appUserPreferences::SetPref(static::USER_PREF_CODE, $aHistoryEntries); appUserPreferences::SetPref(static::USER_PREF_CODE, $aHistoryEntries);
} }
@@ -88,7 +89,8 @@ class QuickCreateHelper
{ {
/** @var array $aHistoryEntries */ /** @var array $aHistoryEntries */
$aHistoryEntries = appUserPreferences::GetPref(static::USER_PREF_CODE, []); $aHistoryEntries = appUserPreferences::GetPref(static::USER_PREF_CODE, []);
static::TruncateHistory($aHistoryEntries);
static::Truncate($aHistoryEntries, 'quick_create.max_history_results');
for($iIdx = 0; $iIdx < count($aHistoryEntries); $iIdx++) for($iIdx = 0; $iIdx < count($aHistoryEntries); $iIdx++)
{ {
@@ -125,16 +127,70 @@ class QuickCreateHelper
} }
/** /**
* Truncate $aHistoryEntries to 'global_search.max_history_results' entries * Return an array of popular object classes
* *
* @param array $aHistoryEntries * @return array
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/ */
protected static function TruncateHistory(array &$aHistoryEntries): void public static function GetPopularClasses(): array
{ {
$iMaxHistoryResults = (int) MetaModel::GetConfig()->Get('quick_create.max_history_results'); $aHistoryEntries = appUserPreferences::GetPref(static::USER_PREF_CODE, []);
if(count($aHistoryEntries) > $iMaxHistoryResults) static::Truncate($aHistoryEntries, 'quick_create.max_history_results');
$aPopularClassesNames = UserRights::GetAllowedClasses(UR_ACTION_CREATE, array('popular'), false);
// Prevent classes in both Popular and Recent to appear twice
for($iIdx = 0; $iIdx < count($aHistoryEntries); $iIdx++)
{ {
$aHistoryEntries = array_slice($aHistoryEntries, 0, $iMaxHistoryResults); if (($key = array_search($aHistoryEntries[$iIdx]['class'], $aPopularClassesNames)) !== false) {
unset($aPopularClassesNames[$key]);
}
}
//die(var_dump($aPopularClassesNames));
static::Truncate($aPopularClassesNames, 'quick_create.max_popular_results');
$aPopularClasses = array();
foreach($aPopularClassesNames as $sClass)
{
if (!MetaModel::IsValidClass($sClass)) {
continue;
}
// Add class icon
$sClassIconUrl = MetaModel::GetClassIcon($sClass, false);
// Mind that some classes don't have an icon
$sClassIconUrl = !empty($sClassIconUrl) ? $sClassIconUrl : null;
// Add class label
$sLabelHtml = utils::EscapeHtml(MetaModel::GetName($sClass));
// Add URL
$sTargetUrl = DBObject::ComputeStandardUIPage($sClass).'?operation=new&class='.$sClass;
$aPopularClasses[] = array(
'class' => $sClass,
'icon_url' => $sClassIconUrl,
'label_html' => $sLabelHtml,
'target_url' => $sTargetUrl
);
}
return $aPopularClasses;
}
/**
* Truncate an array to $sMaxEntriesParam
*
* @param array $aEntries
* @param string $sMaxEntriesParam
*/
protected static function Truncate(array &$aEntries, string $sMaxEntriesParam = 'global_search.max_history_results'): void
{
$iMaxResults = (int) MetaModel::GetConfig()->Get($sMaxEntriesParam);
if(count($aEntries) > $iMaxResults)
{
$aEntries = array_slice($aEntries, 0, $iMaxResults);
} }
} }
} }

View File

@@ -20,10 +20,11 @@
<div class="ibo-quick-create--compartment"> <div class="ibo-quick-create--compartment">
<div class="ibo-quick-create--compartment-content" data-role="ibo-quick-create--compartment-results"> <div class="ibo-quick-create--compartment-content" data-role="ibo-quick-create--compartment-results">
</div> </div>
<div class="ibo-quick-create--compartment-title" data-role="ibo-quick-create--compartment-title"> {# History section #}
<div class="ibo-quick-create--compartment-title ibo-quick-create--history-classes--title" data-role="ibo-quick-create--compartment-title">
<span>{{ 'UI:Component:QuickCreate:Recents:Title'|dict_s }}</span> <span>{{ 'UI:Component:QuickCreate:Recents:Title'|dict_s }}</span>
</div> </div>
<div class="ibo-quick-create--compartment-content" data-role="ibo-quick-create--compartment-content"> <div class="ibo-quick-create--compartment-content ibo-quick-create--history-classes--content" data-role="ibo-quick-create--compartment-content">
{% if oUIBlock.GetShowHistory == false %} {% if oUIBlock.GetShowHistory == false %}
<div class="ibo-quick-create--compartment--placeholder"> <div class="ibo-quick-create--compartment--placeholder">
<div class="ibo-quick-create--compartment--placeholder-hint">{{ 'UI:Component:QuickCreate:HistoryDisabled'|dict_s }}</div> <div class="ibo-quick-create--compartment--placeholder-hint">{{ 'UI:Component:QuickCreate:HistoryDisabled'|dict_s }}</div>
@@ -48,6 +49,23 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
{# Popular classes section #}
{% if oUIBlock.GetPopularClasses()|length > 0 %}
<div class="ibo-quick-create--compartment-title ibo-quick-create--popular-classes--title" data-role="ibo-quick-create--compartment-title">
<span>{{ 'UI:Component:QuickCreate:MostPopular:Title'|dict_s }}</span>
</div>
<div class="ibo-quick-create--compartment-content ibo-quick-create--popular-classes--content" data-role="ibo-quick-create--compartment-content">
{% for aClass in oUIBlock.GetPopularClasses() %}
<a href="{{ aClass.target_url }}" class="ibo-quick-create--compartment-element" data-role="ibo-quick-create--compartment-element" data-class-code="{{ aQuery.class }}">
{% if aClass.icon_url is defined and aClass.icon_url is not null%}
{# Mind the empty "alt" attribute https://www.w3.org/WAI/tutorials/images/decorative/ #}
<img src="{{ aClass.icon_url}}" alt="" class="ibo-quick-create--compartment-element-image">
{% endif %}
{{ aClass.label_html|raw }}
</a>
{% endfor %}
</div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -9,30 +9,30 @@
"packages-dev": [ "packages-dev": [
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
"version": "1.5.0", "version": "2.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/instantiator.git", "url": "https://github.com/doctrine/instantiator.git",
"reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0",
"reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0" "php": "^8.1"
}, },
"require-dev": { "require-dev": {
"doctrine/coding-standard": "^9 || ^11", "doctrine/coding-standard": "^11",
"ext-pdo": "*", "ext-pdo": "*",
"ext-phar": "*", "ext-phar": "*",
"phpbench/phpbench": "^0.16 || ^1", "phpbench/phpbench": "^1.2",
"phpstan/phpstan": "^1.4", "phpstan/phpstan": "^1.9.4",
"phpstan/phpstan-phpunit": "^1", "phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", "phpunit/phpunit": "^9.5.27",
"vimeo/psalm": "^4.30 || ^5.4" "vimeo/psalm": "^5.4"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@@ -59,7 +59,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/doctrine/instantiator/issues", "issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.5.0" "source": "https://github.com/doctrine/instantiator/tree/2.0.0"
}, },
"funding": [ "funding": [
{ {
@@ -75,20 +75,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-12-30T00:15:36+00:00" "time": "2022-12-30T00:23:10+00:00"
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
"version": "1.11.0", "version": "1.12.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/myclabs/DeepCopy.git", "url": "https://github.com/myclabs/DeepCopy.git",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -96,11 +96,12 @@
}, },
"conflict": { "conflict": {
"doctrine/collections": "<1.6.8", "doctrine/collections": "<1.6.8",
"doctrine/common": "<2.13.3 || >=3,<3.2.2" "doctrine/common": "<2.13.3 || >=3 <3.2.2"
}, },
"require-dev": { "require-dev": {
"doctrine/collections": "^1.6.8", "doctrine/collections": "^1.6.8",
"doctrine/common": "^2.13.3 || ^3.2.2", "doctrine/common": "^2.13.3 || ^3.2.2",
"phpspec/prophecy": "^1.10",
"phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
}, },
"type": "library", "type": "library",
@@ -126,7 +127,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/myclabs/DeepCopy/issues", "issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1"
}, },
"funding": [ "funding": [
{ {
@@ -134,29 +135,31 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-03-03T13:19:32+00:00" "time": "2024-11-08T17:47:46+00:00"
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v4.15.2", "version": "v5.3.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc" "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b",
"reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-ctype": "*",
"ext-json": "*",
"ext-tokenizer": "*", "ext-tokenizer": "*",
"php": ">=7.0" "php": ">=7.4"
}, },
"require-dev": { "require-dev": {
"ircmaxell/php-yacc": "^0.0.7", "ircmaxell/php-yacc": "^0.0.7",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" "phpunit/phpunit": "^9.0"
}, },
"bin": [ "bin": [
"bin/php-parse" "bin/php-parse"
@@ -164,7 +167,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "4.9-dev" "dev-master": "5.0-dev"
} }
}, },
"autoload": { "autoload": {
@@ -188,26 +191,27 @@
], ],
"support": { "support": {
"issues": "https://github.com/nikic/PHP-Parser/issues", "issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.15.2" "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1"
}, },
"time": "2022-11-12T15:38:23+00:00" "time": "2024-10-08T18:51:32+00:00"
}, },
{ {
"name": "phar-io/manifest", "name": "phar-io/manifest",
"version": "2.0.3", "version": "2.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phar-io/manifest.git", "url": "https://github.com/phar-io/manifest.git",
"reference": "97803eca37d319dfa7826cc2437fc020857acb53" "reference": "54750ef60c58e43759730615a392c31c80e23176"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176",
"reference": "97803eca37d319dfa7826cc2437fc020857acb53", "reference": "54750ef60c58e43759730615a392c31c80e23176",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
"ext-libxml": "*",
"ext-phar": "*", "ext-phar": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"phar-io/version": "^3.0.1", "phar-io/version": "^3.0.1",
@@ -248,9 +252,15 @@
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"support": { "support": {
"issues": "https://github.com/phar-io/manifest/issues", "issues": "https://github.com/phar-io/manifest/issues",
"source": "https://github.com/phar-io/manifest/tree/2.0.3" "source": "https://github.com/phar-io/manifest/tree/2.0.4"
}, },
"time": "2021-07-20T11:28:43+00:00" "funding": [
{
"url": "https://github.com/theseer",
"type": "github"
}
],
"time": "2024-03-03T12:33:53+00:00"
}, },
{ {
"name": "phar-io/version", "name": "phar-io/version",
@@ -305,44 +315,44 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "9.2.23", "version": "9.2.32",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c" "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5",
"reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
"ext-libxml": "*", "ext-libxml": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"nikic/php-parser": "^4.14", "nikic/php-parser": "^4.19.1 || ^5.1.0",
"php": ">=7.3", "php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3", "phpunit/php-file-iterator": "^3.0.6",
"phpunit/php-text-template": "^2.0.2", "phpunit/php-text-template": "^2.0.4",
"sebastian/code-unit-reverse-lookup": "^2.0.2", "sebastian/code-unit-reverse-lookup": "^2.0.3",
"sebastian/complexity": "^2.0", "sebastian/complexity": "^2.0.3",
"sebastian/environment": "^5.1.2", "sebastian/environment": "^5.1.5",
"sebastian/lines-of-code": "^1.0.3", "sebastian/lines-of-code": "^1.0.4",
"sebastian/version": "^3.0.1", "sebastian/version": "^3.0.2",
"theseer/tokenizer": "^1.2.0" "theseer/tokenizer": "^1.2.3"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.3" "phpunit/phpunit": "^9.6"
}, },
"suggest": { "suggest": {
"ext-pcov": "*", "ext-pcov": "PHP extension that provides line coverage",
"ext-xdebug": "*" "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "9.2-dev" "dev-main": "9.2.x-dev"
} }
}, },
"autoload": { "autoload": {
@@ -370,7 +380,8 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.23" "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32"
}, },
"funding": [ "funding": [
{ {
@@ -378,7 +389,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-12-28T12:41:10+00:00" "time": "2024-08-22T04:23:01+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@@ -623,50 +634,50 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "9.5.27", "version": "9.6.21",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa",
"reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"doctrine/instantiator": "^1.3.1", "doctrine/instantiator": "^1.5.0 || ^2",
"ext-dom": "*", "ext-dom": "*",
"ext-json": "*", "ext-json": "*",
"ext-libxml": "*", "ext-libxml": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-xml": "*", "ext-xml": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.10.1", "myclabs/deep-copy": "^1.12.0",
"phar-io/manifest": "^2.0.3", "phar-io/manifest": "^2.0.4",
"phar-io/version": "^3.0.2", "phar-io/version": "^3.2.1",
"php": ">=7.3", "php": ">=7.3",
"phpunit/php-code-coverage": "^9.2.13", "phpunit/php-code-coverage": "^9.2.32",
"phpunit/php-file-iterator": "^3.0.5", "phpunit/php-file-iterator": "^3.0.6",
"phpunit/php-invoker": "^3.1.1", "phpunit/php-invoker": "^3.1.1",
"phpunit/php-text-template": "^2.0.3", "phpunit/php-text-template": "^2.0.4",
"phpunit/php-timer": "^5.0.2", "phpunit/php-timer": "^5.0.3",
"sebastian/cli-parser": "^1.0.1", "sebastian/cli-parser": "^1.0.2",
"sebastian/code-unit": "^1.0.6", "sebastian/code-unit": "^1.0.8",
"sebastian/comparator": "^4.0.8", "sebastian/comparator": "^4.0.8",
"sebastian/diff": "^4.0.3", "sebastian/diff": "^4.0.6",
"sebastian/environment": "^5.1.3", "sebastian/environment": "^5.1.5",
"sebastian/exporter": "^4.0.5", "sebastian/exporter": "^4.0.6",
"sebastian/global-state": "^5.0.1", "sebastian/global-state": "^5.0.7",
"sebastian/object-enumerator": "^4.0.3", "sebastian/object-enumerator": "^4.0.4",
"sebastian/resource-operations": "^3.0.3", "sebastian/resource-operations": "^3.0.4",
"sebastian/type": "^3.2", "sebastian/type": "^3.2.1",
"sebastian/version": "^3.0.2" "sebastian/version": "^3.0.2"
}, },
"suggest": { "suggest": {
"ext-soap": "*", "ext-soap": "To be able to generate mocks based on WSDL files",
"ext-xdebug": "*" "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage"
}, },
"bin": [ "bin": [
"phpunit" "phpunit"
@@ -674,7 +685,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "9.5-dev" "dev-master": "9.6-dev"
} }
}, },
"autoload": { "autoload": {
@@ -705,7 +716,8 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21"
}, },
"funding": [ "funding": [
{ {
@@ -721,20 +733,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-12-09T07:31:23+00:00" "time": "2024-09-19T10:50:18+00:00"
}, },
{ {
"name": "sebastian/cli-parser", "name": "sebastian/cli-parser",
"version": "1.0.1", "version": "1.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/cli-parser.git", "url": "https://github.com/sebastianbergmann/cli-parser.git",
"reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b",
"reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -769,7 +781,7 @@
"homepage": "https://github.com/sebastianbergmann/cli-parser", "homepage": "https://github.com/sebastianbergmann/cli-parser",
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/cli-parser/issues", "issues": "https://github.com/sebastianbergmann/cli-parser/issues",
"source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2"
}, },
"funding": [ "funding": [
{ {
@@ -777,7 +789,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-09-28T06:08:49+00:00" "time": "2024-03-02T06:27:43+00:00"
}, },
{ {
"name": "sebastian/code-unit", "name": "sebastian/code-unit",
@@ -966,20 +978,20 @@
}, },
{ {
"name": "sebastian/complexity", "name": "sebastian/complexity",
"version": "2.0.2", "version": "2.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/complexity.git", "url": "https://github.com/sebastianbergmann/complexity.git",
"reference": "739b35e53379900cc9ac327b2147867b8b6efd88" "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a",
"reference": "739b35e53379900cc9ac327b2147867b8b6efd88", "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"nikic/php-parser": "^4.7", "nikic/php-parser": "^4.18 || ^5.0",
"php": ">=7.3" "php": ">=7.3"
}, },
"require-dev": { "require-dev": {
@@ -1011,7 +1023,7 @@
"homepage": "https://github.com/sebastianbergmann/complexity", "homepage": "https://github.com/sebastianbergmann/complexity",
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/complexity/issues", "issues": "https://github.com/sebastianbergmann/complexity/issues",
"source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3"
}, },
"funding": [ "funding": [
{ {
@@ -1019,20 +1031,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-10-26T15:52:27+00:00" "time": "2023-12-22T06:19:30+00:00"
}, },
{ {
"name": "sebastian/diff", "name": "sebastian/diff",
"version": "4.0.4", "version": "4.0.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/diff.git", "url": "https://github.com/sebastianbergmann/diff.git",
"reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc",
"reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1077,7 +1089,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/diff/issues", "issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6"
}, },
"funding": [ "funding": [
{ {
@@ -1085,20 +1097,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-10-26T13:10:38+00:00" "time": "2024-03-02T06:30:58+00:00"
}, },
{ {
"name": "sebastian/environment", "name": "sebastian/environment",
"version": "5.1.4", "version": "5.1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/environment.git", "url": "https://github.com/sebastianbergmann/environment.git",
"reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed",
"reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1140,7 +1152,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/environment/issues", "issues": "https://github.com/sebastianbergmann/environment/issues",
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5"
}, },
"funding": [ "funding": [
{ {
@@ -1148,20 +1160,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-04-03T09:37:03+00:00" "time": "2023-02-03T06:03:51+00:00"
}, },
{ {
"name": "sebastian/exporter", "name": "sebastian/exporter",
"version": "4.0.5", "version": "4.0.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git", "url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72",
"reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1217,7 +1229,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues", "issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6"
}, },
"funding": [ "funding": [
{ {
@@ -1225,20 +1237,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-09-14T06:03:37+00:00" "time": "2024-03-02T06:33:00+00:00"
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",
"version": "5.0.5", "version": "5.0.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git", "url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9",
"reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1281,7 +1293,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues", "issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7"
}, },
"funding": [ "funding": [
{ {
@@ -1289,24 +1301,24 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-02-14T08:28:10+00:00" "time": "2024-03-02T06:35:11+00:00"
}, },
{ {
"name": "sebastian/lines-of-code", "name": "sebastian/lines-of-code",
"version": "1.0.3", "version": "1.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/lines-of-code.git", "url": "https://github.com/sebastianbergmann/lines-of-code.git",
"reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5",
"reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"nikic/php-parser": "^4.6", "nikic/php-parser": "^4.18 || ^5.0",
"php": ">=7.3" "php": ">=7.3"
}, },
"require-dev": { "require-dev": {
@@ -1338,7 +1350,7 @@
"homepage": "https://github.com/sebastianbergmann/lines-of-code", "homepage": "https://github.com/sebastianbergmann/lines-of-code",
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
"source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4"
}, },
"funding": [ "funding": [
{ {
@@ -1346,7 +1358,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-11-28T06:42:11+00:00" "time": "2023-12-22T06:20:34+00:00"
}, },
{ {
"name": "sebastian/object-enumerator", "name": "sebastian/object-enumerator",
@@ -1462,16 +1474,16 @@
}, },
{ {
"name": "sebastian/recursion-context", "name": "sebastian/recursion-context",
"version": "4.0.4", "version": "4.0.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git", "url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1510,10 +1522,10 @@
} }
], ],
"description": "Provides functionality to recursively process PHP variables", "description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context", "homepage": "https://github.com/sebastianbergmann/recursion-context",
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues", "issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5"
}, },
"funding": [ "funding": [
{ {
@@ -1521,20 +1533,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-10-26T13:17:30+00:00" "time": "2023-02-03T06:07:39+00:00"
}, },
{ {
"name": "sebastian/resource-operations", "name": "sebastian/resource-operations",
"version": "3.0.3", "version": "3.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/resource-operations.git", "url": "https://github.com/sebastianbergmann/resource-operations.git",
"reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e",
"reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1546,7 +1558,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.0-dev" "dev-main": "3.0-dev"
} }
}, },
"autoload": { "autoload": {
@@ -1567,8 +1579,7 @@
"description": "Provides a list of PHP built-in functions that operate on resources", "description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations", "homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/resource-operations/issues", "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4"
"source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
}, },
"funding": [ "funding": [
{ {
@@ -1576,20 +1587,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-09-28T06:45:17+00:00" "time": "2024-03-14T16:00:52+00:00"
}, },
{ {
"name": "sebastian/type", "name": "sebastian/type",
"version": "3.2.0", "version": "3.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/type.git", "url": "https://github.com/sebastianbergmann/type.git",
"reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7",
"reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1624,7 +1635,7 @@
"homepage": "https://github.com/sebastianbergmann/type", "homepage": "https://github.com/sebastianbergmann/type",
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/type/issues", "issues": "https://github.com/sebastianbergmann/type/issues",
"source": "https://github.com/sebastianbergmann/type/tree/3.2.0" "source": "https://github.com/sebastianbergmann/type/tree/3.2.1"
}, },
"funding": [ "funding": [
{ {
@@ -1632,7 +1643,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-09-12T14:47:03+00:00" "time": "2023-02-03T06:13:03+00:00"
}, },
{ {
"name": "sebastian/version", "name": "sebastian/version",
@@ -1727,16 +1738,16 @@
}, },
{ {
"name": "theseer/tokenizer", "name": "theseer/tokenizer",
"version": "1.2.1", "version": "1.2.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/theseer/tokenizer.git", "url": "https://github.com/theseer/tokenizer.git",
"reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
"reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1765,7 +1776,7 @@
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"support": { "support": {
"issues": "https://github.com/theseer/tokenizer/issues", "issues": "https://github.com/theseer/tokenizer/issues",
"source": "https://github.com/theseer/tokenizer/tree/1.2.1" "source": "https://github.com/theseer/tokenizer/tree/1.2.3"
}, },
"funding": [ "funding": [
{ {
@@ -1773,15 +1784,15 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-07-28T10:34:58+00:00" "time": "2024-03-03T12:36:25+00:00"
} }
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": {},
"platform-dev": [], "platform-dev": {},
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }

View File

@@ -0,0 +1,60 @@
<?php
namespace Application\UI\Base\Components\QuickCreate;
use appUserPreferences;
use Combodo\iTop\Application\UI\Base\Component\QuickCreate\QuickCreateHelper;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
class QuickCreateHelperTest extends ItopDataTestCase
{
public function testPopularClassesShouldBeLeftUnchangedWhenNotInRecent()
{
// Given popular classes = ['FunctionalCI', 'UserRequest'], as defined in datamodel
$this->GivenRecentClasses(['Person']);
$aPopularClasses = QuickCreateHelper::GetPopularClasses();
$this->AssertPopularClassesMatches(['FunctionalCI', 'UserRequest'], $aPopularClasses, "");
}
public function testPopularClassesShouldBeLeftUnchangedWhenNoRecent()
{
// Given popular classes = ['FunctionalCI', 'UserRequest'], as defined in datamodel
$this->GivenRecentClasses([]);
$aPopularClasses = QuickCreateHelper::GetPopularClasses();
$this->AssertPopularClassesMatches(['FunctionalCI', 'UserRequest'], $aPopularClasses, "");
}
public function testClassInRecentShouldNotBeInPopular()
{
// Given popular classes = ['FunctionalCI', 'UserRequest'], as defined in datamodel
$this->GivenRecentClasses(['UserRequest']);
$aPopularClasses = QuickCreateHelper::GetPopularClasses();
$this->AssertPopularClassesMatches(['FunctionalCI'], $aPopularClasses, "");
}
private function GivenRecentClasses(array $aGivenClasses)
{
$aRecentClasses = [];
// User preferences will be reset during the rollback
foreach($aGivenClasses as $sClass) {
$aRecentClasses[] = array(
'class' => $sClass,
);
}
appUserPreferences::SetPref(QuickCreateHelper::USER_PREF_CODE, $aRecentClasses);
}
private function AssertPopularClassesMatches(array $aExpectedClasses, array $aPopularClasses, string $sMessage = '')
{
$aFoundClasses = [];
foreach($aPopularClasses as $aClassData) {
$aFoundClasses[] = $aClassData['class'];
}
sort($aFoundClasses);
sort($aExpectedClasses);
$this->assertEquals($aExpectedClasses, $aFoundClasses, $sMessage);
}
}