. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use ErrorException; use function date_default_timezone_get; use function date_default_timezone_set; use function error_reporting; use function set_error_handler; /** * Test the Webtrees class */ class WebtreesTest extends TestCase { /** * @covers \Fisharebest\Webtrees\Webtrees::bootstrap * @return void */ public function testInit(): void { error_reporting(0); set_error_handler(null); $webtrees = new Webtrees(); $webtrees->bootstrap(); // webtrees sets the error reporting level. $this->assertNotSame(0, error_reporting()); $this->assertSame(Webtrees::ERROR_REPORTING, error_reporting()); try { // Trigger an error fopen(__DIR__ . '/no-such-file', 'rb'); } catch (ErrorException $ex) { $this->assertSame(__FILE__, $ex->getFile()); } // Disable error reporting (we could use "@"), and don't raise an exception. error_reporting(0); fopen(__DIR__ . '/no-such-file', 'rb'); } }