2024-07-12 04:19:40 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Reporting;
|
|
|
|
|
|
|
|
use App\Models\Asset;
|
|
|
|
use App\Models\Company;
|
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Testing\TestResponse;
|
|
|
|
use League\Csv\Reader;
|
|
|
|
use PHPUnit\Framework\Assert;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
2024-08-06 13:25:22 -07:00
|
|
|
final class UnacceptedAssetReportTest extends TestCase
|
2024-07-12 04:19:40 -07:00
|
|
|
{
|
|
|
|
protected function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
TestResponse::macro(
|
|
|
|
'assertSeeTextInStreamedResponse',
|
|
|
|
function (string $needle) {
|
|
|
|
Assert::assertTrue(
|
|
|
|
collect(Reader::createFromString($this->streamedContent())->getRecords())
|
|
|
|
->pluck(0)
|
|
|
|
->contains($needle)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
TestResponse::macro(
|
|
|
|
'assertDontSeeTextInStreamedResponse',
|
|
|
|
function (string $needle) {
|
|
|
|
Assert::assertFalse(
|
|
|
|
collect(Reader::createFromString($this->streamedContent())->getRecords())
|
|
|
|
->pluck(0)
|
|
|
|
->contains($needle)
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-08-06 13:30:34 -07:00
|
|
|
public function testPermissionRequiredToViewUnacceptedAssetReport()
|
2024-07-12 04:19:40 -07:00
|
|
|
{
|
|
|
|
$this->actingAs(User::factory()->create())
|
|
|
|
->get(route('reports/unaccepted_assets'))
|
|
|
|
->assertForbidden();
|
|
|
|
}
|
|
|
|
|
2024-08-06 13:30:34 -07:00
|
|
|
public function testUserCanListUnacceptedAssets()
|
2024-07-12 04:19:40 -07:00
|
|
|
{
|
|
|
|
$this->actingAs(User::factory()->superuser()->create())
|
|
|
|
->get(route('reports/unaccepted_assets'))
|
|
|
|
->assertOk();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|