From c9dab0832478d4bea0e2295c72bed6cbba63b133 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 4 Aug 2020 15:24:11 +0200 Subject: [PATCH] :green_heart: Fix DBSearchTest::testSelectInWithVariableExpressions --- test/core/DBSearchTest.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/core/DBSearchTest.php b/test/core/DBSearchTest.php index 9389bc9ca..66323b1a3 100644 --- a/test/core/DBSearchTest.php +++ b/test/core/DBSearchTest.php @@ -675,17 +675,21 @@ class DBSearchTest extends ItopDataTestCase $TwoOrgIdsOnly = array($allOrgIds[0], $allOrgIds[1]); $oSearch = DBSearch::FromOQL("SELECT UserRequest WHERE org_id IN (:org_ids)"); self::assertNotNull($oSearch); - $oSet = new \CMDBObjectSet($oSearch, array(), array('org_ids'=> $TwoOrgIdsOnly)); + $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'; + $_SERVER['REQUEST_URI'] = 'FAKE_REQUEST_URI'; + $_SERVER['REQUEST_METHOD'] = 'FAKE_REQUEST_METHOD'; $oP = new \iTopWebPage("test"); $oBlock = new \DisplayBlock($oSet->GetFilter(), 'list', false); - $sHtml = $oBlock->GetDisplay($oP, 'package_table', array ('menu'=>true, 'display_limit'=>false)); + $sHtml = $oBlock->GetDisplay($oP, 'package_table', array('menu' => true, 'display_limit' => false)); $iHtmlUserRequestLineCount = substr_count($sHtml, 'output(); + 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(); } }