From cb34494b0d34d95458732d1d2f6def5c537c09bd Mon Sep 17 00:00:00 2001 From: David Lapointe Gilbert Date: Fri, 21 Jun 2024 10:01:22 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20`@menu`,=20`@hasmenu`=20and?= =?UTF-8?q?=20`@endhasmenu`=20WordPress=20directives=20(#147)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Directives/WordPress.php | 18 ++++++++++++++++++ tests/Unit/WordPressTest.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/Directives/WordPress.php b/src/Directives/WordPress.php index 1622f01..de08c58 100644 --- a/src/Directives/WordPress.php +++ b/src/Directives/WordPress.php @@ -631,6 +631,24 @@ public function directives(): array return ""; }, + + /* + |--------------------------------------------------------------------- + | @menu / @hasmenu / @endhasmenu + |--------------------------------------------------------------------- + */ + + 'menu' => function ($expression) { + return ""; + }, + + 'hasmenu' => function ($expression) { + return ""; + }, + + 'endhasmenu' => function () { + return ''; + }, ]; } } diff --git a/tests/Unit/WordPressTest.php b/tests/Unit/WordPressTest.php index 0b347d0..30a230f 100644 --- a/tests/Unit/WordPressTest.php +++ b/tests/Unit/WordPressTest.php @@ -845,3 +845,33 @@ expect($compiled)->toBe(""); }); }); + +describe('@menu', function () { + it('compiles correctly', function () { + $directive = "@menu(['theme_location' => 'primary_navigation'])"; + + $compiled = $this->compile($directive); + + expect($compiled)->toBe(" 'primary_navigation']); ?>"); + }); +}); + +describe('@hasmenu', function () { + it('compiles correctly', function () { + $directive = "@hasmenu('primary_navigation')"; + + $compiled = $this->compile($directive); + + expect($compiled)->toBe(""); + }); +}); + +describe('@endhasmenu', function () { + it('compiles correctly', function () { + $directive = '@endhasmenu'; + + $compiled = $this->compile($directive); + + expect($compiled)->toBe(''); + }); +});