mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
5874
Add comments to tests for clarity Add setUp and tearDown methods on tests Add classes on history and popular sections
This commit is contained in:
@@ -21,10 +21,10 @@
|
||||
<div class="ibo-quick-create--compartment-content" data-role="ibo-quick-create--compartment-results">
|
||||
</div>
|
||||
{# History section #}
|
||||
<div class="ibo-quick-create--compartment-title" data-role="ibo-quick-create--compartment-title">
|
||||
<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>
|
||||
</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 %}
|
||||
<div class="ibo-quick-create--compartment--placeholder">
|
||||
<div class="ibo-quick-create--compartment--placeholder-hint">{{ 'UI:Component:QuickCreate:HistoryDisabled'|dict_s }}</div>
|
||||
@@ -50,10 +50,10 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{# Popular classes section #}
|
||||
<div class="ibo-quick-create--compartment-title" data-role="ibo-quick-create--compartment-title">
|
||||
<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" data-role="ibo-quick-create--compartment-content">
|
||||
<div class="ibo-quick-create--compartment-content ibo-quick-create--popular-classes--content" data-role="ibo-quick-create--compartment-content">
|
||||
{% if oUIBlock.GetPopularClasses()|length > 0 %}
|
||||
{% 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 }}">
|
||||
|
||||
@@ -2,11 +2,22 @@
|
||||
|
||||
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
|
||||
{
|
||||
private array $aInitialUserPref = [];
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->aInitialUserPref = appUserPreferences::GetPref(QuickCreateHelper::USER_PREF_CODE, []);
|
||||
}
|
||||
|
||||
protected function tearDown(): void{
|
||||
parent::tearDown();
|
||||
appUserPreferences::SetPref(QuickCreateHelper::USER_PREF_CODE, $this->aInitialUserPref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test class removal from popular when it is in recent classes
|
||||
@@ -14,10 +25,12 @@ class QuickCreateHelperTest extends ItopDataTestCase
|
||||
public function testNoDuplicateInPopularAndLast()
|
||||
{
|
||||
$aClasses = ['ApplicationSolution', 'BusinessProcess', 'DatabaseSchema', 'MiddlewareInstance', 'Enclosure'];
|
||||
$aPopularClassesInitial = QuickCreateHelper::GetPopularClasses(); // Should contain the first Popular class (FunctionalCI if default)
|
||||
// Should contain the first Popular class (FunctionalCI if default)
|
||||
$aPopularClassesInitial = QuickCreateHelper::GetPopularClasses();
|
||||
$sPopularClass = $aPopularClassesInitial[0]['class'];
|
||||
QuickCreateHelper::AddClassToHistory($sPopularClass);
|
||||
$aPopularClassNoParam = QuickCreateHelper::GetPopularClasses(); // Popular class should now be in Recents and no longer in Popular
|
||||
// Popular class should now be in Recents and no longer in Popular
|
||||
$aPopularClassNoParam = QuickCreateHelper::GetPopularClasses();
|
||||
|
||||
for($iIdx = 0; $iIdx < count($aPopularClassNoParam); $iIdx++)
|
||||
{
|
||||
@@ -36,9 +49,11 @@ class QuickCreateHelperTest extends ItopDataTestCase
|
||||
|
||||
foreach($aClasses as $sClass)
|
||||
{
|
||||
QuickCreateHelper::AddClassToHistory($sClass); // Creating as many classes as needed for UserRequest to no longer be in the Recent classes (at least equal to 'quick_create.max_history_results')
|
||||
// Creating as many classes as needed for UserRequest to no longer be in the Recent classes (at least equal to 'quick_create.max_history_results')
|
||||
QuickCreateHelper::AddClassToHistory($sClass);
|
||||
}
|
||||
$aPopularClassesFinal = QuickCreateHelper::GetPopularClasses(); // Should contain UserRequest
|
||||
// Should contain the first Popular class (FunctionalCI if default)
|
||||
$aPopularClassesFinal = QuickCreateHelper::GetPopularClasses();
|
||||
$this->assertEquals($aPopularClassesInitial, $aPopularClassesFinal);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user