Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions tests/ComposerJsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public function set_up() {

// Save and set logger.
$class_wp_cli_logger = new \ReflectionProperty( 'WP_CLI', 'logger' );
$class_wp_cli_logger->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$class_wp_cli_logger->setAccessible( true );
}
$this->prev_logger = $class_wp_cli_logger->getValue();

$this->logger = new Execution();
Expand All @@ -30,7 +32,9 @@ public function set_up() {
// Enable exit exception.

$class_wp_cli_capture_exit = new \ReflectionProperty( 'WP_CLI', 'capture_exit' );
$class_wp_cli_capture_exit->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$class_wp_cli_capture_exit->setAccessible( true );
}
$class_wp_cli_capture_exit->setValue( null, true );

$this->temp_dir = Utils\get_temp_dir() . uniqid( 'wp-cli-test-package-composer-json-', true ) . '/';
Expand All @@ -43,7 +47,9 @@ public function tear_down() {

// Restore exit exception.
$class_wp_cli_capture_exit = new \ReflectionProperty( 'WP_CLI', 'capture_exit' );
$class_wp_cli_capture_exit->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$class_wp_cli_capture_exit->setAccessible( true );
}
$class_wp_cli_capture_exit->setValue( null, $this->prev_capture_exit );

rmdir( $this->temp_dir );
Expand All @@ -53,7 +59,9 @@ public function tear_down() {

public function test_create_default_composer_json() {
$create_default_composer_json = new \ReflectionMethod( 'Package_Command', 'create_default_composer_json' );
$create_default_composer_json->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$create_default_composer_json->setAccessible( true );
}

$package = new Package_Command();

Expand Down Expand Up @@ -84,7 +92,9 @@ public function test_get_composer_json_path() {
$env_wp_cli_packages_dir = getenv( 'WP_CLI_PACKAGES_DIR' );

$get_composer_json_path = new \ReflectionMethod( 'Package_Command', 'get_composer_json_path' );
$get_composer_json_path->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$get_composer_json_path->setAccessible( true );
}

$package = new Package_Command();

Expand Down Expand Up @@ -134,7 +144,9 @@ public function test_get_composer_json_path_backup_decoded() {
putenv( 'WP_CLI_PACKAGES_DIR=' . $this->temp_dir . 'packages' );

$get_composer_json_path_backup_decoded = new \ReflectionMethod( 'Package_Command', 'get_composer_json_path_backup_decoded' );
$get_composer_json_path_backup_decoded->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$get_composer_json_path_backup_decoded->setAccessible( true );
}

$package = new Package_Command();

Expand Down