Skip to content

Commit

Permalink
Add testing for php warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Aug 29, 2024
1 parent 95be7c8 commit 8e487dc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
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 <[email protected]>
* @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");

0 comments on commit 8e487dc

Please sign in to comment.