From df0915b9f9c07bc533dba2ad433fd79e4c2d40b1 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 6 Apr 2020 15:58:20 +0700 Subject: [PATCH] clean up buffer tweak in FeatureTestCaseTest --- system/Test/FeatureTestCase.php | 19 +++++++++---------- tests/system/Test/FeatureTestCaseTest.php | 9 --------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/system/Test/FeatureTestCase.php b/system/Test/FeatureTestCase.php index 9b393257c027..dc53c42c1e4f 100644 --- a/system/Test/FeatureTestCase.php +++ b/system/Test/FeatureTestCase.php @@ -151,6 +151,15 @@ public function skipEvents() */ public function call(string $method, string $path, array $params = null) { + // Clean up any open output buffers + // not relevant to unit testing + // @codeCoverageIgnoreStart + if (\ob_get_level() > 0 && $this->clean) + { + \ob_end_clean(); + } + // @codeCoverageIgnoreEnd + // Simulate having a blank session $_SESSION = []; $_SERVER['REQUEST_METHOD'] = $method; @@ -178,16 +187,6 @@ public function call(string $method, string $path, array $params = null) $response->setBody($output); } - // Clean up any open output buffers - // not relevant to unit testing - // @codeCoverageIgnoreStart - - if (ob_get_level() > 0 && $this->clean) - { - ob_end_clean(); - } - // @codeCoverageIgnoreEnd - // Reset directory if it has been set Services::router()->setDirectory(null); diff --git a/tests/system/Test/FeatureTestCaseTest.php b/tests/system/Test/FeatureTestCaseTest.php index b89422760085..5b9ff4f1ab1c 100644 --- a/tests/system/Test/FeatureTestCaseTest.php +++ b/tests/system/Test/FeatureTestCaseTest.php @@ -198,10 +198,6 @@ public function testEchoes() public function testCallZeroAsPathGot404() { $this->expectException(PageNotFoundException::class); - while (\ob_get_level() > 0) - { - \ob_end_flush(); - } $this->get('0'); } @@ -247,11 +243,6 @@ public function testOpenCliRoutesFromHttpGot404($from, $to, $httpGet) $to, ], ]); - - while (\ob_get_level() > 0) - { - \ob_end_flush(); - } $this->get($httpGet); } }