<?php

namespace Tests;

use Tests\TestCase;
use Laravel\Lumen\Testing\DatabaseMigrations;
use Laravel\Lumen\Testing\DatabaseTransactions;

class CsvGenerationTest extends TestCase
{
    public function test_export_contains_correct_data()
    {

        $res = $this->post('/backend', array(
            'organization' => 'GruppoCO',
            'password' => getenv('APP_PASSWORD')
        ));
        $res->assertResponseOk();

        $beginningDateYear = '2024' ;
        $beginningDateMonth = '04';
        $endDateYear = '2024';
        $endDateMonth = '05';
        $issueType = 'closed';

        $generatedCsv = $this->post('/export', array(
            'from_year' => $beginningDateYear,
            'from_month' => $beginningDateMonth,
            'to_year' => $endDateYear,
            'to_month' => $endDateMonth,
            'issues_type' => $issueType,
        ));

        $res->assertResponseOK();

        $generatedCsvHash = md5_file($generatedCsv);
        $testFileHash = '07078b8e24768453b1e45236b13d347d';

        assertEquals($generatedCsvHash, $testFileHash);
    }
}