protected function _before() { global $_flag; $_flag = false; $this->module_container = $this->prophesize(ModuleContainer::class); vfsStream::setup('wproot', null, ['wp' => ['wp-load.php' => '// load WordPress']]); $this->config = ['wpRootFolder' => vfsStream::url('wproot')]; $this->restorer = $this->prophesize(Restorer::class); $this->wp = $this->prophesize(WP::class); $this->wp->set_site_transient(Argument::type('string'), Argument::any(), Argument::any())->willReturn(true); }
public function bootstrapWp() { include_once $this->wpLoadPath; if ($this->config['backupGlobals']) { if ($this->globalStateSnapshot === false) { $this->setupSuperglobalArrays(); $this->unsetGlobalClosures(); $this->globalStateSnapshot = new Snapshot(); codecept_debug('WPBootstrapper: backed up global state.'); } else { $this->restorer->restoreGlobalVariables($this->globalStateSnapshot); $this->restorer->restoreStaticAttributes($this->globalStateSnapshot); $this->restoreAllGlobals(); $this->restoreWpdbConnection(); codecept_debug('WPBootstrapper: restored global state.'); } } codecept_debug('WPBootstrappper: WordPress bootstrapped from wp-load.php file'); // prevent WordPress from trying to update when bootstrapping foreach (['update_core', 'update_plugins', 'update_themes'] as $key) { $this->wp->set_site_transient($key, (object) ['last_checked' => time() + 86400]); } sleep(1); }