87 lines
3.1 KiB
PHP
87 lines
3.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 testAdminSeesReferenceBusinessNavigation()
|
|
{
|
|
$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('侧边栏功能名称');
|
|
|
|
$navigation = BusinessNavigation::all();
|
|
$this->assertSame(
|
|
['company-management', 'trademark-management', 'store-management'],
|
|
array_slice(array_column($navigation, 'slug'), 0, 3)
|
|
);
|
|
$this->assertSame(
|
|
['people-inventory', 'company-progress', 'company-information', 'entity-report'],
|
|
array_column($navigation[0]['pages'], 'slug')
|
|
);
|
|
$this->assertSame(
|
|
['trademark-progress', 'trademark-information'],
|
|
array_column($navigation[1]['pages'], 'slug')
|
|
);
|
|
$this->assertSame(
|
|
['store-report', 'store-information', 'store-change-progress'],
|
|
array_column($navigation[2]['pages'], 'slug')
|
|
);
|
|
}
|
|
|
|
public function testOrderDataAndRefundAreConfiguredBetweenInvoiceAndReceivablesMenus()
|
|
{
|
|
$navigation = BusinessNavigation::all();
|
|
$slugs = array_column($navigation, 'slug');
|
|
|
|
$invoiceIndex = array_search('invoice-management', $slugs, true);
|
|
$orderIndex = array_search('order-data', $slugs, true);
|
|
$refundIndex = array_search('refunds', $slugs, true);
|
|
$receivablesIndex = array_search('store-receivables', $slugs, true);
|
|
$orderData = $navigation[$orderIndex] ?? null;
|
|
$refund = $navigation[$refundIndex] ?? null;
|
|
|
|
$this->assertNotFalse($invoiceIndex);
|
|
$this->assertNotFalse($orderIndex);
|
|
$this->assertNotFalse($refundIndex);
|
|
$this->assertNotFalse($receivablesIndex);
|
|
$this->assertGreaterThan($invoiceIndex, $orderIndex);
|
|
$this->assertGreaterThan($orderIndex, $refundIndex);
|
|
$this->assertLessThan($receivablesIndex, $refundIndex);
|
|
$this->assertSame('订单数据', $orderData['title']);
|
|
$this->assertSame(
|
|
['after-sales-expenses', 'promotion-expenses'],
|
|
array_column($orderData['pages'], 'slug')
|
|
);
|
|
$this->assertSame(
|
|
['订单售后费用明细', '商品推广费用明细'],
|
|
array_column($orderData['pages'], 'title')
|
|
);
|
|
$this->assertSame('退款', $refund['title']);
|
|
$this->assertSame('assignment_return', $refund['icon']);
|
|
$this->assertSame(
|
|
['jingxi-refund-data', 'non-jingxi-refund-data'],
|
|
array_column($refund['pages'], 'slug')
|
|
);
|
|
$this->assertSame(
|
|
['京喜退款数据', '非京喜退款数据'],
|
|
array_column($refund['pages'], 'title')
|
|
);
|
|
}
|
|
|
|
}
|