/** * @test * * Creates a post and edits it (compatibly) in both environments. This leads to two different date modified's * but they should still merge fine if our merge driver works correctly. */ public function dateModifiedMergesAutomatically() { $cloneSiteConfig = self::$cloneSiteConfig; $internalCommandPath = __DIR__ . '/../../src/Cli/vp-internal.php'; $wpAutomation = new WpAutomation(self::$siteConfig, self::$testConfig->wpCliVersion); $cloneWpAutomation = new WpAutomation(self::$cloneSiteConfig, self::$testConfig->wpCliVersion); $this->prepareSite($wpAutomation); $post = ["post_type" => "page", "post_status" => "publish", "post_title" => "Test page for menu", "post_date" => "2011-11-11 11:11:11", "post_content" => "Test page", "post_author" => 1]; $postId = $wpAutomation->createPost($post); $postVpId = $wpAutomation->runWpCliCommand('vp-internal', 'get-entity-vpid', ['require' => $internalCommandPath, 'id' => $postId, 'name' => 'posts']); $wpAutomation->runWpCliCommand('vp', 'clone', ['name' => self::$cloneSiteConfig->name, 'yes' => null]); $wpAutomation->editPost($postId, ['post_title' => 'Some new title']); // We need to sleep for at least a second to get different date modified's; // WP-CLI / WordPress don't allow setting `post_modified` so we need to use this. sleep(1); $clonedPostId = $cloneWpAutomation->runWpCliCommand('vp-internal', 'get-entity-id', ['require' => $internalCommandPath, 'vpid' => $postVpId]); $cloneWpAutomation->editPost($clonedPostId, ['post_content' => 'Some new content']); $wpAutomation->runWpCliCommand('vp', 'pull', ['from' => self::$cloneSiteConfig->name]); $modifiedDate = $wpAutomation->runWpCliCommand('post get', $postId, ['field' => 'post_modified']); $clonedModifiedDate = $cloneWpAutomation->runWpCliCommand('post get', $clonedPostId, ['field' => 'post_modified']); $modifiedDateGmt = $wpAutomation->runWpCliCommand('post get', $postId, ['field' => 'post_modified_gmt']); $clonedModifiedDateGmt = $cloneWpAutomation->runWpCliCommand('post get', $clonedPostId, ['field' => 'post_modified_gmt']); $this->assertEquals($clonedModifiedDate, $modifiedDate); $this->assertEquals($clonedModifiedDateGmt, $modifiedDateGmt); }