Skip to content
Snippets Groups Projects
Commit fca0d925 authored by Damien Labat's avatar Damien Labat
Browse files

test: Add export evaluation & organizations features tests

parent 0cbdc665
No related branches found
No related tags found
1 merge request!1Export CSV feature
Pipeline #34828 canceled
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Testing\TestResponse;
use Tests\TestCase;
class ExportControllerTest extends TestCase
{
use RefreshDatabase;
/**
* Test organizations export.
*/
public function testExportOrganizations(): void
{
/** @var Authenticatable $user */
$user = User::with('organization')->first();
$response = $this->actingAs($user)->get(route('export.organizations', ['ext' => 'json']));
$this->_testJsonExportResponse($response);
}
/**
* Test evaluations export.
*/
public function testExportEvaluations(): void
{
/** @var Authenticatable $user */
$user = User::with('organization')->first();
$response = $this->actingAs($user)->get(route('export.evaluations', ['ext' => 'json']));
$this->_testJsonExportResponse($response);
}
private function _testJsonExportResponse(TestResponse $response): void
{
if ($response->exception) {
dump($response->exception);
}
$response->assertOk();
$content = $response->json();
self::assertGreaterThan(0, count($content['header']));
self::assertGreaterThan(0, count($content['rows']));
self::assertSameSize($content['header'], $content['rows'][0]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment