1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2023 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\Module; 21 22use Fisharebest\Webtrees\Report\AbstractRenderer; 23use Fisharebest\Webtrees\Report\HtmlRenderer; 24use Fisharebest\Webtrees\Report\PdfRenderer; 25use Fisharebest\Webtrees\Report\ReportBaseCell; 26use Fisharebest\Webtrees\Report\ReportBaseElement; 27use Fisharebest\Webtrees\Report\ReportBaseFootnote; 28use Fisharebest\Webtrees\Report\ReportBaseImage; 29use Fisharebest\Webtrees\Report\ReportBaseLine; 30use Fisharebest\Webtrees\Report\ReportBaseText; 31use Fisharebest\Webtrees\Report\ReportBaseTextbox; 32use Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider; 33use Fisharebest\Webtrees\Report\ReportHtmlCell; 34use Fisharebest\Webtrees\Report\ReportHtmlFootnote; 35use Fisharebest\Webtrees\Report\ReportHtmlImage; 36use Fisharebest\Webtrees\Report\ReportHtmlLine; 37use Fisharebest\Webtrees\Report\ReportHtmlText; 38use Fisharebest\Webtrees\Report\ReportHtmlTextbox; 39use Fisharebest\Webtrees\Report\ReportParserBase; 40use Fisharebest\Webtrees\Report\ReportParserGenerate; 41use Fisharebest\Webtrees\Report\ReportParserSetup; 42use Fisharebest\Webtrees\Report\ReportPdfCell; 43use Fisharebest\Webtrees\Report\ReportPdfFootnote; 44use Fisharebest\Webtrees\Report\ReportPdfImage; 45use Fisharebest\Webtrees\Report\ReportPdfLine; 46use Fisharebest\Webtrees\Report\ReportPdfText; 47use Fisharebest\Webtrees\Report\ReportPdfTextBox; 48use Fisharebest\Webtrees\Report\TcpdfWrapper; 49use Fisharebest\Webtrees\TestCase; 50use PHPUnit\Framework\Attributes\CoversClass; 51 52#[CoversTrait(ModuleReportTrait::trait)] 53#[CoversClass(PedigreeReportModule::class)] 54#[CoversClass(AbstractRenderer::class)] 55#[CoversClass(HtmlRenderer::class)] 56#[CoversClass(PdfRenderer::class)] 57#[CoversClass(ReportBaseCell::class)] 58#[CoversClass(ReportBaseElement::class)] 59#[CoversClass(ReportBaseFootnote::class)] 60#[CoversClass(ReportBaseImage::class)] 61#[CoversClass(ReportBaseLine::class)] 62#[CoversClass(ReportBaseText::class)] 63#[CoversClass(ReportBaseTextbox::class)] 64#[CoversClass(ReportExpressionLanguageProvider::class)] 65#[CoversClass(ReportHtmlCell::class)] 66#[CoversClass(ReportHtmlFootnote::class)] 67#[CoversClass(ReportHtmlImage::class)] 68#[CoversClass(ReportHtmlLine::class)] 69#[CoversClass(ReportHtmlText::class)] 70#[CoversClass(ReportHtmlTextbox::class)] 71#[CoversClass(ReportParserBase::class)] 72#[CoversClass(ReportParserGenerate::class)] 73#[CoversClass(ReportParserSetup::class)] 74#[CoversClass(ReportPdfCell::class)] 75#[CoversClass(ReportPdfFootnote::class)] 76#[CoversClass(ReportPdfImage::class)] 77#[CoversClass(ReportPdfLine::class)] 78#[CoversClass(ReportPdfText::class)] 79#[CoversClass(ReportPdfTextBox::class)] 80#[CoversClass(TcpdfWrapper::class)] 81class BirthDeathMarriageReportModuleTest extends TestCase 82{ 83 protected static bool $uses_database = true; 84 85 public function testReportRunsWithoutError(): void 86 { 87 $tree = $this->importTree('demo.ged'); 88 $module = new BirthDeathMarriageReportModule(); 89 $module->setName('bdm_report'); 90 91 $xml = 'resources/' . $module->xmlFilename(); 92 $vars = [ 93 'name' => ['id' => ''], 94 'bdmplace' => ['id' => ''], 95 'birthdate1' => ['id' => ''], 96 'birthdate2' => ['id' => ''], 97 'deathdate1' => ['id' => ''], 98 'deathdate2' => ['id' => ''], 99 'sortby' => ['id' => 'BIRT:DATE'], 100 'pageSize' => ['id' => 'A4'], 101 ]; 102 103 $report = new ReportParserSetup($xml); 104 self::assertNotEmpty($report->reportProperties()); 105 106 ob_start(); 107 new ReportParserGenerate($xml, new HtmlRenderer(), $vars, $tree); 108 $html = ob_get_clean(); 109 self::assertStringStartsWith('<', $html); 110 self::assertStringEndsWith('>', $html); 111 112 ob_start(); 113 new ReportParserGenerate($xml, new PdfRenderer(), $vars, $tree); 114 $pdf = ob_get_clean(); 115 self::assertStringStartsWith('%PDF', $pdf); 116 self::assertStringEndsWith("%%EOF\n", $pdf); 117 } 118} 119