13763c3f2SGreg Roach<?php 23976b470SGreg Roach 33763c3f2SGreg Roach/** 43763c3f2SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 63763c3f2SGreg Roach * This program is free software: you can redistribute it and/or modify 73763c3f2SGreg Roach * it under the terms of the GNU General Public License as published by 83763c3f2SGreg Roach * the Free Software Foundation, either version 3 of the License, or 93763c3f2SGreg Roach * (at your option) any later version. 103763c3f2SGreg Roach * This program is distributed in the hope that it will be useful, 113763c3f2SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 123763c3f2SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 133763c3f2SGreg Roach * GNU General Public License for more details. 143763c3f2SGreg 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/>. 163763c3f2SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2084e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\Module; 213763c3f2SGreg Roach 223c5bb98bSGreg Roachuse Fisharebest\Webtrees\Auth; 231fe542e9SGreg Roachuse Fisharebest\Webtrees\Contracts\UserInterface; 24*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\AbstractRenderer; 25b6f35a76SGreg Roachuse Fisharebest\Webtrees\Report\HtmlRenderer; 26f0c88a96SGreg Roachuse Fisharebest\Webtrees\Report\PdfRenderer; 27*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportBaseCell; 28*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportBaseElement; 29*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportBaseFootnote; 30*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportBaseImage; 31*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportBaseLine; 32*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportBaseText; 33*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportBaseTextbox; 34*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider; 35*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportHtmlCell; 36*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportHtmlFootnote; 37*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportHtmlImage; 38*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportHtmlLine; 39*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportHtmlText; 40*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportHtmlTextbox; 41*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserBase; 429a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate; 434358d8aeSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserSetup; 44*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportPdfCell; 45*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportPdfFootnote; 46*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportPdfImage; 47*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportPdfLine; 48*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportPdfText; 49*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\ReportPdfTextBox; 50*202c018bSGreg Roachuse Fisharebest\Webtrees\Report\TcpdfWrapper; 513c5bb98bSGreg Roachuse Fisharebest\Webtrees\Services\UserService; 523cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 53*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 549a3accd7SGreg Roach 55*202c018bSGreg Roach 56*202c018bSGreg Roach#[CoversClass(ModuleReportTrait::class)] 57*202c018bSGreg Roach#[CoversClass(PedigreeReportModule::class)] 58*202c018bSGreg Roach#[CoversClass(AbstractRenderer::class)] 59*202c018bSGreg Roach#[CoversClass(HtmlRenderer::class)] 60*202c018bSGreg Roach#[CoversClass(PdfRenderer::class)] 61*202c018bSGreg Roach#[CoversClass(ReportBaseCell::class)] 62*202c018bSGreg Roach#[CoversClass(ReportBaseElement::class)] 63*202c018bSGreg Roach#[CoversClass(ReportBaseFootnote::class)] 64*202c018bSGreg Roach#[CoversClass(ReportBaseImage::class)] 65*202c018bSGreg Roach#[CoversClass(ReportBaseLine::class)] 66*202c018bSGreg Roach#[CoversClass(ReportBaseText::class)] 67*202c018bSGreg Roach#[CoversClass(ReportBaseTextbox::class)] 68*202c018bSGreg Roach#[CoversClass(ReportExpressionLanguageProvider::class)] 69*202c018bSGreg Roach#[CoversClass(ReportHtmlCell::class)] 70*202c018bSGreg Roach#[CoversClass(ReportHtmlFootnote::class)] 71*202c018bSGreg Roach#[CoversClass(ReportHtmlImage::class)] 72*202c018bSGreg Roach#[CoversClass(ReportHtmlLine::class)] 73*202c018bSGreg Roach#[CoversClass(ReportHtmlText::class)] 74*202c018bSGreg Roach#[CoversClass(ReportHtmlTextbox::class)] 75*202c018bSGreg Roach#[CoversClass(ReportParserBase::class)] 76*202c018bSGreg Roach#[CoversClass(ReportParserGenerate::class)] 77*202c018bSGreg Roach#[CoversClass(ReportParserSetup::class)] 78*202c018bSGreg Roach#[CoversClass(ReportPdfCell::class)] 79*202c018bSGreg Roach#[CoversClass(ReportPdfFootnote::class)] 80*202c018bSGreg Roach#[CoversClass(ReportPdfImage::class)] 81*202c018bSGreg Roach#[CoversClass(ReportPdfLine::class)] 82*202c018bSGreg Roach#[CoversClass(ReportPdfText::class)] 83*202c018bSGreg Roach#[CoversClass(ReportPdfTextBox::class)] 84*202c018bSGreg Roach#[CoversClass(TcpdfWrapper::class)] 85824da64cSGreg Roachclass MissingFactsReportModuleTest extends TestCase 86824da64cSGreg Roach{ 87cd94ca66SGreg Roach protected static bool $uses_database = true; 88824da64cSGreg Roach 899a3accd7SGreg Roach public function testReportRunsWithoutError(): void 90c1010edaSGreg Roach { 913c5bb98bSGreg Roach $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret'); 921fe542e9SGreg Roach $user->setPreference(UserInterface::PREF_IS_ADMINISTRATOR, '1'); 933c5bb98bSGreg Roach Auth::login($user); 943c5bb98bSGreg Roach 959a3accd7SGreg Roach $tree = $this->importTree('demo.ged'); 960acf1b4bSGreg Roach $module = new MissingFactsReportModule(); 970acf1b4bSGreg Roach $module->setName('missing_facts_report'); 980acf1b4bSGreg Roach 99824da64cSGreg Roach $xml = 'resources/' . $module->xmlFilename(); 1009a3accd7SGreg Roach $vars = [ 1013c5bb98bSGreg Roach 'pid' => ['id' => 'X1030'], 1029a3accd7SGreg Roach 'relatives' => ['id' => 'direct-ancestors'], 1039a3accd7SGreg Roach 'maxgen' => ['id' => '*'], 1049a3accd7SGreg Roach 'pageSize' => ['id' => 'A4'], 1059a3accd7SGreg Roach 'sortby' => ['id' => 'NAME'], 1069a3accd7SGreg Roach 'fbirt' => ['id' => 'on'], 1073c5bb98bSGreg Roach 'fburi' => ['id' => 'on'], 1089a3accd7SGreg Roach 'fdeat' => ['id' => 'on'], 1099a3accd7SGreg Roach 'fsour' => ['id' => 'on'], 1109a3accd7SGreg Roach 'fbapm' => ['id' => 'on'], 1119a3accd7SGreg Roach 'fbarm' => ['id' => 'on'], 1129a3accd7SGreg Roach 'fbasm' => ['id' => 'on'], 1139a3accd7SGreg Roach 'fconf' => ['id' => 'on'], 1149a3accd7SGreg Roach 'fenga' => ['id' => 'on'], 1159a3accd7SGreg Roach 'ffcom' => ['id' => 'on'], 1169a3accd7SGreg Roach 'fmarb' => ['id' => 'on'], 1179a3accd7SGreg Roach 'fmarr' => ['id' => 'on'], 1189a3accd7SGreg Roach 'freli' => ['id' => 'on'], 1199a3accd7SGreg Roach ]; 1209a3accd7SGreg Roach 1214358d8aeSGreg Roach $report = new ReportParserSetup($xml); 12258a588c6SGreg Roach self::assertNotEmpty($report->reportProperties()); 1234358d8aeSGreg Roach 1249a3accd7SGreg Roach ob_start(); 1259458f20aSGreg Roach new ReportParserGenerate($xml, new HtmlRenderer(), $vars, $tree); 1269a3accd7SGreg Roach $html = ob_get_clean(); 1275e933c21SGreg Roach self::assertStringStartsWith('<', $html); 1285e933c21SGreg Roach self::assertStringEndsWith('>', $html); 1299a3accd7SGreg Roach 1309a3accd7SGreg Roach ob_start(); 1319458f20aSGreg Roach new ReportParserGenerate($xml, new PdfRenderer(), $vars, $tree); 1329a3accd7SGreg Roach $pdf = ob_get_clean(); 1335e933c21SGreg Roach self::assertStringStartsWith('%PDF', $pdf); 1345e933c21SGreg Roach self::assertStringEndsWith("%%EOF\n", $pdf); 1353763c3f2SGreg Roach } 1363763c3f2SGreg Roach} 137