Add tests around loading saved reports
This commit is contained in:
parent
c9157dc55d
commit
c3845f4393
1 changed files with 52 additions and 0 deletions
52
tests/Feature/SavedReports/SavedReportsTest.php
Normal file
52
tests/Feature/SavedReports/SavedReportsTest.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\SavedReports;
|
||||||
|
|
||||||
|
use App\Models\SavedReport;
|
||||||
|
use App\Models\User;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class SavedReportsTest extends TestCase
|
||||||
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
|
public function testCanLoadCustomReportPage()
|
||||||
|
{
|
||||||
|
$this->actingAs(User::factory()->canViewReports()->create())
|
||||||
|
->get(route('reports/custom'))
|
||||||
|
->assertOk()
|
||||||
|
->assertViewHas(['savedReport' => function (SavedReport $report) {
|
||||||
|
// the view should have an empty report by default
|
||||||
|
return $report->exists() === false;
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCanLoadASavedCustomReport()
|
||||||
|
{
|
||||||
|
$user = User::factory()->canViewReports()->create();
|
||||||
|
$savedReport = SavedReport::factory()->make(['name' => 'My Awesome Report']);
|
||||||
|
$user->savedReports()->save($savedReport);
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->get(route('reports/custom', ['report' => $savedReport->id]))
|
||||||
|
->assertOk()
|
||||||
|
->assertViewHas(['savedReport' => function (SavedReport $viewReport) use ($savedReport) {
|
||||||
|
return $viewReport->is($savedReport);
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCanOnlySeeOwnSavedCustomReports()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete('potentially...');
|
||||||
|
|
||||||
|
// create saved reports for two users
|
||||||
|
// load the route('reports/custom')
|
||||||
|
// ensure the view only has the current users reports ($saved_reports)
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCanSaveACustomReport()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue