xref: /webtrees/tests/app/Module/FamilyGroupReportModuleTest.php (revision 9a3accd78795046143d5b995599032fcff82a467)
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*9a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportHtml;
21*9a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportParserGenerate;
22*9a3accd7SGreg Roachuse Fisharebest\Webtrees\Report\ReportPdf;
23*9a3accd7SGreg Roachuse Fisharebest\Webtrees\Tree;
24*9a3accd7SGreg Roach
253763c3f2SGreg Roach/**
263763c3f2SGreg Roach * Test harness for the class FamilyGroupReportModule
27*9a3accd7SGreg Roach *
28*9a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportHtml
29*9a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate;
30*9a3accd7SGreg Roach * @covers \Fisharebest\Webtrees\Report\ReportPdf;
313763c3f2SGreg Roach */
3284e2cf4eSGreg Roachclass FamilyGroupReportModuleTest extends \Fisharebest\Webtrees\TestCase
33c1010edaSGreg Roach{
34*9a3accd7SGreg Roach    protected static $uses_database = true;
35*9a3accd7SGreg Roach
363763c3f2SGreg Roach    /**
3752348eb8SGreg Roach     * @return void
383763c3f2SGreg Roach     */
39*9a3accd7SGreg Roach    public function testReportRunsWithoutError(): void
40c1010edaSGreg Roach    {
41*9a3accd7SGreg Roach        $tree = $this->importTree('demo.ged');
42*9a3accd7SGreg Roach        app()->instance(Tree::class, $tree);
43*9a3accd7SGreg Roach        $xml  = WT_ROOT . 'resources/xml/reports/family_group_report.xml';
44*9a3accd7SGreg Roach        $vars = [
45*9a3accd7SGreg Roach            'id'       => ['id' => 'f1'],
46*9a3accd7SGreg Roach            'sources'  => ['id' => 'on'],
47*9a3accd7SGreg Roach            'notes'    => ['id' => 'on'],
48*9a3accd7SGreg Roach            'photos'   => ['id' => 'on'],
49*9a3accd7SGreg Roach            'colors'   => ['id' => 'on'],
50*9a3accd7SGreg Roach            'blanks'   => ['id' => 'on'],
51*9a3accd7SGreg Roach            'pageSize' => ['id' => 'A4'],
52*9a3accd7SGreg Roach        ];
53*9a3accd7SGreg Roach
54*9a3accd7SGreg Roach        ob_start();
55*9a3accd7SGreg Roach        new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree);
56*9a3accd7SGreg Roach        $html = ob_get_clean();
57*9a3accd7SGreg Roach        $this->assertStringStartsWith('<', $html);
58*9a3accd7SGreg Roach        $this->assertStringEndsWith('>', $html);
59*9a3accd7SGreg Roach
60*9a3accd7SGreg Roach        ob_start();
61*9a3accd7SGreg Roach        new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree);
62*9a3accd7SGreg Roach        $pdf = ob_get_clean();
63*9a3accd7SGreg Roach        $this->assertStringStartsWith('%PDF', $pdf);
64*9a3accd7SGreg Roach        $this->assertStringEndsWith("%%EOF\n", $pdf);
653763c3f2SGreg Roach    }
663763c3f2SGreg Roach}
67