Executes a WP-CLI command
http://wp-Cli.org/commands/
public runWpCliCommand ( string $command, string $subcommand, array $args = [], boolean $debug = false ) : string | ||
$command | string | Like "core" |
$subcommand | string | Like "config". Might be null, e.g. if the main command is "eval" there is no subcommand |
$args | array | Like array("dbname" => "wordpress", "dbuser" => "wpuser", "positionalargument") which will produce something like `--dbname='wordpress' --dbuser='wpuser' 'positionalargument'` |
$debug | boolean | |
return | string |
/** * @test */ public function runAutomation() { $testConfig = TestConfig::createDefaultConfig(); $wpAutomation = new WpAutomation($testConfig->testSite, $testConfig->wpCliVersion); $wpAutomation->setUpSite(); $wpAutomation->copyVersionPressFiles(); $wpAutomation->activateVersionPress(); $wpAutomation->runWpCliCommand('vp', 'config', ['VP_PROJECT_ROOT', '.']); }
/** * Defines global constants, container and wpdb dynamic mapping of value references. * It's not pretty, but makes the mapping functions very flexible (they can have various dependecies). */ private static function defineGlobalVariables() { global $versionPressContainer, $wpdb, $wp_taxonomies; defined('VERSIONPRESS_PLUGIN_DIR') || define('VERSIONPRESS_PLUGIN_DIR', self::$testConfig->testSite->path . '/wp-content/plugins/versionpress'); defined('VP_VPDB_DIR') || define('VP_VPDB_DIR', self::$testConfig->testSite->path . '/wp-content/vpdb'); $versionPressContainer = DIContainer::getConfiguredInstance(); $wpdb = self::$wpdb; $rawTaxonomies = self::$wpAutomation->runWpCliCommand('taxonomy', 'list', ['format' => 'json', 'fields' => 'name']); $taxonomies = array_column(json_decode($rawTaxonomies, true), 'name'); $wp_taxonomies = array_combine($taxonomies, $taxonomies); }
/** * @test * */ public function sitesAreNotMergedIfThereIsConflict() { $cloneWpAutomation = new WpAutomation(self::$cloneSiteConfig, self::$testConfig->wpCliVersion); $cloneWpAutomation->editOption('blogname', 'Blogname from clone - conflict'); $wpAutomation = new WpAutomation(self::$siteConfig, self::$testConfig->wpCliVersion); $wpAutomation->editOption('blogname', 'Blogname from original - conflict'); $output = $wpAutomation->runWpCliCommand('vp', 'pull', ['from' => self::$cloneSiteConfig->name]); $this->assertContains("Pull aborted", $output); }