Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testing for php warnings #190

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

<h3>PHP level errors and setup</h3>
<p>These are errors are awkward to theme because they can appear in the middle of a themed page</p>
<li>A 200 page which emits a notice and a warning
<a href='errors/phpwarnings.php'>phpwarnings.php</a></li>
<li>A 200 unthemed moodle script which 'Fatal errors' times out after 1 second
<a href='errors/moodletimeout.php'>moodletimeout.php</a></li>
<li>A 200 unthemed moodle script which 'Fatal errors' times out after exceding memory
Expand Down
41 changes: 41 additions & 0 deletions errors/phpwarnings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Tests all the different types of error classes
*
* @package tool_heartbeat
* @copyright 2024 Brendan Heywood <brendan@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define('NO_OUTPUT_BUFFERING', true);

// @codingStandardsIgnoreStart
require(__DIR__ . '/../../../../config.php');
// @codingStandardsIgnoreEnd

// So we don't brick our session.
\core\session\manager::write_close();

echo "This is an ok page which emits notices and warnings, and error logs";

trigger_error("This is a notice", E_USER_NOTICE);
trigger_error("This is a warning", E_USER_WARNING);

error_log("This is an error_log");
file_put_contents("php://stderr", "This writing to php://stderr");

Loading