From db74a9c051c2a5bc67ff8f6edcfc709b196abf9c Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Tue, 30 Jun 2020 09:27:40 +0800 Subject: [PATCH] remove unnecessary code --- app/Events/RenderingFooter.php | 8 +------- app/Events/RenderingHeader.php | 8 +------- tests/HttpTest/ControllersTest/HomeControllerTest.php | 11 ----------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/app/Events/RenderingFooter.php b/app/Events/RenderingFooter.php index 6df1d513..7efd142b 100644 --- a/app/Events/RenderingFooter.php +++ b/app/Events/RenderingFooter.php @@ -13,12 +13,6 @@ class RenderingFooter extends Event public function addContent(string $content) { - if ($content) { - if (!is_string($content)) { - throw new \Exception('Can not add non-string content', 1); - } - - $this->contents[] = $content; - } + $this->contents[] = $content; } } diff --git a/app/Events/RenderingHeader.php b/app/Events/RenderingHeader.php index eedb5c02..c136f331 100644 --- a/app/Events/RenderingHeader.php +++ b/app/Events/RenderingHeader.php @@ -13,12 +13,6 @@ class RenderingHeader extends Event public function addContent(string $content) { - if ($content) { - if (!is_string($content)) { - throw new \Exception('Can not add non-string content', 1); - } - - $this->contents[] = $content; - } + $this->contents[] = $content; } } diff --git a/tests/HttpTest/ControllersTest/HomeControllerTest.php b/tests/HttpTest/ControllersTest/HomeControllerTest.php index e0317a87..cd4a51b9 100644 --- a/tests/HttpTest/ControllersTest/HomeControllerTest.php +++ b/tests/HttpTest/ControllersTest/HomeControllerTest.php @@ -5,7 +5,6 @@ namespace Tests; use App\Events\RenderingFooter; use App\Events\RenderingHeader; use Illuminate\Support\Facades\Event; -use stdClass; class HomeControllerTest extends TestCase { @@ -23,11 +22,6 @@ class HomeControllerTest extends TestCase $event->addContent('testing custom header'); }); $this->get('/')->assertSee('testing custom header'); - - Event::listen(RenderingHeader::class, function (RenderingHeader $event) { - $event->addContent(new stdClass()); - }); - $this->get('/'); } public function testRenderingFooterEvent() @@ -36,11 +30,6 @@ class HomeControllerTest extends TestCase $event->addContent('testing custom footer'); }); $this->get('/')->assertSee('testing custom footer'); - - Event::listen(RenderingFooter::class, function (RenderingFooter $event) { - $event->addContent(new stdClass()); - }); - $this->get('/'); } public function testApiRoot()