35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\View;
|
|
|
|
use App\Listeners\Menu\ShowInAdmin;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
require_once dirname(__DIR__, 3) . '/app/Listeners/Menu/ShowInAdmin.php';
|
|
|
|
class PayablesGroupTest extends TestCase
|
|
{
|
|
public function test_group_preserves_sections_and_does_not_include_inventory(): void
|
|
{
|
|
$original = require dirname(__DIR__, 3) . '/config/business_navigation.php';
|
|
$grouped = ShowInAdmin::groupPayables($original);
|
|
$slugs = array_column($grouped, 'slug');
|
|
$index = array_search('payable-items', $slugs, true);
|
|
$this->assertSame('store-receivables', $slugs[$index - 1]);
|
|
$this->assertCount(6, $grouped[$index]['sections']);
|
|
$this->assertContains('inventory-management', $slugs);
|
|
foreach ($grouped[$index]['sections'] as $section) {
|
|
$this->assertNotContains($section['slug'], $slugs);
|
|
$this->assertSame($original[array_search($section['slug'], array_column($original, 'slug'), true)], $section);
|
|
}
|
|
}
|
|
|
|
public function test_only_authorized_sections_are_grouped(): void
|
|
{
|
|
$allowed = [['slug' => 'courier-payables', 'title' => '快递应付', 'pages' => [['slug' => 'freight-reconciliation']]]];
|
|
$result = ShowInAdmin::groupPayables($allowed);
|
|
$this->assertSame($allowed, $result[0]['sections']);
|
|
$this->assertSame([], ShowInAdmin::groupPayables([]));
|
|
}
|
|
}
|