xref: /webtrees/tests/app/Module/FactSourcesReportModuleTest.php (revision 3c5bb98b6dc8b535dd6d02c009d1748959dee388)
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
20*3c5bb98bSGreg Roachuse Fisharebest\Webtrees\Auth;
219a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportHtml;
229a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate;
239a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportPdf;
24*3c5bb98bSGreg Roachuse Fisharebest\Webtrees\Services\UserService;
259a3accd7SGreg Roachuse Fisharebest\Webtrees\Tree;
269a3accd7SGreg Roach
273763c3f2SGreg Roach/**
283763c3f2SGreg Roach * Test harness for the class FactSourcesReportModule
299a3accd7SGreg Roach *
306113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\FactSourcesReportModule
316113edefSGreg Roach * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait
326113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\AbstractReport
336113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseCell
346113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseElement
356113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote
366113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseHtml
376113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseImage
386113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseLine
396113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBasePageheader
406113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseText
416113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox
426113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider
439a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtml
446113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell
456113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote
466113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlHtml
476113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage
486113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine
496113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlPageheader
506113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlText
516113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtmlTextbox
526113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserBase
53c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate
546113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserSetup
55c52e6333SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdf
566113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfCell
576113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote
586113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfHtml
596113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfImage
606113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfLine
616113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfPageheader
626113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfText
636113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdfTextbox
646113edefSGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportTcpdf
653763c3f2SGreg Roach */
6684e2cf4eSGreg Roachclass FactSourcesReportModuleTest extends \Fisharebest\Webtrees\TestCase
67c1010edaSGreg Roach{
689a3accd7SGreg Roach    protected static $uses_database = true;
699a3accd7SGreg Roach
703763c3f2SGreg Roach    /**
7152348eb8SGreg Roach     * @return void
723763c3f2SGreg Roach     */
739a3accd7SGreg Roach    public function testReportRunsWithoutError(): void
74c1010edaSGreg Roach    {
75*3c5bb98bSGreg Roach        $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret');
76*3c5bb98bSGreg Roach        $user->setPreference('canadmin', '1');
77*3c5bb98bSGreg Roach        Auth::login($user);
78*3c5bb98bSGreg Roach
799a3accd7SGreg Roach        $tree = $this->importTree('demo.ged');
809a3accd7SGreg Roach        app()->instance(Tree::class, $tree);
819a3accd7SGreg Roach        $xml  = WT_ROOT . 'resources/xml/reports/fact_sources.xml';
829a3accd7SGreg Roach        $vars = [
839a3accd7SGreg Roach            'id'       => ['id' => 's1'],
849a3accd7SGreg Roach            'stype'    => ['id' => 'facts'],
859a3accd7SGreg Roach            'sortby'   => ['id' => 'BIRT:DATE'],
869a3accd7SGreg Roach            'pageSize' => ['id' => 'A4'],
879a3accd7SGreg Roach        ];
889a3accd7SGreg Roach
899a3accd7SGreg Roach        ob_start();
909a3accd7SGreg Roach        new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree);
919a3accd7SGreg Roach        $html = ob_get_clean();
929a3accd7SGreg Roach        $this->assertStringStartsWith('<', $html);
939a3accd7SGreg Roach        $this->assertStringEndsWith('>', $html);
949a3accd7SGreg Roach
959a3accd7SGreg Roach        ob_start();
969a3accd7SGreg Roach        new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree);
979a3accd7SGreg Roach        $pdf = ob_get_clean();
989a3accd7SGreg Roach        $this->assertStringStartsWith('%PDF', $pdf);
999a3accd7SGreg Roach        $this->assertStringEndsWith("%%EOF\n", $pdf);
1003763c3f2SGreg Roach    }
1013763c3f2SGreg Roach}
102