65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Settings;
|
|
|
|
use App\Models\Auth\Permission;
|
|
use App\Models\Auth\Role;
|
|
use App\Utilities\BusinessNavigation;
|
|
use Tests\Feature\FeatureTestCase;
|
|
|
|
class NavigationTest extends FeatureTestCase
|
|
{
|
|
public function testAdminCanUpdateSidebarLabels()
|
|
{
|
|
$this->user->roles()->sync([
|
|
Role::where('name', 'admin')->firstOrFail()->id,
|
|
]);
|
|
|
|
$this->user->attachPermission(
|
|
Permission::where('name', 'read-admin-panel')->firstOrFail()
|
|
);
|
|
|
|
$this->loginAs()
|
|
->get(route('settings.navigation.manage'))
|
|
->assertOk()
|
|
->assertSeeText('侧边栏功能名称');
|
|
|
|
$this->patch(route('settings.navigation.save'), [
|
|
'section_titles' => [
|
|
'company-management' => '企业档案',
|
|
],
|
|
'page_titles' => [
|
|
'company-management' => [
|
|
'registration' => '企业设立',
|
|
],
|
|
],
|
|
])->assertOk();
|
|
|
|
$navigation = BusinessNavigation::all();
|
|
$companyRegistration = collect($navigation[0]['pages'])->firstWhere('slug', 'registration');
|
|
|
|
$this->assertSame('企业档案', $navigation[0]['title']);
|
|
$this->assertSame('企业设立', $companyRegistration['title']);
|
|
}
|
|
|
|
public function testOrderDataIsConfiguredAsStandaloneSectionBetweenPayablesMenus()
|
|
{
|
|
$navigation = BusinessNavigation::all();
|
|
$slugs = array_column($navigation, 'slug');
|
|
|
|
$supplierIndex = array_search('supplier-payables', $slugs, true);
|
|
$orderIndex = array_search('order-data', $slugs, true);
|
|
$courierIndex = array_search('courier-payables', $slugs, true);
|
|
$orderData = $navigation[$orderIndex] ?? null;
|
|
|
|
$this->assertNotFalse($supplierIndex);
|
|
$this->assertNotFalse($orderIndex);
|
|
$this->assertNotFalse($courierIndex);
|
|
$this->assertGreaterThan($supplierIndex, $orderIndex);
|
|
$this->assertLessThan($courierIndex, $orderIndex);
|
|
$this->assertSame('订单数据', $orderData['title']);
|
|
$this->assertSame([], $orderData['pages']);
|
|
}
|
|
|
|
}
|