mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 22:19:41 -08:00
34 lines
996 B
PHP
34 lines
996 B
PHP
|
<?php
|
||
|
|
||
|
namespace Tests\Feature\Reports;
|
||
|
|
||
|
use App\Models\Asset;
|
||
|
use App\Models\User;
|
||
|
use League\Csv\Reader;
|
||
|
use Tests\Support\InteractsWithSettings;
|
||
|
use Tests\TestCase;
|
||
|
|
||
|
class CustomReportTest extends TestCase
|
||
|
{
|
||
|
use InteractsWithSettings;
|
||
|
|
||
|
public function testCustomAssetReport()
|
||
|
{
|
||
|
Asset::factory()->create(['name' => 'Asset A']);
|
||
|
Asset::factory()->create(['name' => 'Asset B']);
|
||
|
|
||
|
$response = $this->actingAs(User::factory()->canViewReports()->create())
|
||
|
->post('reports/custom', [
|
||
|
'asset_name' => '1',
|
||
|
'asset_tag' => '1',
|
||
|
'serial' => '1',
|
||
|
])->assertOk()
|
||
|
->assertHeader('content-type', 'text/csv; charset=UTF-8');
|
||
|
|
||
|
$reader = Reader::createFromString($response->streamedContent());
|
||
|
|
||
|
$this->assertTrue(collect($reader->getRecords())->pluck(0)->contains('Asset A'));
|
||
|
$this->assertTrue(collect($reader->getRecords())->pluck(0)->contains('Asset B'));
|
||
|
}
|
||
|
}
|