Esempio n. 1
0
 /**
  * @test
  * it should not switch to theme if not set
  */
 public function it_should_not_switch_to_theme_if_not_set()
 {
     unset($this->config['theme']);
     $this->wp->switch_theme(Argument::type('string'))->shouldNotBeCalled();
     $sut = $this->make_instance();
     $sut->_switch_theme();
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 public function _switch_theme()
 {
     if (!empty($this->config['theme'])) {
         $stylesheet = is_array($this->config['theme']) ? end($this->config['theme']) : $this->config['theme'];
         $functionsFile = $this->wp->WP_CONTENT_DIR() . '/themes/' . $stylesheet . '/functions.php';
         if (file_exists($functionsFile)) {
             require_once $functionsFile;
         }
         call_user_func([$this->wp, 'switch_theme'], $stylesheet);
         $this->wp->do_action('after_switch_theme', $stylesheet);
     }
 }