wp-discourse/tests/phpunit/helpers/logging.php
Angus McLeod 22ee91dfb5
Two Five Seven (#541)
* Don't try to add url to <head> if it's not present

* Update js config and formatting for comment block and sidebar

* PHP Linting

* FIX: Don't auto-publish updates to existing posts.

See: https://meta.discourse.org/t/disable-posting-wordpress-articles-to-discourse-when-theyre-updated/204488

* Bump version and release notes.

* Fix remote-post.php linting

* Update tests.yml to install svn

* Re-generate comments js build
2025-04-15 16:53:23 -07:00

42 lines
786 B
PHP
Vendored

<?php
/**
* Class \Test\Logging
*
* @package WPDiscourse
*/
namespace WPDiscourse\Test;
use WPDiscourse\Logs\FileManager;
/**
* Logging methods for WPDiscourse unit tests
*/
trait Logging {
/**
* Get last line in latest log file.
*/
protected function get_last_log() {
$manager = new FileManager();
$log_files = glob( $manager->logs_dir . '/*.log' );
if ( empty( $log_files ) ) {
return '';
}
$log_file = $log_files[0];
return shell_exec( "tail -n 1 $log_file" );
}
/**
* Clear all logs.
*/
protected function clear_logs() {
$manager = new FileManager();
$log_files = glob( $manager->logs_dir . '/*.log' );
foreach ( $log_files as $file ) {
if ( is_file( $file ) ) {
unlink( $file );
}
}
}
}