user->attachPermission( Permission::where('name', 'read-admin-panel')->firstOrFail() ); $this->companyInformation = Mockery::mock(BusinessInformationMirrorRepository::class); $this->companyInformation->shouldReceive('allCompaniesForClassification') ->byDefault() ->andReturn([]); $this->app->instance(BusinessInformationMirrorRepository::class, $this->companyInformation); } public function test_invoice_reports_puts_summary_tab_before_input_and_output(): void { $page = collect(collect(config('business_navigation')) ->firstWhere('slug', 'invoice-management')['pages']) ->firstWhere('slug', 'invoice-reports'); $this->assertSame( ['summary', 'input', 'output'], array_column($page['tabs'], 'slug') ); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'invoice-management', 'page' => 'invoice-reports', ])) ->assertRedirect(route('business.pages.show', [ 'section' => 'invoice-management', 'page' => 'invoice-reports', 'tab' => 'summary', ])); } public function test_summary_combines_input_and_output_reports_by_company(): void { $this->createReports(); $companyInformation = Mockery::mock(BusinessInformationMirrorRepository::class); $companyInformation->shouldReceive('allCompaniesForClassification') ->once() ->andReturn([ ['company_name' => '甲公司', 'taxpayer_category' => '一般纳税人'], ['company_name' => '乙公司', 'taxpayer_category' => '小规模纳税人'], ]); $this->app->instance(BusinessInformationMirrorRepository::class, $companyInformation); $this->loginAs() ->get(route('business.pages.show', [ 'section' => 'invoice-management', 'page' => 'invoice-reports', 'tab' => 'summary', ])) ->assertOk() ->assertSeeText('发票情况汇总') ->assertSeeText('公司') ->assertSeeText('纳税人类型') ->assertSeeText('销项金额') ->assertSeeText('销项税额') ->assertSeeText('进项金额') ->assertSeeText('进项税额') ->assertSeeText('是否预警') ->assertSeeText('全部公司') ->assertSeeText('全部类型') ->assertSeeText('甲公司') ->assertSeeText('乙公司') ->assertSeeText('一般纳税人') ->assertSeeText('小规模纳税人') ->assertSeeText('150.00') ->assertSeeText('16.00') ->assertSeeText('100.00') ->assertSeeText('10.00') ->assertSeeText('320.00') ->assertSeeText('41.60') ->assertSeeText('合计') ->assertSeeText('250.00') ->assertSeeText('26.00') ->assertSee('invoice-warning is-warning', false) ->assertSee('进项/销项 = 46.9%', false) ->assertSee('销项金额为 0,无法计算比例', false); } public function test_summary_filters_by_company_taxpayer_type_and_warning(): void { $this->createReports(); $companyInformation = Mockery::mock(BusinessInformationMirrorRepository::class); $companyInformation->shouldReceive('allCompaniesForClassification') ->andReturn([ ['company_name' => '甲公司', 'taxpayer_category' => '一般纳税人'], ['company_name' => '乙公司', 'taxpayer_category' => '小规模纳税人'], ]); $this->app->instance(BusinessInformationMirrorRepository::class, $companyInformation); $this->loginAs(); $url = route('business.pages.show', [ 'section' => 'invoice-management', 'page' => 'invoice-reports', 'tab' => 'summary', ]); $this->loginAs() ->get($url . '?company=' . urlencode('甲公司')) ->assertOk() ->assertSee('