xref: /webtrees/tests/app/Module/PedigreeReportModuleTest.php (revision 4358d8ae61ad3a69c9460d7a3f75ae9fd271cce7)
13763c3f2SGreg Roach<?php
23763c3f2SGreg Roach/**
33763c3f2SGreg Roach * webtrees: online genealogy
48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
53763c3f2SGreg Roach * This program is free software: you can redistribute it and/or modify
63763c3f2SGreg Roach * it under the terms of the GNU General Public License as published by
73763c3f2SGreg Roach * the Free Software Foundation, either version 3 of the License, or
83763c3f2SGreg Roach * (at your option) any later version.
93763c3f2SGreg Roach * This program is distributed in the hope that it will be useful,
103763c3f2SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
113763c3f2SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
123763c3f2SGreg Roach * GNU General Public License for more details.
133763c3f2SGreg Roach * You should have received a copy of the GNU General Public License
143763c3f2SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
153763c3f2SGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
1884e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\Module;
193763c3f2SGreg Roach
203c5bb98bSGreg Roachuse Fisharebest\Webtrees\Auth;
219a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportHtml;
229a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate;
23*4358d8aeSGreg Roachuse Fisharebest\Webtrees\Report\ReportParserSetup;
249a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportPdf;
253c5bb98bSGreg Roachuse Fisharebest\Webtrees\Services\UserService;
269a3accd7SGreg Roachuse Fisharebest\Webtrees\Tree;
27f397d0fdSGreg Roachuse Fisharebest\Webtrees\Webtrees;
289a3accd7SGreg Roach
293763c3f2SGreg Roach/**
303763c3f2SGreg Roach * Test harness for the class PedigreeReportModule
319a3accd7SGreg Roach *
326113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait
336113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\PedigreeReportModule
346113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\AbstractReport
356113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseCell
366113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseElement
376113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote
386113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseHtml
396113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseImage
406113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseLine
416113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBasePageheader
426113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseText
436113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox
446113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider
459a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtml
466113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell
476113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote
486113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlHtml
496113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage
506113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine
516113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlPageheader
526113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlText
536113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlTextbox
546113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserBase
55c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate
566113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserSetup
57c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdf
586113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfCell
596113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote
606113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfHtml
616113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfImage
626113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfLine
636113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfPageheader
646113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfText
656113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfTextbox
666113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportTcpdf
673763c3f2SGreg Roach */
6884e2cf4eSGreg Roachclass PedigreeReportModuleTest extends \Fisharebest\Webtrees\TestCase
69c1010edaSGreg Roach{
709a3accd7SGreg Roach    protected static $uses_database = true;
719a3accd7SGreg Roach
723763c3f2SGreg Roach    /**
7352348eb8SGreg Roach     * @return void
743763c3f2SGreg Roach     */
759a3accd7SGreg Roach    public function testReportRunsWithoutError(): void
76c1010edaSGreg Roach    {
773c5bb98bSGreg Roach        $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret');
783c5bb98bSGreg Roach        $user->setPreference('canadmin', '1');
793c5bb98bSGreg Roach        Auth::login($user);
803c5bb98bSGreg Roach
819a3accd7SGreg Roach        $tree = $this->importTree('demo.ged');
829a3accd7SGreg Roach        app()->instance(Tree::class, $tree);
83f397d0fdSGreg Roach        $xml  = Webtrees::ROOT_DIR . 'resources/xml/reports/pedigree_report.xml';
849a3accd7SGreg Roach        $vars = [
853c5bb98bSGreg Roach            'pid'         => ['id' => 'X1030'],
8669cbf2a4SGreg Roach            'spouses'     => ['id' => 'on'],
879a3accd7SGreg Roach            'orientation' => ['id' => 'portrait'],
889a3accd7SGreg Roach        ];
899a3accd7SGreg Roach
90*4358d8aeSGreg Roach        $report = new ReportParserSetup($xml);
91*4358d8aeSGreg Roach        $this->assertIsArray($report->reportProperties());
92*4358d8aeSGreg Roach
939a3accd7SGreg Roach        ob_start();
949a3accd7SGreg Roach        new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree);
959a3accd7SGreg Roach        $html = ob_get_clean();
969a3accd7SGreg Roach        $this->assertStringStartsWith('<', $html);
979a3accd7SGreg Roach        $this->assertStringEndsWith('>', $html);
989a3accd7SGreg Roach
999a3accd7SGreg Roach        ob_start();
1009a3accd7SGreg Roach        new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree);
1019a3accd7SGreg Roach        $pdf = ob_get_clean();
1029a3accd7SGreg Roach        $this->assertStringStartsWith('%PDF', $pdf);
1039a3accd7SGreg Roach        $this->assertStringEndsWith("%%EOF\n", $pdf);
1043763c3f2SGreg Roach    }
1053763c3f2SGreg Roach}
106