xref: /webtrees/tests/app/Module/BirthDeathMarriageReportModuleTest.php (revision a04bb9a236e92915034f97b1229f5d47c9bc750f)
10e62c4b8SGreg Roach<?php
23976b470SGreg Roach
30e62c4b8SGreg Roach/**
40e62c4b8SGreg Roach * webtrees: online genealogy
58fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
60e62c4b8SGreg Roach * This program is free software: you can redistribute it and/or modify
70e62c4b8SGreg Roach * it under the terms of the GNU General Public License as published by
80e62c4b8SGreg Roach * the Free Software Foundation, either version 3 of the License, or
90e62c4b8SGreg Roach * (at your option) any later version.
100e62c4b8SGreg Roach * This program is distributed in the hope that it will be useful,
110e62c4b8SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
120e62c4b8SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
130e62c4b8SGreg Roach * GNU General Public License for more details.
140e62c4b8SGreg Roach * You should have received a copy of the GNU General Public License
150e62c4b8SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
160e62c4b8SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
2084e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\Module;
210e62c4b8SGreg Roach
229a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportHtml;
239a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate;
244358d8aeSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserSetup;
259a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportPdf;
263cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
27f397d0fdSGreg Roachuse Fisharebest\Webtrees\Webtrees;
28*a04bb9a2SGreg Roachuse League\Flysystem\Adapter\NullAdapter;
29*a04bb9a2SGreg Roachuse League\Flysystem\Filesystem;
309a3accd7SGreg Roach
310e62c4b8SGreg Roach/**
320e62c4b8SGreg Roach * Test harness for the class BirthDeathMarriageReportModule
339a3accd7SGreg Roach *
346113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\BirthDeathMarriageReportModule
356113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait
366113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\AbstractReport
376113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseCell
386113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseElement
396113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote
406113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseHtml
416113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseImage
426113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseLine
436113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBasePageheader
446113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseText
456113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox
466113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider
479a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtml
486113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell
496113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote
506113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlHtml
516113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage
526113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine
536113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlPageheader
546113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlText
556113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlTextbox
566113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserBase
57c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate
586113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserSetup
59c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdf
606113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfCell
616113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote
626113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfHtml
636113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfImage
646113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfLine
656113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfPageheader
666113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfText
676113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfTextbox
686113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportTcpdf
690e62c4b8SGreg Roach */
703cfcc809SGreg Roachclass BirthDeathMarriageReportModuleTest extends TestCase
71c1010edaSGreg Roach{
729a3accd7SGreg Roach    protected static $uses_database = true;
739a3accd7SGreg Roach
740e62c4b8SGreg Roach    /**
7552348eb8SGreg Roach     * @return void
760e62c4b8SGreg Roach     */
779a3accd7SGreg Roach    public function testReportRunsWithoutError(): void
78c1010edaSGreg Roach    {
79*a04bb9a2SGreg Roach        $data_filesystem = new Filesystem(new NullAdapter());
80*a04bb9a2SGreg Roach
819a3accd7SGreg Roach        $tree = $this->importTree('demo.ged');
82f397d0fdSGreg Roach        $xml  = Webtrees::ROOT_DIR . 'resources/xml/reports/bdm_report.xml';
839a3accd7SGreg Roach        $vars = [
849a3accd7SGreg Roach            'name'       => ['id' => ''],
859a3accd7SGreg Roach            'bdmplace'   => ['id' => ''],
869a3accd7SGreg Roach            'birthdate1' => ['id' => ''],
879a3accd7SGreg Roach            'birthdate2' => ['id' => ''],
889a3accd7SGreg Roach            'deathdate1' => ['id' => ''],
899a3accd7SGreg Roach            'deathdate2' => ['id' => ''],
909a3accd7SGreg Roach            'sortby'     => ['id' => 'BIRT:DATE'],
919a3accd7SGreg Roach            'pageSize'   => ['id' => 'A4'],
929a3accd7SGreg Roach        ];
939a3accd7SGreg Roach
944358d8aeSGreg Roach        $report = new ReportParserSetup($xml);
954358d8aeSGreg Roach        $this->assertIsArray($report->reportProperties());
964358d8aeSGreg Roach
979a3accd7SGreg Roach        ob_start();
98*a04bb9a2SGreg Roach        new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree, $data_filesystem);
999a3accd7SGreg Roach        $html = ob_get_clean();
1009a3accd7SGreg Roach        $this->assertStringStartsWith('<', $html);
1019a3accd7SGreg Roach        $this->assertStringEndsWith('>', $html);
1029a3accd7SGreg Roach
1039a3accd7SGreg Roach        ob_start();
104*a04bb9a2SGreg Roach        new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree, $data_filesystem);
1059a3accd7SGreg Roach        $pdf = ob_get_clean();
1069a3accd7SGreg Roach        $this->assertStringStartsWith('%PDF', $pdf);
1079a3accd7SGreg Roach        $this->assertStringEndsWith("%%EOF\n", $pdf);
1080e62c4b8SGreg Roach    }
1090e62c4b8SGreg Roach}
110