<?php declare(strict_types=1);

require_once __DIR__ . '/../../src/data/QrbProtocolEntry.php';

use PHPUnit\Framework\TestCase;

final class QrbProtocolEntryTest extends TestCase
{
    public function testConstructor() : void
    {
        $protocolEntry = new QrbProtocolEntry($this->createRecipient());
        $result = $protocolEntry->toArray();
        $this->assertEquals(1,       $result[0]);    // index
        $this->assertEquals("",      $result[1]);    // lastName
        $this->assertEquals("",      $result[2]);    // firstName
        $this->assertEquals("",      $result[3]);    // mailAddress
        $this->assertEquals("false", $result[4]);    // pdfFileWritten
        $this->assertEquals("false", $result[5]);    // mailSent
    }
    
    public function testMarkPdfWrittenAndMarkMailSentAndToString() : void
    {
        $protocolEntry = new QrbProtocolEntry($this->createRecipient());
        $protocolEntry->markPdfWritten(true);
        $protocolEntry->markMailSent(true);
        $result = $protocolEntry->toArray();
        $this->assertEquals("true", $result[4]);    // pdfFileWritten
        $this->assertEquals("true", $result[5]);    // mailSent
        
         echo $protocolEntry . "\n";
    }
    
    public function testMarkPdfWrittenFalseAndMarkMailSentFalseAndToString() : void
    {
        $protocolEntry = new QrbProtocolEntry($this->createRecipient());
        $protocolEntry->markPdfWritten(false);
        $protocolEntry->markMailSent(false);
        $result = $protocolEntry->toArray();
        $this->assertEquals("false", $result[4]);    // pdfFileWritten
        $this->assertEquals("false", $result[5]);    // mailSent
        
         echo $protocolEntry . "\n";
    }
    
    private function createRecipient() : QrbRecipient
    {
        $line = array();
        array_push($line, "en");
        $headerNames = array();
        $headerNames[QrbRecipient::HDR_LANGUAGE] = 0;
        $supportedLanguages = array();
        array_push($supportedLanguages, "en");
        return new QrbRecipient(1, $line, $headerNames, false, false, false, false, $supportedLanguages);
    }
}

?>
