Fix unit tests

This commit is contained in:
Eric
2020-11-09 11:52:00 +01:00
parent d7b1e60219
commit 866a93c0c8
3 changed files with 139 additions and 250 deletions

View File

@@ -679,20 +679,21 @@ class DBSearchTest extends ItopDataTestCase
$oSet = new \CMDBObjectSet($oSearch, array(), array('org_ids' => $TwoOrgIdsOnly));
static::assertEquals(4, $oSet->Count());
$_SERVER['REQUEST_URI'] = 'FAKE_REQUEST_URI';
$_SERVER['REQUEST_METHOD'] = 'FAKE_REQUEST_METHOD';
$oP = new \iTopWebPage("test");
$oBlock = new \DisplayBlock($oSet->GetFilter(), 'list', false);
$oHtml = $oBlock->GetDisplay($oP, 'package_table', array('menu' => true, 'display_limit' => false));
$sHtml = BlockRenderer::RenderBlockTemplates($oHtml);
$iHtmlUserRequestLineCount = substr_count($sHtml, '<tr><td data-object-class="UserRequest"');
static::assertEquals(4, $iHtmlUserRequestLineCount, "Failed Generated html :".$sHtml);
// Content now generated with ajax call
// $_SERVER['REQUEST_URI'] = 'FAKE_REQUEST_URI';
// $_SERVER['REQUEST_METHOD'] = 'FAKE_REQUEST_METHOD';
// $oP = new \iTopWebPage("test");
// $oBlock = new \DisplayBlock($oSet->GetFilter(), 'list', false);
// $oHtml = $oBlock->GetDisplay($oP, 'package_table', array('menu' => true, 'display_limit' => false));
// $sHtml = BlockRenderer::RenderBlockTemplates($oHtml);
//
// $iHtmlUserRequestLineCount = substr_count($sHtml, '<tr><td data-object-class="UserRequest"');
// static::assertEquals(4, $iHtmlUserRequestLineCount, "Failed Generated html :".$sHtml);
// As using $oP we added some content in the PHP buffer, we need to empty it !
// Otherwise PHPUnit will throw the error : "Test code or tested code did not (only) close its own output buffers"
// Previously we were using a output() call but this is time consuming and could cause "risky test" error !
ob_get_clean();
// ob_get_clean();
}
/**