Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
21 changes: 16 additions & 5 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use WP_CLI\Process;
use WP_CLI\ProcessRun;
use WP_CLI\Utils;
use WP_CLI\Path;
use WP_CLI\WpOrgApi;

/**
Expand Down Expand Up @@ -1650,7 +1651,13 @@ public function install_wp( $subdir = '', $version = '' ): void {

// This is the sqlite equivalent of restoring a database dump in MySQL
if ( 'sqlite' === self::$db_type ) {
copy( "{$install_cache_path}.sqlite", "$run_dir/wp-content/database/.ht.sqlite" );
$sqlite_dest_dir = "$run_dir/wp-content/database";
if ( ! is_dir( $sqlite_dest_dir ) ) {
mkdir( $sqlite_dest_dir, 0755, true );
}
if ( file_exists( "{$install_cache_path}.sqlite" ) ) {
copy( "{$install_cache_path}.sqlite", "$sqlite_dest_dir/.ht.sqlite.php" );
Comment thread
swissspidy marked this conversation as resolved.
}
} else {
$ssl_flag = 'mariadb' === self::$db_type ? ' --ssl-verify-server-cert' : '';
self::run_sql( self::$mysql_binary . ' --no-defaults' . $ssl_flag, [ 'execute' => "source {$install_cache_path}.sql" ], true /*add_database*/ );
Expand Down Expand Up @@ -1679,7 +1686,11 @@ public function install_wp( $subdir = '', $version = '' ): void {

if ( 'sqlite' === self::$db_type ) {
// This is the sqlite equivalent of creating a database dump in MySQL
$sqlite_source = "$run_dir/wp-content/database/.ht.sqlite";
// Support both the new (.ht.sqlite.php) and legacy (.ht.sqlite) file names.
$sqlite_source = "$run_dir/wp-content/database/.ht.sqlite.php";
if ( ! file_exists( $sqlite_source ) ) {
$sqlite_source = "$run_dir/wp-content/database/.ht.sqlite";
}
if ( file_exists( $sqlite_source ) ) {
copy( $sqlite_source, "{$install_cache_path}.sqlite" );
} elseif ( file_exists( "{$install_cache_path}.sqlite" ) ) {
Expand Down Expand Up @@ -1901,8 +1912,8 @@ private static function get_scenario_key( $scope ): string {
$scenario_key = '';
$file = self::get_event_file( $scope, $line );
if ( isset( $file ) ) {
$scenario_grandparent = Utils\basename( dirname( $file, 2 ) );
$scenario_key = $scenario_grandparent . ' ' . Utils\basename( $file ) . ':' . $line;
$scenario_grandparent = Path::basename( dirname( $file, 2 ) );
$scenario_key = $scenario_grandparent . ' ' . Path::basename( $file ) . ':' . $line;
}
return $scenario_key;
}
Expand All @@ -1919,7 +1930,7 @@ private static function log_run_times_after_suite( AfterSuiteScope $scope ): voi
$suite = substr( $keys[0], 0, strpos( $keys[0], ' ' ) );
}

$run_from = Utils\basename( dirname( __DIR__, 2 ) );
$run_from = Path::basename( dirname( __DIR__, 2 ) );

// Format same as Behat, if have minutes.
$fmt = static function ( $time ) {
Expand Down
3 changes: 2 additions & 1 deletion src/Context/GivenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Behat\Gherkin\Node\TableNode;
use RuntimeException;
use WP_CLI\Utils;
use WP_CLI\Path;

trait GivenStepDefinitions {

Expand Down Expand Up @@ -45,7 +46,7 @@ public function given_an_empty_directory(): void {
*/
public function given_a_specific_directory( $empty_or_nonexistent, $dir ): void {
$dir = $this->replace_variables( $dir );
if ( ! Utils\is_path_absolute( $dir ) ) {
if ( ! Path::is_absolute( $dir ) ) {
$dir = $this->variables['RUN_DIR'] . "/$dir";
}

Expand Down
3 changes: 2 additions & 1 deletion src/Context/ThenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use WP_CLI\Utils;

Check failure on line 7 in src/Context/ThenStepDefinitions.php

View workflow job for this annotation

GitHub Actions / code-quality / PHPCS

Type WP_CLI\Utils is not used in this file.
use WP_CLI\Path;
use Exception;
use Requests;
use RuntimeException;
Expand Down Expand Up @@ -457,7 +458,7 @@
$path = $this->replace_variables( $path );

// If it's a relative path, make it relative to the current test dir.
if ( ! Utils\is_path_absolute( $path ) ) {
if ( ! Path::is_absolute( $path ) ) {
$path = $this->variables['RUN_DIR'] . DIRECTORY_SEPARATOR . $path;
}

Expand Down
Loading