13763c3f2SGreg Roach<?php 2*3976b470SGreg 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 */ 17e7f56f2aSGreg Roachdeclare(strict_types=1); 18e7f56f2aSGreg Roach 1984e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\Module; 203763c3f2SGreg Roach 213c5bb98bSGreg Roachuse Fisharebest\Webtrees\Auth; 229a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportHtml; 239a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate; 244358d8aeSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserSetup; 259a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportPdf; 263c5bb98bSGreg Roachuse Fisharebest\Webtrees\Services\UserService; 279a3accd7SGreg Roachuse Fisharebest\Webtrees\Tree; 28f397d0fdSGreg Roachuse Fisharebest\Webtrees\Webtrees; 299a3accd7SGreg Roach 303763c3f2SGreg Roach/** 313763c3f2SGreg Roach * Test harness for the class DescendancyReportModule 329a3accd7SGreg Roach * 336113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\DescendancyReportModule 346113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait 356113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\AbstractReport 366113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseCell 376113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseElement 386113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote 396113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseHtml 406113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseImage 416113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseLine 426113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBasePageheader 436113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseText 446113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox 456113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider 469a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtml 476113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell 486113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote 496113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlHtml 506113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage 516113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine 526113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlPageheader 536113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlText 546113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlTextbox 556113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserBase 56c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate 576113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserSetup 58c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdf 596113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfCell 606113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote 616113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfHtml 626113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfImage 636113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfLine 646113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfPageheader 656113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfText 666113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfTextbox 676113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportTcpdf 683763c3f2SGreg Roach */ 6984e2cf4eSGreg Roachclass DescendancyReportModuleTest extends \Fisharebest\Webtrees\TestCase 70c1010edaSGreg Roach{ 719a3accd7SGreg Roach protected static $uses_database = true; 729a3accd7SGreg Roach 733763c3f2SGreg Roach /** 7452348eb8SGreg Roach * @return void 753763c3f2SGreg Roach */ 769a3accd7SGreg Roach public function testReportRunsWithoutError(): void 77c1010edaSGreg Roach { 783c5bb98bSGreg Roach $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret'); 793c5bb98bSGreg Roach $user->setPreference('canadmin', '1'); 803c5bb98bSGreg Roach Auth::login($user); 813c5bb98bSGreg Roach 829a3accd7SGreg Roach $tree = $this->importTree('demo.ged'); 839a3accd7SGreg Roach app()->instance(Tree::class, $tree); 84f397d0fdSGreg Roach $xml = Webtrees::ROOT_DIR . 'resources/xml/reports/descendancy_report.xml'; 859a3accd7SGreg Roach $vars = [ 863c5bb98bSGreg Roach 'pid' => ['id' => 'X1030'], 879a3accd7SGreg Roach 'maxgen' => ['id' => '3'], 889a3accd7SGreg Roach 'sources' => ['id' => 'on'], 899a3accd7SGreg Roach 'pageSize' => ['id' => 'A4'], 909a3accd7SGreg Roach ]; 919a3accd7SGreg Roach 924358d8aeSGreg Roach $report = new ReportParserSetup($xml); 934358d8aeSGreg Roach $this->assertIsArray($report->reportProperties()); 944358d8aeSGreg Roach 959a3accd7SGreg Roach ob_start(); 969a3accd7SGreg Roach new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree); 979a3accd7SGreg Roach $html = ob_get_clean(); 989a3accd7SGreg Roach $this->assertStringStartsWith('<', $html); 999a3accd7SGreg Roach $this->assertStringEndsWith('>', $html); 1009a3accd7SGreg Roach 1019a3accd7SGreg Roach ob_start(); 1029a3accd7SGreg Roach new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree); 1039a3accd7SGreg Roach $pdf = ob_get_clean(); 1049a3accd7SGreg Roach $this->assertStringStartsWith('%PDF', $pdf); 1059a3accd7SGreg Roach $this->assertStringEndsWith("%%EOF\n", $pdf); 1063763c3f2SGreg Roach } 1073763c3f2SGreg Roach} 108