lonnieezell / forum-example

An in-progress sample forum application built on CodeIgniter 4.
MIT License
43 stars 10 forks source link

Bug: Call to undefined function `sys_getloadavg()` #293

Closed datamweb closed 6 months ago

datamweb commented 8 months ago

I have a problem running the test and I see error.

There were 37 errors:

1) Tests\Controllers\ThreadControllerTest::testCanUserSeeTheCreateADiscussionPage
Error: Call to undefined function sys_getloadavg()

P:\MyGitHubWork\codeigniter4-forum-example\themes\default\_footer.php:26
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\View\View.php:228
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\View\View.php:231
P:\MyGitHubWork\codeigniter4-forum-example\app\Libraries\View.php:17
P:\MyGitHubWork\codeigniter4-forum-example\themes\default\master.php:37
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\View\View.php:228
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\View\View.php:231
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\View\View.php:244
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\View\View.php:244
P:\MyGitHubWork\codeigniter4-forum-example\app\Libraries\Theme.php:44
P:\MyGitHubWork\codeigniter4-forum-example\app\Controllers\BaseController.php:93
P:\MyGitHubWork\codeigniter4-forum-example\app\Controllers\Discussions\ThreadController.php:90
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\CodeIgniter.php:941
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\CodeIgniter.php:502
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\CodeIgniter.php:361
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\Test\FeatureTestTrait.php:179
P:\MyGitHubWork\codeigniter4-forum-example\vendor\codeigniter4\framework\system\Test\FeatureTestTrait.php:199
P:\MyGitHubWork\codeigniter4-forum-example\tests\Controllers\ThreadControllerTest.php:31

2) Controllers\Moderation\ReportsControllerTest::testActionDenyThread
Error: Call to undefined function sys_getloadavg()
// ...

It seems that sys_getloadavg() is not supported in the Windows platforms. see Notes in https://www.php.net/manual/en/function.sys-getloadavg.php https://github.com/lonnieezell/forum-example/blob/b01c62ef0c48d2fc4b6b21faa64a40343015e952/app/Views/admin/dashboard.php#L32

The tests are passed with the following changes:

<?php if(function_exists('sys_getloadavg')):?>
<td><?= number_format(sys_getloadavg()[1], 2) ?></td>
<?php endif;?>
lonnieezell commented 8 months ago

I didn't realize that, thank you. Care to submit a PR?