wordpress-develop/tests/phpunit/tests/filesystem/_unzipFilePclzip.php
Sergey Biryukov 0444cf5337 Coding Standards: Fix a few newly introduced WPCS issues.
Follow-up to [56683], [56689].

See #59161, #58831.

git-svn-id: https://develop.svn.wordpress.org/trunk@56692 602fd350-edb4-49c9-b593-d223f7449a82
2023-09-26 00:07:56 +00:00

76 lines
1.8 KiB
PHP

<?php
/**
* Tests _unzip_file_pclzip().
*
* @group file.php
*
* @covers ::_unzip_file_pclzip
*/
class Tests_Filesystem_UnzipFilePclzip extends WP_UnitTestCase {
/**
* The test data directory.
*
* @var string $test_data_dir
*/
private static $test_data_dir;
/**
* Sets up the filesystem and test data directory property
* before any tests run.
*/
public static function set_up_before_class() {
parent::set_up_before_class();
require_once ABSPATH . 'wp-admin/includes/file.php';
WP_Filesystem();
self::$test_data_dir = DIR_TESTDATA . '/filesystem/';
}
/**
* Tests that _unzip_file_pclzip() applies "pre_unzip_file" filters.
*
* @ticket 37719
*/
public function test_should_apply_pre_unzip_file_filters() {
$filter = new MockAction();
add_filter( 'pre_unzip_file', array( $filter, 'filter' ) );
// Prepare test environment.
$unzip_destination = self::$test_data_dir . 'archive/';
mkdir( $unzip_destination );
_unzip_file_pclzip( self::$test_data_dir . 'archive.zip', $unzip_destination );
// Cleanup test environment.
$this->rmdir( $unzip_destination );
$this->delete_folders( $unzip_destination );
$this->assertSame( 1, $filter->get_call_count() );
}
/**
* Tests that _unzip_file_pclzip() applies "unzip_file" filters.
*
* @ticket 37719
*/
public function test_should_apply_unzip_file_filters() {
$filter = new MockAction();
add_filter( 'unzip_file', array( $filter, 'filter' ) );
// Prepare test environment.
$unzip_destination = self::$test_data_dir . 'archive/';
mkdir( $unzip_destination );
_unzip_file_pclzip( self::$test_data_dir . 'archive.zip', $unzip_destination );
// Cleanup test environment.
$this->rmdir( $unzip_destination );
$this->delete_folders( $unzip_destination );
$this->assertSame( 1, $filter->get_call_count() );
}
}