xref: /webtrees/tests/app/Module/BirthDeathMarriageReportModuleTest.php (revision 9458f20a3c5e8e676f65488153a8d8a76b1773fb)
10e62c4b8SGreg Roach<?php
23976b470SGreg Roach
30e62c4b8SGreg Roach/**
40e62c4b8SGreg Roach * webtrees: online genealogy
55bfc6897SGreg Roach * Copyright (C) 2022 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
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
160e62c4b8SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
2084e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\Module;
210e62c4b8SGreg Roach
22b6f35a76SGreg Roachuse Fisharebest\Webtrees\Report\HtmlRenderer;
23f0c88a96SGreg Roachuse Fisharebest\Webtrees\Report\PdfRenderer;
249a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate;
254358d8aeSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserSetup;
26824da64cSGreg Roachuse Fisharebest\Webtrees\Services\ModuleService;
273cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
289a3accd7SGreg Roach
290e62c4b8SGreg Roach/**
300e62c4b8SGreg Roach * Test harness for the class BirthDeathMarriageReportModule
31824da64cSGreg Roach */
32824da64cSGreg Roachclass BirthDeathMarriageReportModuleTest extends TestCase
33824da64cSGreg Roach{
34cd94ca66SGreg Roach    protected static bool $uses_database = true;
35824da64cSGreg Roach
36824da64cSGreg Roach    /**
376113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait
38824da64cSGreg Roach     * @covers \Fisharebest\Webtrees\Module\PedigreeReportModule
39b6f35a76SGreg Roach     * @covers \Fisharebest\Webtrees\Report\AbstractRenderer
40824da64cSGreg Roach     * @covers \Fisharebest\Webtrees\Report\HtmlRenderer
41824da64cSGreg Roach     * @covers \Fisharebest\Webtrees\Report\PdfRenderer
426113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportBaseCell
436113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportBaseElement
446113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote
456113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportBaseImage
466113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportBaseLine
476113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportBaseText
486113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox
496113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider
506113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell
516113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote
526113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage
536113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine
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
596113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportPdfCell
606113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote
616113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportPdfImage
626113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportPdfLine
636113edefSGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportPdfText
64b6f35a76SGreg Roach     * @covers \Fisharebest\Webtrees\Report\ReportPdfTextBox
65824da64cSGreg Roach     * @covers \Fisharebest\Webtrees\Report\TcpdfWrapper
66824da64cSGreg Roach     *
6752348eb8SGreg Roach     * @return void
680e62c4b8SGreg Roach     */
699a3accd7SGreg Roach    public function testReportRunsWithoutError(): void
70c1010edaSGreg Roach    {
71824da64cSGreg Roach        $module_service = new ModuleService();
72a04bb9a2SGreg Roach
739a3accd7SGreg Roach        $tree   = $this->importTree('demo.ged');
74824da64cSGreg Roach        $module = $module_service->findByInterface(BirthDeathMarriageReportModule::class)->first();
75824da64cSGreg Roach        $xml    = 'resources/' . $module->xmlFilename();
769a3accd7SGreg Roach        $vars   = [
779a3accd7SGreg Roach            'name'       => ['id' => ''],
789a3accd7SGreg Roach            'bdmplace'   => ['id' => ''],
799a3accd7SGreg Roach            'birthdate1' => ['id' => ''],
809a3accd7SGreg Roach            'birthdate2' => ['id' => ''],
819a3accd7SGreg Roach            'deathdate1' => ['id' => ''],
829a3accd7SGreg Roach            'deathdate2' => ['id' => ''],
839a3accd7SGreg Roach            'sortby'     => ['id' => 'BIRT:DATE'],
849a3accd7SGreg Roach            'pageSize'   => ['id' => 'A4'],
859a3accd7SGreg Roach        ];
869a3accd7SGreg Roach
874358d8aeSGreg Roach        $report = new ReportParserSetup($xml);
885e933c21SGreg Roach        self::assertIsArray($report->reportProperties());
894358d8aeSGreg Roach
909a3accd7SGreg Roach        ob_start();
91*9458f20aSGreg Roach        new ReportParserGenerate($xml, new HtmlRenderer(), $vars, $tree);
929a3accd7SGreg Roach        $html = ob_get_clean();
935e933c21SGreg Roach        self::assertStringStartsWith('<', $html);
945e933c21SGreg Roach        self::assertStringEndsWith('>', $html);
959a3accd7SGreg Roach
969a3accd7SGreg Roach        ob_start();
97*9458f20aSGreg Roach        new ReportParserGenerate($xml, new PdfRenderer(), $vars, $tree);
989a3accd7SGreg Roach        $pdf = ob_get_clean();
995e933c21SGreg Roach        self::assertStringStartsWith('%PDF', $pdf);
1005e933c21SGreg Roach        self::assertStringEndsWith("%%EOF\n", $pdf);
1010e62c4b8SGreg Roach    }
1020e62c4b8SGreg Roach}
103