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' => [ 'subject-operating-report' => '主体经营', ], ], ])->assertOk(); $navigation = BusinessNavigation::all(); $companyRegistration = collect($navigation[0]['pages'])->firstWhere('slug', 'subject-operating-report'); $this->assertSame('企业档案', $navigation[0]['title']); $this->assertSame('主体经营', $companyRegistration['title']); } public function testOrderDataAndRefundAreConfiguredBetweenInvoiceAndReceivablesMenus() { $navigation = BusinessNavigation::all(); $slugs = array_column($navigation, 'slug'); $invoiceIndex = array_search('invoice-management', $slugs, true); $fundIndex = array_search('fund-management', $slugs, true); $orderIndex = array_search('order-data', $slugs, true); $refundIndex = array_search('refunds', $slugs, true); $billingIndex = array_search('billing-transactions', $slugs, true); $balanceIndex = array_search('account-balance-data', $slugs, true); $productIndex = array_search('product-inventory', $slugs, true); $receivablesIndex = array_search('store-receivables', $slugs, true); $orderData = $navigation[$orderIndex] ?? null; $refund = $navigation[$refundIndex] ?? null; $this->assertNotFalse($invoiceIndex); $this->assertNotFalse($fundIndex); $this->assertNotFalse($orderIndex); $this->assertNotFalse($refundIndex); $this->assertNotFalse($billingIndex); $this->assertNotFalse($balanceIndex); $this->assertNotFalse($productIndex); $this->assertNotFalse($receivablesIndex); $this->assertSame( [ 'invoice-management', 'fund-management', 'order-data', 'refunds', 'billing-transactions', 'account-balance-data', 'product-inventory', ], array_slice($slugs, $invoiceIndex, 7) ); $this->assertSame( [ '票务管理', '资金管理', '订单数据', '退款数据', '账单流水数据', '账单余额数据', '商品及库存管理', ], array_column(array_slice($navigation, $invoiceIndex, 7), 'title') ); $this->assertGreaterThan($invoiceIndex, $orderIndex); $this->assertGreaterThan($orderIndex, $refundIndex); $this->assertGreaterThan($refundIndex, $billingIndex); $this->assertGreaterThan($billingIndex, $balanceIndex); $this->assertGreaterThan($balanceIndex, $productIndex); $this->assertLessThan($receivablesIndex, $productIndex); $this->assertSame('订单数据', $orderData['title']); $this->assertSame( ['raw-data', 'bill-offset'], array_column($orderData['pages'], 'slug') ); $this->assertSame( ['原始数据', '账单冲减'], array_column($orderData['pages'], 'title') ); $this->assertSame( ['after-sales-expenses', 'promotion-expenses'], array_column($orderData['pages'][0]['tabs'], 'slug') ); $this->assertSame( ['订单售后费用明细', '商品推广费用明细'], array_column($orderData['pages'][0]['tabs'], 'title') ); $this->assertArrayNotHasKey('children', $orderData['pages'][0]); $this->assertSame( ['bill-offset'], array_column(array_slice($orderData['pages'], 1), 'slug') ); $this->assertSame( ['账单冲减'], array_column(array_slice($orderData['pages'], 1), 'title') ); $this->assertSame('退款数据', $refund['title']); $this->assertSame('assignment_return', $refund['icon']); $this->assertSame( ['jingxi-refund-data', 'non-jingxi-refund-data', 'small-payment-work-orders'], array_column($refund['pages'], 'slug') ); $this->assertSame( ['京喜退款数据', '售后(退货退款)', '小额打款'], array_column($refund['pages'], 'title') ); } }