<?php declare(strict_types=1);

require_once __DIR__ . '/../../src/storage/file/QrbFileStorage.php';

use PHPUnit\Framework\TestCase;

final class QrbFileStorageTest extends TestCase
{
    const TEST_DIR_1  = "TestDir1";
    const TEST_DIR_2  = "TestDir2";
    const CURRENT_RUN = "RunSubDir";
    
    private QrbStorage $qrbStorage;
    
    protected function setUp(): void
    {
        $this->qrbStorage = new QrbFileStorage();
        $this->qrbStorage->selectCurrentProfile("QrbFileStorageTest");
    }
    
    protected function tearDown() : void
    {
        $this->qrbStorage->selectCurrentProfile(QrbEnvironment::DEFAULT_PROFILE);
        $this->qrbStorage->deleteData();
    }
    
    public function testSetMaxRunsToKeep() : void
    {
        $savedValue = $this->qrbStorage->getMaxRunsToKeep();
        
        try
        {
            $this->qrbStorage->setMaxRunsToKeep(99);
            $this->assertEquals(99, $this->qrbStorage->getMaxRunsToKeep());
        }
        finally
        {
            $this->qrbStorage->setMaxRunsToKeep($savedValue);
        }
    }

    public function testSetMaxRunsToKeepInvalidArgument() : void
    {
        $savedValue = $this->qrbStorage->getMaxRunsToKeep();
        
        try
        {
            $this->expectException(QrbException::class);
            $this->qrbStorage->setMaxRunsToKeep(-1);
        }
        finally
        {
            $this->qrbStorage->setMaxRunsToKeep($savedValue);
        }
    }

    public function testWriteLogAdditionalLines() : void
    {
        $result = $this->qrbStorage->writeLog("Test1", [ "Test2", "Test3" ] );
        $this->assertTrue( $result && ($result > 15));
    }

    public function testInitializeNewRunProcessRun() : void
    {
        $savedProfile = $this->qrbStorage->getCurrentProfile();
        $this->qrbStorage->createProfile(self::TEST_DIR_1);
        // do NOT call QrbFilePaths::getOutputPathOfRun(), as this method creates the sub directory!
        $expectedPath    = QrbFilePaths::getOutputPath(self::TEST_DIR_1);
        $expectedSubPath = $expectedPath    . "/" . self::CURRENT_RUN;
    
        try
        {
            $this->qrbStorage->initializeNewRun(self::CURRENT_RUN, false, false);
            $this->assertTrue(file_exists($expectedSubPath));
        }
        finally
        {
            $this->qrbStorage->selectCurrentProfile($savedProfile);
        }
    }

    public function testInitializeNewRunTestRun() : void
    {
        $savedProfile = $this->qrbStorage->getCurrentProfile();
        $this->qrbStorage->selectCurrentProfile(self::TEST_DIR_1);
        // do NOT call QrbFilePaths::getOutputPathOfRun(), as this method creates the sub directory!
        $expectedPath    = QrbFilePaths::getOutputPath(self::TEST_DIR_1);
        $expectedSubPath = $expectedPath    . "/" . self::CURRENT_RUN;
        $expectedMarkerFile = $expectedSubPath . "/" . $this->qrbStorage->getFileName(QrbDataType::MARKER_TEST);
    
        try
        {
            $this->qrbStorage->initializeNewRun(self::CURRENT_RUN, true, false);
            $this->assertTrue(file_exists($expectedSubPath));
            $this->assertTrue(file_exists($expectedMarkerFile));
        }
        finally
        {
            $this->qrbStorage->selectCurrentProfile($savedProfile);
        }
    }

    public function testZipCurrentRun() : void
    {
        $logFileName  = "log";
        $date         = "2099-12-31";
        $profile      = "Test";
        $savedProfile = $this->qrbStorage->getCurrentProfile();
        $this->qrbStorage->createProfile($profile);

        try
        {
            $this->qrbStorage->initializeNewRun(self::CURRENT_RUN, true, false);
            
            $expectedPath = QrbFilePaths::getOutputPath($profile);
            $expectedSubPath      = $expectedPath    . "/" . self::CURRENT_RUN;
            $expectedProtocolFile = $expectedSubPath . "/" . QrbDataType::PROTOCOL->value . ".csv";
            $expectedZipFile      = $expectedSubPath . "/" . self::CURRENT_RUN .".zip";
            
            $result = $this->qrbStorage->zipCurrentRun();
            $this->assertNull($result);    // no ZIP file as self::CURRENT_RUN is empty
    
            $this->qrbStorage->initializeNewRun(self::CURRENT_RUN, false, false);
            
            // make protocol file in "self::CURRENT_RUN
            $p = fopen($expectedProtocolFile, "w");
            fwrite($p, "Something");
            fclose($p);
            $result = $this->qrbStorage->zipCurrentRun();
            $this->assertNotNull($result);
            $this->assertEquals("data/" . $profile . "/output/" . self::CURRENT_RUN . "/" . self::CURRENT_RUN . ".zip", 
                                $result);
        }
        finally
        {
            $this->qrbStorage->selectCurrentProfile($savedProfile);
        }
    }

    public function testGetProfiles() : void
    {
        $defaultPath   = QrbFilePaths::getDataPath() . "/" . QrbEnvironment::DEFAULT_PROFILE;
        $expectedPath1 = QrbFilePaths::getDataPath() . "/" . self::TEST_DIR_1;
        $expectedPath2 = QrbFilePaths::getDataPath() . "/" . self::TEST_DIR_2;
        
        if (!file_exists($defaultPath) && !mkdir($defaultPath, 0777, true))
            throw new QrbException(static::class . " - Unable to create path '{$defaultPath}'",
                                   "exception.upload.unableToCreatePath",
                                   "{$defaultPath}");
        if (!file_exists($expectedPath1) && !mkdir($expectedPath1, 0777, true))
            throw new QrbException(static::class . " - Unable to create path '{$expectedPath1}'",
                                   "exception.upload.unableToCreatePath",
                                   "{$expectedPath1}");
        if (!file_exists($expectedPath2) && !mkdir($expectedPath2, 0777, true))
            throw new QrbException(static::class . " - Unable to create path '{$expectedPath2}'",
                                   "exception.upload.unableToCreatePath",
                                   "{$expectedPath2}");
        
        $profiles = $this->qrbStorage->getProfiles();
        
        $this->assertEquals(3, sizeof($profiles));    // Default should always exist?
        $this->assertEquals(QrbEnvironment::DEFAULT_PROFILE, $profiles[0]);
        $this->assertEquals(self::TEST_DIR_1, $profiles[1]);
        $this->assertEquals(self::TEST_DIR_2, $profiles[2]);
    }
    
    public function testDeleteProfile() : void
    {
        $profilePath = QrbFilePaths::getDataPath() . "/TestDir";
        
        if (!file_exists($profilePath))
            if (!mkdir($profilePath, 0777, true))
                throw new QrbException(static::class . " - Unable to create path '{$profilePath}'",
                                       "exception.upload.unableToCreatePath",
                                       "{$profilePath}");
    
        $inputPath = $profilePath . "/input";
        
        if (!file_exists($inputPath))
            if (!mkdir($inputPath, 0777, true))
                throw new QrbException(static::class . " - Unable to create path '{$inputPath}'",
                                       "exception.upload.unableToCreatePath",
                                       "{$inputPath}");

        $testInputFile = $inputPath . "/TestInputFile.txt";
        QrbFiles::writeTextFile($testInputFile, "TestInput");
        
        $outputPath = $profilePath . "/output";
        
        if (!file_exists($outputPath))
            if (!mkdir($outputPath, 0777, true))
                throw new QrbException(static::class . " - Unable to create path '{$outputPath}'",
                                       "exception.upload.unableToCreatePath",
                                       "{$outputPath}");

        $testOutputFile = $outputPath . "/TestOutputFile.txt";
        QrbFiles::writeTextFile($testOutputFile, "TestOutput");

        $outputDatePath = $outputPath . "/2024-03-26";
        
        if (!file_exists($outputDatePath))
            if (!mkdir($outputDatePath, 0777, true))
                throw new QrbException(static::class . " - Unable to create path '{$outputDatePath}'",
                                       "exception.upload.unableToCreatePath",
                                       "{$outputDatePath}");

        $testOutputDateFile = $outputDatePath . "/TestOutputDateFile.txt";
        QrbFiles::writeTextFile($testOutputDateFile, "TestOutputDate");

        // call testee
        $this->assertTrue($this->qrbStorage->deleteProfile("TestDir"));
        // test
        $this->assertFalse(file_exists($profilePath));
        // returns true even if nothing to delete
        $this->assertTrue($this->qrbStorage->deleteProfile("TestDir"));
    }

    public function testCheckInputFileExists() : void
    {
        $savedProfile = $this->qrbStorage->getCurrentProfile();
        
        $testInpuFileName = "Gaga.gaga";
        
        $this->assertNull($this->qrbStorage->checkInputFileExists($testInpuFileName));

        try
        {
            $this->qrbStorage->createProfile(self::TEST_DIR_1);
            $expectedGagaFile = QrbFilePaths::getInputPath(self::TEST_DIR_1) . "/" . $testInpuFileName;
        
            QrbFiles::writeTextFile($expectedGagaFile, "Gaga");
            $this->assertEquals(
                "data/" . self::TEST_DIR_1 . "/input/" . $testInpuFileName,
                $this->qrbStorage->checkInputFileExists($testInpuFileName));
        }
        finally
        {
            $this->qrbStorage->selectCurrentProfile($savedProfile);
        }
    }

    public function testDeleteOutputOfOldRuns() : void
    {
        $savedProfile       = $this->qrbStorage->getCurrentProfile();
        $savedMaxRunsToKeep = $this->qrbStorage->getMaxRunsToKeep();
        
        $currentProfile = "Test0";
        $runName = "202404090006";
        $this->qrbStorage->setMaxRunsToKeep(5);

        try
        {
            $this->createBunchOfOutput($currentProfile);
            $this->qrbStorage->initializeNewRun($runName, true, false);
            $this->qrbStorage->deleteOutputOfOldRuns(true);

            $this->qrbStorage->selectCurrentProfile($currentProfile);
            $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
            $this->assertTrue(file_exists($outputPath . "/202404090001"));
            $this->assertTrue(file_exists($outputPath . "/202404090002"));
            $this->assertTrue(file_exists($outputPath . "/202404090003"));
            $this->assertTrue(file_exists($outputPath . "/202404090004"));
            $this->assertTrue(file_exists($outputPath . "/202404090005"));
            $this->assertFalse(file_exists($outputPath . "/202404090006"));
            $this->qrbStorage->selectCurrentProfile("Test1");
            $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
            $this->assertFalse(file_exists($outputPath . "/202404090001"));
            $this->assertTrue(file_exists($outputPath . "/202404090002"));
            $this->assertTrue(file_exists($outputPath . "/202404090003"));
            $this->assertTrue(file_exists($outputPath . "/202404090004"));
            $this->assertTrue(file_exists($outputPath . "/202404090005"));
            $this->assertTrue(file_exists($outputPath . "/202404090006"));
            $this->qrbStorage->selectCurrentProfile("Test2");
            $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
            $this->assertTrue(file_exists($outputPath . "/202404090001"));
            $this->assertTrue(file_exists($outputPath . "/202404090002"));
            $this->assertTrue(file_exists($outputPath . "/202404090003"));
            $this->assertTrue(file_exists($outputPath . "/202404090004"));
            $this->assertTrue(file_exists($outputPath . "/202404090005"));
            $this->assertFalse(file_exists($outputPath . "/202404090006"));
            $this->qrbStorage->selectCurrentProfile("Test3");
            $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
            $this->assertTrue(file_exists($outputPath . "/202404090001"));
            $this->assertTrue(file_exists($outputPath . "/202404090002"));
            $this->assertTrue(file_exists($outputPath . "/202404090003"));
            $this->assertTrue(file_exists($outputPath . "/202404090004"));
            $this->qrbStorage->deleteProfile($currentProfile);
            $this->qrbStorage->deleteProfile("Test1");
            $this->qrbStorage->deleteProfile("Test2");
            $this->qrbStorage->deleteProfile("Test3");

            $this->createBunchOfOutput($currentProfile);
            $this->qrbStorage->initializeNewRun($runName, false, false);
            $this->qrbStorage->deleteOutputOfOldRuns(false);

            $this->qrbStorage->selectCurrentProfile($currentProfile);
            $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
            $this->assertTrue(file_exists($outputPath . "/202404090001"));
            $this->assertTrue(file_exists($outputPath . "/202404090002"));
            $this->assertTrue(file_exists($outputPath . "/202404090003"));
            $this->assertTrue(file_exists($outputPath . "/202404090004"));
            $this->assertTrue(file_exists($outputPath . "/202404090005"));
            $this->assertFalse(file_exists($outputPath . "/202404090006"));
            $this->qrbStorage->selectCurrentProfile("Test1");
            $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
            $this->assertFalse(file_exists($outputPath . "/202404090001"));
            $this->assertTrue(file_exists($outputPath . "/202404090002"));
            $this->assertTrue(file_exists($outputPath . "/202404090003"));
            $this->assertTrue(file_exists($outputPath . "/202404090004"));
            $this->assertTrue(file_exists($outputPath . "/202404090005"));
            $this->assertTrue(file_exists($outputPath . "/202404090006"));
            $this->qrbStorage->selectCurrentProfile("Test2");
            $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
            $this->assertTrue(file_exists($outputPath . "/202404090001"));
            $this->assertTrue(file_exists($outputPath . "/202404090002"));
            $this->assertTrue(file_exists($outputPath . "/202404090003"));
            $this->assertTrue(file_exists($outputPath . "/202404090004"));
            $this->assertTrue(file_exists($outputPath . "/202404090005"));
            $this->assertFalse(file_exists($outputPath . "/202404090006"));
            $this->qrbStorage->selectCurrentProfile("Test3");
            $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
            $this->assertTrue(file_exists($outputPath . "/202404090001"));
            $this->assertTrue(file_exists($outputPath . "/202404090002"));
            $this->assertTrue(file_exists($outputPath . "/202404090003"));
            $this->assertTrue(file_exists($outputPath . "/202404090004"));
        }        
        finally
        {
            $this->qrbStorage->setMaxRunsToKeep($savedMaxRunsToKeep);
            $this->qrbStorage->deleteProfile($currentProfile);
            $this->qrbStorage->deleteProfile("Test1");
            $this->qrbStorage->deleteProfile("Test2");
            $this->qrbStorage->deleteProfile("Test3");
            $this->qrbStorage->selectCurrentProfile($savedProfile);
        }
    }
    
    private function createBunchOfOutput(string $currentProfile) : void
    {
        $this->qrbStorage->deleteData();
           
        $this->qrbStorage->createProfile($currentProfile);
        $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
           
        // 6 files including old TestRun => delete old TestRun only if !TestRun
        mkdir($outputPath . "/202404090001");                                        // do NOT delete
        QrbFiles::writeTextFile($outputPath . "/202404090001/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090002");
        QrbFiles::writeTextFile($outputPath . "/202404090002/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090003");
        QrbFiles::writeTextFile($outputPath . "/202404090003/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090004");
        QrbFiles::writeTextFile($outputPath . "/202404090004/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090005");                                        
        QrbFiles::writeTextFile($outputPath . "/202404090005/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090006");                                       // do NOT delete if TestRun
        QrbFiles::writeTextFile($outputPath . "/202404090006/" . $this->qrbStorage->getFileName(QrbDataType::MARKER_TEST), "");
    
        $this->qrbStorage->createProfile("Test1");
        $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
        // 6 files (> maxRunsToKeep) => delete oldest run
        mkdir($outputPath . "/202404090001", 0777, true);                            // delete
        QrbFiles::writeTextFile($outputPath . "/202404090001/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090002");
        QrbFiles::writeTextFile($outputPath . "/202404090002/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090003");
        QrbFiles::writeTextFile($outputPath . "/202404090003/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090004");
        QrbFiles::writeTextFile($outputPath . "/202404090004/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090005");
        QrbFiles::writeTextFile($outputPath . "/202404090005/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090006");
        QrbFiles::writeTextFile($outputPath . "/202404090006/Gaga.txt", "Gaga");

        $this->qrbStorage->createProfile("Test2");
        $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
        // 6 files (> maxRunsToKeep) including old TestRun => delete old TestRun
        mkdir($outputPath . "/202404090001");                                        // do NOT delete
        QrbFiles::writeTextFile($outputPath . "/202404090001/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090002");
        QrbFiles::writeTextFile($outputPath . "/202404090002/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090003");
        QrbFiles::writeTextFile($outputPath . "/202404090003/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090004");
        QrbFiles::writeTextFile($outputPath . "/202404090004/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090005");                                        // delete (outdated TestRun)
        QrbFiles::writeTextFile($outputPath . "/202404090005/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090006");
        QrbFiles::writeTextFile($outputPath . "/202404090006/" . $this->qrbStorage->getFileName(QrbDataType::MARKER_TEST), "");

        $this->qrbStorage->createProfile("Test3");
        $outputPath = QrbFilePaths::getOutputPath($this->qrbStorage->getCurrentProfile());
        // only 4 files => nothing to delete
        mkdir($outputPath . "/202404090001");
        QrbFiles::writeTextFile($outputPath . "/202404090001/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090002");
        QrbFiles::writeTextFile($outputPath . "/202404090002/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090003");
        QrbFiles::writeTextFile($outputPath . "/202404090003/Gaga.txt", "Gaga");
        mkdir($outputPath . "/202404090004");
        QrbFiles::writeTextFile($outputPath . "/202404090004/Gaga.txt", "Gaga");
    }
    
    public function testDeleteInputData() : void
    {
        $savedProfile = $this->qrbStorage->getCurrentProfile();
        $this->qrbStorage->createProfile("TestDir");
        
        try
        {
            $inputPath = QrbFilePaths::getInputPath("TestDir");
            $testInputFile = $inputPath . "/TestInputFile.txt";
            QrbFiles::writeTextFile($testInputFile, "TestInput");
            
            // call testee
            $this->assertTrue($this->qrbStorage->deleteInputData());
            // test
            $this->assertFalse(file_exists($testInputFile));
            // returns true even if nothing to delete
            $this->assertTrue($this->qrbStorage->deleteInputData());
        }
        finally
        {
            $this->qrbStorage->deleteProfile("TestDir");
            $this->qrbStorage->selectCurrentProfile($savedProfile);
        }
    }

    public function testGetPath()
    {
        $runName = "Test";
        $this->qrbStorage->initializeNewRun($runName, true, false);
        $this->assertEquals(QrbFilePaths::getInputPath($this->qrbStorage->getCurrentProfile()),
                            $this->qrbStorage->getPath(QrbDataType::PDF_TEMPLATE));
        $this->assertEquals(QrbFilePaths::getInputPath($this->qrbStorage->getCurrentProfile()),
                            $this->qrbStorage->getPath(QrbDataType::PDF_DATA));
        $this->assertEquals(QrbFilePaths::getInputPath($this->qrbStorage->getCurrentProfile()),
                            $this->qrbStorage->getPath(QrbDataType::MAIL_BODY));
        $this->assertEquals(QrbFilePaths::getInputPath($this->qrbStorage->getCurrentProfile()),
                            $this->qrbStorage->getPath(QrbDataType::MAIL_DATA));
        $this->assertEquals(QrbFilePaths::getInputPath($this->qrbStorage->getCurrentProfile()),
                            $this->qrbStorage->getPath(QrbDataType::CRED_INFO));
        $this->assertEquals(QrbFilePaths::getInputPath($this->qrbStorage->getCurrentProfile()),
                            $this->qrbStorage->getPath(QrbDataType::ADD_INFO));
        $this->assertEquals(QrbFilePaths::getInputPath($this->qrbStorage->getCurrentProfile()),
                            $this->qrbStorage->getPath(QrbDataType::RECIPIENTS));
        $this->assertEquals(QrbFilePaths::getCfgPath(),
                            $this->qrbStorage->getPath(QrbDataType::TEST_RCPNTS));
        $this->assertEquals(QrbFilePaths::getOutputPathOfRun($this->qrbStorage->getCurrentProfile(), $runName),
                            $this->qrbStorage->getPath(QrbDataType::MARKER_TEST));
        $this->assertEquals(QrbFilePaths::getOutputPathOfRun($this->qrbStorage->getCurrentProfile(), $runName),
                            $this->qrbStorage->getPath(QrbDataType::PROTOCOL));
    }

    public function testGetExtension()
    {
        $this->assertEquals(".pdf",
                            $this->qrbStorage->getExtension(QrbDataType::PDF_TEMPLATE));
        $this->assertEquals(".json",
                            $this->qrbStorage->getExtension(QrbDataType::PDF_DATA));
        $this->assertEquals(".html",
                            $this->qrbStorage->getExtension(QrbDataType::MAIL_BODY));
        $this->assertEquals(".json",
                            $this->qrbStorage->getExtension(QrbDataType::MAIL_DATA));
        $this->assertEquals(".json",
                            $this->qrbStorage->getExtension(QrbDataType::CRED_INFO));
        $this->assertEquals(".json",
                            $this->qrbStorage->getExtension(QrbDataType::ADD_INFO));
        $this->assertEquals(".csv",
                            $this->qrbStorage->getExtension(QrbDataType::RECIPIENTS));
        $this->assertEquals(".csv",
                            $this->qrbStorage->getExtension(QrbDataType::TEST_RCPNTS));
        $this->assertEquals(".marker",
                            $this->qrbStorage->getExtension(QrbDataType::MARKER_TEST));
        $this->assertEquals(".csv",
                            $this->qrbStorage->getExtension(QrbDataType::PROTOCOL));
    }

    public function testGetFileName()
    {
        $this->assertEquals("PdfTemplate.pdf",
                            $this->qrbStorage->getFileName(QrbDataType::PDF_TEMPLATE));
        $this->assertEquals("PdfTemplate_de.pdf",
                            $this->qrbStorage->getFileName(QrbDataType::PDF_TEMPLATE, "de"));
        $this->assertEquals("PdfData.json",
                            $this->qrbStorage->getFileName(QrbDataType::PDF_DATA, ""));
        $this->assertEquals("PdfData_fr.json",
                            $this->qrbStorage->getFileName(QrbDataType::PDF_DATA, "fr"));
        $this->assertEquals("MailBody.html",
                            $this->qrbStorage->getFileName(QrbDataType::MAIL_BODY));
        $this->assertEquals("MailBody_it.html",
                            $this->qrbStorage->getFileName(QrbDataType::MAIL_BODY, "it"));
        $this->assertEquals("MailData.json",
                            $this->qrbStorage->getFileName(QrbDataType::MAIL_DATA, ""));
        $this->assertEquals("MailData_en.json",
                            $this->qrbStorage->getFileName(QrbDataType::MAIL_DATA, "en"));
        $this->assertEquals("CreditorInformation.json",
                            $this->qrbStorage->getFileName(QrbDataType::CRED_INFO));
        $this->assertEquals("AdditionalInformation.json",
                            $this->qrbStorage->getFileName(QrbDataType::ADD_INFO));
        $this->assertEquals("Recipients.csv",
                            $this->qrbStorage->getFileName(QrbDataType::RECIPIENTS));
        $this->assertEquals("RecipientsTestRun.csv",
                            $this->qrbStorage->getFileName(QrbDataType::TEST_RCPNTS));
        $this->assertEquals("qr-bills-test-run.marker",
                            $this->qrbStorage->getFileName(QrbDataType::MARKER_TEST));
        $this->assertEquals("qr-bills-protocol.csv",
                            $this->qrbStorage->getFileName(QrbDataType::PROTOCOL));
    }
}

?>
