xref: /webtrees/tests/app/Module/IndividualFamiliesReportModuleTest.php (revision 9a3accd78795046143d5b995599032fcff82a467)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Module;
19
20use Fisharebest\Webtrees\Report\ReportHtml;
21use Fisharebest\Webtrees\Report\ReportParserGenerate;
22use Fisharebest\Webtrees\Report\ReportPdf;
23use Fisharebest\Webtrees\Tree;
24
25/**
26 * Test harness for the class IndividualFamiliesReportModule
27 *
28 * @covers \Fisharebest\Webtrees\Report\ReportHtml
29 * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate;
30 * @covers \Fisharebest\Webtrees\Report\ReportPdf;
31 */
32class IndividualFamiliesReportModuleTest extends \Fisharebest\Webtrees\TestCase
33{
34    protected static $uses_database = true;
35
36    /**
37     * @return void
38     */
39    public function testReportRunsWithoutError(): void
40    {
41        $tree = $this->importTree('demo.ged');
42        app()->instance(Tree::class, $tree);
43        $xml  = WT_ROOT . 'resources/xml/reports/individual_ext_report.xml';
44        $vars = [
45            'pid'       => ['id' => 'i1'],
46            'relatives' => ['id' => 'child-families'],
47            'maxgen'    => ['id' => '4'],
48            'sortby'    => ['id' => 'BIRT:DATE'],
49            'sources'   => ['id' => 'on'],
50            'notes'     => ['id' => 'on'],
51            'photos'    => ['id' => 'on'],
52            'pageSize'  => ['id' => 'A4'],
53            'colors'    => ['id' => 'on'],
54        ];
55
56        ob_start();
57        new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree);
58        $html = ob_get_clean();
59        $this->assertStringStartsWith('<', $html);
60        $this->assertStringEndsWith('>', $html);
61
62        ob_start();
63        new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree);
64        $pdf = ob_get_clean();
65        $this->assertStringStartsWith('%PDF', $pdf);
66        $this->assertStringEndsWith("%%EOF\n", $pdf);
67    }
68}
69