From 69b1949e921bfd963d7987ecd306b73d3342b0e0 Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Sun, 13 Sep 2026 14:41:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E5=BA=94=E4=BB=98?= =?UTF-8?q?=E6=AC=BE=E9=A1=B9=E9=87=8D=E5=A4=8D=E7=BB=88=E7=89=88=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Listeners/Menu/ShowInAdmin.php | 8 +++++++- tests/Unit/View/PayablesGroupTest.php | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/Listeners/Menu/ShowInAdmin.php b/app/Listeners/Menu/ShowInAdmin.php index c2a56afa..fce6be26 100644 --- a/app/Listeners/Menu/ShowInAdmin.php +++ b/app/Listeners/Menu/ShowInAdmin.php @@ -52,7 +52,13 @@ class ShowInAdmin public static function groupPayables(array $navigation): array { - $keys = ['supplier-payables-final', 'courier-payables-final', 'supplier-payables', 'courier-payables', 'raw-board-payables', + $legacyKeys = ['supplier-payables-final', 'courier-payables-final']; + $navigation = array_values(array_filter( + $navigation, + static fn (array $section): bool => ! in_array($section['slug'], $legacyKeys, true) + )); + + $keys = ['supplier-payables', 'courier-payables', 'raw-board-payables', 'lamination-factory-payables', 'paper-materials', 'edge-banding-materials']; $children = array_values(array_filter($navigation, static fn (array $section): bool => in_array($section['slug'], $keys, true))); if ($children === []) { diff --git a/tests/Unit/View/PayablesGroupTest.php b/tests/Unit/View/PayablesGroupTest.php index acf0c943..a1d2efc8 100644 --- a/tests/Unit/View/PayablesGroupTest.php +++ b/tests/Unit/View/PayablesGroupTest.php @@ -16,8 +16,15 @@ class PayablesGroupTest extends TestCase $slugs = array_column($grouped, 'slug'); $index = array_search('payable-items', $slugs, true); $this->assertSame('store-receivables', $slugs[$index - 1]); - $this->assertCount(8, $grouped[$index]['sections']); - $this->assertSame(['供应商应付(终版)', '快递应付(终版)'], array_column(array_slice($grouped[$index]['sections'], 0, 2), 'title')); + $this->assertCount(6, $grouped[$index]['sections']); + $this->assertSame(['供应商应付', '快递应付'], array_column(array_slice($grouped[$index]['sections'], 0, 2), 'title')); + $this->assertSame( + [], + array_intersect( + ['supplier-payables-final', 'courier-payables-final'], + array_column($grouped[$index]['sections'], 'slug') + ) + ); $this->assertContains('inventory-management', $slugs); foreach ($grouped[$index]['sections'] as $section) { $this->assertNotContains($section['slug'], $slugs); @@ -31,5 +38,11 @@ class PayablesGroupTest extends TestCase $result = ShowInAdmin::groupPayables($allowed); $this->assertSame($allowed, $result[0]['sections']); $this->assertSame([], ShowInAdmin::groupPayables([])); + + $legacy = [ + ['slug' => 'supplier-payables-final', 'title' => '供应商应付(终版)', 'pages' => []], + ['slug' => 'courier-payables-final', 'title' => '快递应付(终版)', 'pages' => []], + ]; + $this->assertSame([], ShowInAdmin::groupPayables($legacy)); } }