13763c3f2SGreg Roach<?php 23976b470SGreg Roach 33763c3f2SGreg Roach/** 43763c3f2SGreg Roach * webtrees: online genealogy 58fcd0d32SGreg Roach * Copyright (C) 2019 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 153763c3f2SGreg Roach * along with this program. If not, see <http://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; 239a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportHtml; 249a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate; 254358d8aeSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserSetup; 269a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportPdf; 273c5bb98bSGreg Roachuse Fisharebest\Webtrees\Services\UserService; 283cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 29*7c4add84SGreg Roachuse Fisharebest\Webtrees\User; 30f397d0fdSGreg Roachuse Fisharebest\Webtrees\Webtrees; 31a04bb9a2SGreg Roachuse League\Flysystem\Adapter\NullAdapter; 32a04bb9a2SGreg Roachuse League\Flysystem\Filesystem; 339a3accd7SGreg Roach 343763c3f2SGreg Roach/** 353763c3f2SGreg Roach * Test harness for the class IndividualReportModule 369a3accd7SGreg Roach * 376113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\IndividualReportModule 386113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait 396113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\AbstractReport 406113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseCell 416113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseElement 426113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote 436113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseHtml 446113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseImage 456113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseLine 466113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBasePageheader 476113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseText 486113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox 496113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider 509a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtml 516113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell 526113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote 536113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlHtml 546113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage 556113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine 566113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlPageheader 576113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlText 586113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlTextbox 596113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserBase 60c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate 616113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserSetup 626113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdf 636113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfCell 646113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote 656113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfHtml 666113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfImage 676113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfLine 686113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfPageheader 696113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfText 706113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfTextbox 716113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportTcpdf 72c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdf 733763c3f2SGreg Roach */ 743cfcc809SGreg Roachclass IndividualReportModuleTest extends TestCase 75c1010edaSGreg Roach{ 769a3accd7SGreg Roach protected static $uses_database = true; 779a3accd7SGreg Roach 783763c3f2SGreg Roach /** 7952348eb8SGreg Roach * @return void 803763c3f2SGreg Roach */ 819a3accd7SGreg Roach public function testReportRunsWithoutError(): void 82c1010edaSGreg Roach { 83a04bb9a2SGreg Roach $data_filesystem = new Filesystem(new NullAdapter()); 84a04bb9a2SGreg Roach 853c5bb98bSGreg Roach $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret'); 86*7c4add84SGreg Roach $user->setPreference(User::PREF_IS_ADMINISTRATOR, '1'); 873c5bb98bSGreg Roach Auth::login($user); 883c5bb98bSGreg Roach 899a3accd7SGreg Roach $tree = $this->importTree('demo.ged'); 90f397d0fdSGreg Roach $xml = Webtrees::ROOT_DIR . 'resources/xml/reports/individual_report.xml'; 919a3accd7SGreg Roach $vars = [ 923c5bb98bSGreg Roach 'id' => ['id' => 'X1030'], 939a3accd7SGreg Roach 'sources' => ['id' => 'on'], 949a3accd7SGreg Roach 'notes' => ['id' => 'on'], 959a3accd7SGreg Roach 'photos' => ['id' => 'highlighted'], 969a3accd7SGreg Roach 'colors' => ['id' => 'on'], 979a3accd7SGreg Roach 'pageSize' => ['id' => 'A4'], 989a3accd7SGreg Roach ]; 999a3accd7SGreg Roach 1004358d8aeSGreg Roach $report = new ReportParserSetup($xml); 1014358d8aeSGreg Roach $this->assertIsArray($report->reportProperties()); 1024358d8aeSGreg Roach 1039a3accd7SGreg Roach ob_start(); 104a04bb9a2SGreg Roach new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree, $data_filesystem); 1059a3accd7SGreg Roach $html = ob_get_clean(); 1069a3accd7SGreg Roach $this->assertStringStartsWith('<', $html); 1079a3accd7SGreg Roach $this->assertStringEndsWith('>', $html); 1089a3accd7SGreg Roach 1099a3accd7SGreg Roach ob_start(); 110a04bb9a2SGreg Roach new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree, $data_filesystem); 1119a3accd7SGreg Roach $pdf = ob_get_clean(); 1129a3accd7SGreg Roach $this->assertStringStartsWith('%PDF', $pdf); 1139a3accd7SGreg Roach $this->assertStringEndsWith("%%EOF\n", $pdf); 1143763c3f2SGreg Roach } 1153763c3f2SGreg Roach} 116