10e62c4b8SGreg Roach<?php 23976b470SGreg Roach 30e62c4b8SGreg Roach/** 40e62c4b8SGreg Roach * webtrees: online genealogy 5*5bfc6897SGreg 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; 239a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate; 244358d8aeSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserSetup; 25b6f35a76SGreg Roachuse Fisharebest\Webtrees\Report\PdfRenderer; 26824da64cSGreg Roachuse Fisharebest\Webtrees\Services\ModuleService; 273cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 28a04bb9a2SGreg Roachuse League\Flysystem\Filesystem; 29f7cf8a15SGreg Roachuse League\Flysystem\InMemory\InMemoryFilesystemAdapter; 309a3accd7SGreg Roach 310e62c4b8SGreg Roach/** 320e62c4b8SGreg Roach * Test harness for the class BirthDeathMarriageReportModule 33824da64cSGreg Roach */ 34824da64cSGreg Roachclass BirthDeathMarriageReportModuleTest extends TestCase 35824da64cSGreg Roach{ 36cd94ca66SGreg Roach protected static bool $uses_database = true; 37824da64cSGreg Roach 38824da64cSGreg Roach /** 396113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait 40824da64cSGreg Roach * @covers \Fisharebest\Webtrees\Module\PedigreeReportModule 41b6f35a76SGreg Roach * @covers \Fisharebest\Webtrees\Report\AbstractRenderer 42824da64cSGreg Roach * @covers \Fisharebest\Webtrees\Report\HtmlRenderer 43824da64cSGreg Roach * @covers \Fisharebest\Webtrees\Report\PdfRenderer 446113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseCell 456113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseElement 466113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote 476113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseImage 486113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseLine 496113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseText 506113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox 516113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider 526113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell 536113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote 546113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage 556113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine 566113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlText 576113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlTextbox 586113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserBase 59c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate 606113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserSetup 616113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfCell 626113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote 636113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfImage 646113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfLine 656113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfText 66b6f35a76SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfTextBox 67824da64cSGreg Roach * @covers \Fisharebest\Webtrees\Report\TcpdfWrapper 68824da64cSGreg Roach * 6952348eb8SGreg Roach * @return void 700e62c4b8SGreg Roach */ 719a3accd7SGreg Roach public function testReportRunsWithoutError(): void 72c1010edaSGreg Roach { 73f7cf8a15SGreg Roach $data_filesystem = new Filesystem(new InMemoryFilesystemAdapter()); 74824da64cSGreg Roach $module_service = new ModuleService(); 75a04bb9a2SGreg Roach 769a3accd7SGreg Roach $tree = $this->importTree('demo.ged'); 77824da64cSGreg Roach $module = $module_service->findByInterface(BirthDeathMarriageReportModule::class)->first(); 78824da64cSGreg Roach $xml = 'resources/' . $module->xmlFilename(); 799a3accd7SGreg Roach $vars = [ 809a3accd7SGreg Roach 'name' => ['id' => ''], 819a3accd7SGreg Roach 'bdmplace' => ['id' => ''], 829a3accd7SGreg Roach 'birthdate1' => ['id' => ''], 839a3accd7SGreg Roach 'birthdate2' => ['id' => ''], 849a3accd7SGreg Roach 'deathdate1' => ['id' => ''], 859a3accd7SGreg Roach 'deathdate2' => ['id' => ''], 869a3accd7SGreg Roach 'sortby' => ['id' => 'BIRT:DATE'], 879a3accd7SGreg Roach 'pageSize' => ['id' => 'A4'], 889a3accd7SGreg Roach ]; 899a3accd7SGreg Roach 904358d8aeSGreg Roach $report = new ReportParserSetup($xml); 915e933c21SGreg Roach self::assertIsArray($report->reportProperties()); 924358d8aeSGreg Roach 939a3accd7SGreg Roach ob_start(); 94b6f35a76SGreg Roach new ReportParserGenerate($xml, new HtmlRenderer(), $vars, $tree, $data_filesystem); 959a3accd7SGreg Roach $html = ob_get_clean(); 965e933c21SGreg Roach self::assertStringStartsWith('<', $html); 975e933c21SGreg Roach self::assertStringEndsWith('>', $html); 989a3accd7SGreg Roach 999a3accd7SGreg Roach ob_start(); 100b6f35a76SGreg Roach new ReportParserGenerate($xml, new PdfRenderer(), $vars, $tree, $data_filesystem); 1019a3accd7SGreg Roach $pdf = ob_get_clean(); 1025e933c21SGreg Roach self::assertStringStartsWith('%PDF', $pdf); 1035e933c21SGreg Roach self::assertStringEndsWith("%%EOF\n", $pdf); 1040e62c4b8SGreg Roach } 1050e62c4b8SGreg Roach} 106