diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7e2defd..51088a4eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Replace `ifsnop/mysqldump-php` with `druidfi/mysqldump-php` for better performance (thanks @staabm). +- Disable MU update routine in CLI router to speed up test execution. ## [4.1.0] 2024-02-20; diff --git a/config/phpstan.neon.dist b/config/phpstan.neon.dist index 8dc314d2c..2a3a72e3a 100644 --- a/config/phpstan.neon.dist +++ b/config/phpstan.neon.dist @@ -9,3 +9,5 @@ parameters: excludePaths: - ./../src/WordPress/Version.php # Using the WordPress version file. - ./../src/TestCase/WPTestCasePHPUnitMethodsTrait.php # Compat file has missing return types. + bootstrapFiles: + - ./phpstan/class-aliases.php diff --git a/config/phpstan/class-aliases.php b/config/phpstan/class-aliases.php new file mode 100644 index 000000000..4dc8ce76f --- /dev/null +++ b/config/phpstan/class-aliases.php @@ -0,0 +1,5 @@ + 0, + 'function' => '__return_false' +]; + if ( file_exists( $root.$path ) ) { // Enforces trailing slash, keeping links tidy in the admin diff --git a/src/WordPress/Database/MysqlDatabase.php b/src/WordPress/Database/MysqlDatabase.php index d43c32fa3..6298efa46 100644 --- a/src/WordPress/Database/MysqlDatabase.php +++ b/src/WordPress/Database/MysqlDatabase.php @@ -3,6 +3,7 @@ namespace lucatume\WPBrowser\WordPress\Database; use Druidfi\Mysqldump\Mysqldump; +use Ifsnop\Mysqldump\Mysqldump as LegacyMysqldump; use Exception; use lucatume\WPBrowser\Utils\Db as DbUtil; use lucatume\WPBrowser\Utils\Serializer; @@ -324,14 +325,42 @@ public function import(string $dumpFilePath): int return $modifiedByQuery; } + private function buildIfsnopMysqlDump(): LegacyMysqldump + { + return new class( $this->dsn, $this->dbUser, $this->dbPassword ) extends LegacyMysqldump { + public function start($filename = ''): void + { + // @phpstan-ignore-next-line property defined in ifsnop/mysqldump dependency. + $this->dumpSettings['add-drop-table'] = true; + $this->dumpSettings['add-drop-database'] = true; + + parent::start($filename); + } + }; + } + + /** + * @throws Exception + */ + private function buildDruidfiMysqldump(): Mysqldump + { + $dumpSettings = [ 'add-drop-table' => true, 'add-drop-database' => true ]; + + return new Mysqldump($this->dsn, $this->dbUser, $this->dbPassword, $dumpSettings); + } + /** * @throws DbException */ public function dump(string $dumpFile): void { try { - $dumpSettings = ['add-drop-table'=> true, 'add-drop-database' => true]; - $dump = new Mysqldump($this->dsn, $this->dbUser, $this->dbPassword, $dumpSettings); + if (class_exists(LegacyMysqldump::class)) { + $dump = $this->buildIfsnopMysqlDump(); + } else { + $dump = $this->buildDruidfiMysqldump(); + } + /** @var Mysqldump $dump */ $dump->start($dumpFile); } catch (\Exception $e) { throw new DbException("Failed to dump database: " . $e->getMessage(), DbException::FAILED_DUMP); diff --git a/tests/webdriver.suite.dist.yml b/tests/webdriver.suite.dist.yml index c7107fb76..951bcda22 100644 --- a/tests/webdriver.suite.dist.yml +++ b/tests/webdriver.suite.dist.yml @@ -17,7 +17,7 @@ modules: path: '/' window_size: false wait: 5 - pageload_timeout: 5 + pageload_timeout: 30 capabilities: "goog:chromeOptions": args: