xref: /webtrees/tests/app/Module/BirthDeathMarriageReportModuleTest.php (revision f397d0fdeebb0d5a9590d5ba2d4d2aae8df09df1)
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;
24use Fisharebest\Webtrees\Webtrees;
25
26/**
27 * Test harness for the class BirthDeathMarriageReportModule
28 *
29 * @covers \Fisharebest\Webtrees\Module\BirthDeathMarriageReportModule
30 * @covers \Fisharebest\Webtrees\Module\ModuleReportTrait
31 * @covers \Fisharebest\Webtrees\Report\AbstractReport
32 * @covers \Fisharebest\Webtrees\Report\ReportBaseCell
33 * @covers \Fisharebest\Webtrees\Report\ReportBaseElement
34 * @covers \Fisharebest\Webtrees\Report\ReportBaseFootnote
35 * @covers \Fisharebest\Webtrees\Report\ReportBaseHtml
36 * @covers \Fisharebest\Webtrees\Report\ReportBaseImage
37 * @covers \Fisharebest\Webtrees\Report\ReportBaseLine
38 * @covers \Fisharebest\Webtrees\Report\ReportBasePageheader
39 * @covers \Fisharebest\Webtrees\Report\ReportBaseText
40 * @covers \Fisharebest\Webtrees\Report\ReportBaseTextbox
41 * @covers \Fisharebest\Webtrees\Report\ReportExpressionLanguageProvider
42 * @covers \Fisharebest\Webtrees\Report\ReportHtml
43 * @covers \Fisharebest\Webtrees\Report\ReportHtmlCell
44 * @covers \Fisharebest\Webtrees\Report\ReportHtmlFootnote
45 * @covers \Fisharebest\Webtrees\Report\ReportHtmlHtml
46 * @covers \Fisharebest\Webtrees\Report\ReportHtmlImage
47 * @covers \Fisharebest\Webtrees\Report\ReportHtmlLine
48 * @covers \Fisharebest\Webtrees\Report\ReportHtmlPageheader
49 * @covers \Fisharebest\Webtrees\Report\ReportHtmlText
50 * @covers \Fisharebest\Webtrees\Report\ReportHtmlTextbox
51 * @covers \Fisharebest\Webtrees\Report\ReportParserBase
52 * @covers \Fisharebest\Webtrees\Report\ReportParserGenerate
53 * @covers \Fisharebest\Webtrees\Report\ReportParserSetup
54 * @covers \Fisharebest\Webtrees\Report\ReportPdf
55 * @covers \Fisharebest\Webtrees\Report\ReportPdfCell
56 * @covers \Fisharebest\Webtrees\Report\ReportPdfFootnote
57 * @covers \Fisharebest\Webtrees\Report\ReportPdfHtml
58 * @covers \Fisharebest\Webtrees\Report\ReportPdfImage
59 * @covers \Fisharebest\Webtrees\Report\ReportPdfLine
60 * @covers \Fisharebest\Webtrees\Report\ReportPdfPageheader
61 * @covers \Fisharebest\Webtrees\Report\ReportPdfText
62 * @covers \Fisharebest\Webtrees\Report\ReportPdfTextbox
63 * @covers \Fisharebest\Webtrees\Report\ReportTcpdf
64 */
65class BirthDeathMarriageReportModuleTest extends \Fisharebest\Webtrees\TestCase
66{
67    protected static $uses_database = true;
68
69    /**
70     * @return void
71     */
72    public function testReportRunsWithoutError(): void
73    {
74        $tree = $this->importTree('demo.ged');
75        app()->instance(Tree::class, $tree);
76        $xml  = Webtrees::ROOT_DIR . 'resources/xml/reports/bdm_report.xml';
77        $vars = [
78            'name'       => ['id' => ''],
79            'bdmplace'   => ['id' => ''],
80            'birthdate1' => ['id' => ''],
81            'birthdate2' => ['id' => ''],
82            'deathdate1' => ['id' => ''],
83            'deathdate2' => ['id' => ''],
84            'sortby'     => ['id' => 'BIRT:DATE'],
85            'pageSize'   => ['id' => 'A4'],
86        ];
87
88        ob_start();
89        new ReportParserGenerate($xml, new ReportHtml(), $vars, $tree);
90        $html = ob_get_clean();
91        $this->assertStringStartsWith('<', $html);
92        $this->assertStringEndsWith('>', $html);
93
94        ob_start();
95        new ReportParserGenerate($xml, new ReportPdf(), $vars, $tree);
96        $pdf = ob_get_clean();
97        $this->assertStringStartsWith('%PDF', $pdf);
98        $this->assertStringEndsWith("%%EOF\n", $pdf);
99    }
100}
101