More phpcs cleanup

This commit is contained in:
Corey McKrill 2023-10-25 15:54:22 -07:00
parent 531eaa029f
commit 35f2fda9a8
No known key found for this signature in database
GPG Key ID: 84BBFE669C4D97B8
3 changed files with 20 additions and 5 deletions

View File

@ -262,7 +262,7 @@ class ListTable extends WP_List_Table {
),
$this->page_controller->get_logs_tab_url()
);
$rotation = '';
$rotation = '';
if ( ! is_null( $item->get_rotation() ) ) {
$rotation = sprintf(
' &ndash; <span class="post-state">%d</span>',

View File

@ -66,7 +66,7 @@ class FileControllerTest extends WC_Unit_Test_Case {
private static function delete_all_log_files(): void {
$files = glob( trailingslashit( realpath( Constants::get_constant( 'WC_LOG_DIR' ) ) ) . '*.log' );
foreach ( $files as $file ) {
@unlink( $file );
unlink( $file );
}
}
@ -76,6 +76,7 @@ class FileControllerTest extends WC_Unit_Test_Case {
public function test_get_files_with_files(): void {
$this->handler->handle( time(), 'debug', '1', array() ); // No source defaults to "log" as source.
$this->handler->handle( time(), 'debug', '2', array( 'source' => 'unit-testing' ) );
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_wp_debug_backtrace_summary -- Unit test.
$this->handler->handle( time(), 'debug', wp_debug_backtrace_summary(), array( 'source' => 'unit-testing' ) ); // Increase file size.
$files = $this->sut->get_files();
@ -86,13 +87,23 @@ class FileControllerTest extends WC_Unit_Test_Case {
$second_file = array_shift( $files );
$this->assertInstanceOf( 'Automattic\\WooCommerce\\Internal\\Admin\\Logging\\FileV2\\File', $second_file );
$files = $this->sut->get_files( array( 'orderby' => 'source', 'order' => 'asc' ) );
$files = $this->sut->get_files(
array(
'orderby' => 'source',
'order' => 'asc',
)
);
$first_file = array_shift( $files );
$this->assertEquals( 'log', $first_file->get_source() );
$second_file = array_shift( $files );
$this->assertEquals( 'unit-testing', $second_file->get_source() );
$files = $this->sut->get_files( array( 'orderby' => 'size', 'order' => 'desc' ) );
$files = $this->sut->get_files(
array(
'orderby' => 'size',
'order' => 'desc',
)
);
$first_file = array_shift( $files );
$this->assertEquals( 'unit-testing', $first_file->get_source() );
}

View File

@ -7,6 +7,8 @@ use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Internal\Admin\Logging\FileV2\File;
use WC_Unit_Test_Case;
// phpcs:disable WordPress.WP.AlternativeFunctions.file_system_read_fopen, WordPress.WP.AlternativeFunctions.file_system_read_fclose
/**
* FileTest class.
*/
@ -20,7 +22,7 @@ class FileTest extends WC_Unit_Test_Case {
// Delete all created log files.
$files = glob( trailingslashit( realpath( Constants::get_constant( 'WC_LOG_DIR' ) ) ) . '*.log' );
foreach ( $files as $file ) {
@unlink( $file );
unlink( $file );
}
parent::tearDown();
@ -108,3 +110,5 @@ class FileTest extends WC_Unit_Test_Case {
$this->assertCount( 0, $files );
}
}
// phpcs:enable WordPress.WP.AlternativeFunctions.file_system_read_fopen, WordPress.WP.AlternativeFunctions.file_system_read_fclose