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 */ 17*fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2084e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\Module; 213763c3f2SGreg Roach 223c5bb98bSGreg Roachuse Fisharebest\Webtrees\Auth; 2348f08416SGreg Roachuse Fisharebest\Webtrees\Carbon; 249a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportHtml; 259a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate; 264358d8aeSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserSetup; 279a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportPdf; 283c5bb98bSGreg Roachuse Fisharebest\Webtrees\Services\UserService; 293cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 309a3accd7SGreg Roachuse Fisharebest\Webtrees\Tree; 31f397d0fdSGreg Roachuse Fisharebest\Webtrees\Webtrees; 329a3accd7SGreg Roach 333763c3f2SGreg Roach/** 343763c3f2SGreg Roach * Test harness for the class ChangeReportModule 359a3accd7SGreg Roach * 366113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\ChangeReportModule 376113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait 386113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\AbstractReport 396113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseCell 406113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseElement 416113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote 426113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseHtml 436113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseImage 446113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseLine 456113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBasePageheader 466113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseText 476113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox 486113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider 499a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtml 506113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell 516113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote 526113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlHtml 536113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage 546113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine 556113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlPageheader 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 61c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdf 626113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfCell 636113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote 646113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfHtml 656113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfImage 666113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfLine 676113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfPageheader 686113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfText 696113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfTextbox 706113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportTcpdf 713763c3f2SGreg Roach */ 723cfcc809SGreg Roachclass ChangeReportModuleTest extends TestCase 73c1010edaSGreg Roach{ 749a3accd7SGreg Roach protected static $uses_database = true; 759a3accd7SGreg Roach 763763c3f2SGreg Roach /** 7752348eb8SGreg Roach * @return void 783763c3f2SGreg Roach */ 799a3accd7SGreg Roach public function testReportRunsWithoutError(): void 80c1010edaSGreg Roach { 813c5bb98bSGreg Roach $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret'); 823c5bb98bSGreg Roach $user->setPreference('canadmin', '1'); 833c5bb98bSGreg Roach Auth::login($user); 843c5bb98bSGreg Roach 859a3accd7SGreg Roach $tree = $this->importTree('demo.ged'); 869a3accd7SGreg Roach app()->instance(Tree::class, $tree); 87f397d0fdSGreg Roach $xml = Webtrees::ROOT_DIR . 'resources/xml/reports/change_report.xml'; 889a3accd7SGreg Roach $vars = [ 899a3accd7SGreg Roach 'changeRangeStart' => ['id' => Carbon::now()->subMonths(1)->format('d M Y')], 909a3accd7SGreg Roach 'changeRangeEnd' => ['id' => Carbon::now()->format('d M Y')], 919a3accd7SGreg Roach 'pending' => ['id' => 'yes'], 929a3accd7SGreg Roach 'sortby' => ['id' => 'CHAN'], 939a3accd7SGreg Roach 'pageSize' => ['id' => 'A4'], 949a3accd7SGreg Roach 'pageorient' => ['id' => 'landscape'], 959a3accd7SGreg Roach ]; 969a3accd7SGreg Roach 974358d8aeSGreg Roach $report = new ReportParserSetup($xml); 984358d8aeSGreg Roach $this->assertIsArray($report->reportProperties()); 994358d8aeSGreg Roach 1009a3accd7SGreg Roach ob_start(); 1019a3accd7SGreg Roach new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree); 1029a3accd7SGreg Roach $html = ob_get_clean(); 1039a3accd7SGreg Roach $this->assertStringStartsWith('<', $html); 1049a3accd7SGreg Roach $this->assertStringEndsWith('>', $html); 1059a3accd7SGreg Roach 1069a3accd7SGreg Roach ob_start(); 1079a3accd7SGreg Roach new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree); 1089a3accd7SGreg Roach $pdf = ob_get_clean(); 1099a3accd7SGreg Roach $this->assertStringStartsWith('%PDF', $pdf); 1109a3accd7SGreg Roach $this->assertStringEndsWith("%%EOF\n", $pdf); 1113763c3f2SGreg Roach } 1123763c3f2SGreg Roach} 113