xref: /webtrees/tests/app/WebtreesTest.php (revision 5e933c21f8006e675d1df8bcedc634ee61f4aec2)
187635d09SGreg Roach<?php
23976b470SGreg Roach
387635d09SGreg Roach/**
487635d09SGreg Roach * webtrees: online genealogy
5*5e933c21SGreg Roach * Copyright (C) 2020 webtrees development team
687635d09SGreg Roach * This program is free software: you can redistribute it and/or modify
787635d09SGreg Roach * it under the terms of the GNU General Public License as published by
887635d09SGreg Roach * the Free Software Foundation, either version 3 of the License, or
987635d09SGreg Roach * (at your option) any later version.
1087635d09SGreg Roach * This program is distributed in the hope that it will be useful,
1187635d09SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1287635d09SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1387635d09SGreg Roach * GNU General Public License for more details.
1487635d09SGreg Roach * You should have received a copy of the GNU General Public License
1587635d09SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1687635d09SGreg Roach */
17fcfa147eSGreg Roach
1887635d09SGreg Roachdeclare(strict_types=1);
1987635d09SGreg Roach
2087635d09SGreg Roachnamespace Fisharebest\Webtrees;
2187635d09SGreg Roach
22f397d0fdSGreg Roachuse ErrorException;
233976b470SGreg Roach
2487635d09SGreg Roachuse function error_reporting;
25cd7f9193SGreg Roachuse function set_error_handler;
2687635d09SGreg Roach
2787635d09SGreg Roach/**
2887635d09SGreg Roach * Test the Webtrees class
2987635d09SGreg Roach */
30e5a6b4d4SGreg Roachclass WebtreesTest extends TestCase
3187635d09SGreg Roach{
3287635d09SGreg Roach    /**
33f397d0fdSGreg Roach     * @covers \Fisharebest\Webtrees\Webtrees::bootstrap
3487635d09SGreg Roach     * @return void
3587635d09SGreg Roach     */
3687635d09SGreg Roach    public function testInit(): void
3787635d09SGreg Roach    {
3887635d09SGreg Roach        error_reporting(0);
39cd7f9193SGreg Roach        set_error_handler(null);
4087635d09SGreg Roach
41f397d0fdSGreg Roach        $webtrees = new Webtrees();
42f397d0fdSGreg Roach        $webtrees->bootstrap();
4387635d09SGreg Roach
4487635d09SGreg Roach        // webtrees sets the error reporting level.
45*5e933c21SGreg Roach        self::assertNotSame(0, error_reporting());
46*5e933c21SGreg Roach        self::assertSame(Webtrees::ERROR_REPORTING, error_reporting());
47cd7f9193SGreg Roach
48cd7f9193SGreg Roach        try {
49cd7f9193SGreg Roach            // Trigger an error
50f397d0fdSGreg Roach            fopen(__DIR__ . '/no-such-file', 'rb');
51cd7f9193SGreg Roach        } catch (ErrorException $ex) {
52*5e933c21SGreg Roach            self::assertSame(__FILE__, $ex->getFile());
53cd7f9193SGreg Roach        }
54cd7f9193SGreg Roach
55cd7f9193SGreg Roach        // Disable error reporting (we could use "@"), and don't raise an exception.
56cd7f9193SGreg Roach        error_reporting(0);
57f397d0fdSGreg Roach        fopen(__DIR__ . '/no-such-file', 'rb');
5887635d09SGreg Roach    }
5987635d09SGreg Roach}
60