コード例 #1
0
 /**
  * @test
  * it should restore global state after first bootstrapping
  */
 public function it_should_restore_global_state_after_first_bootstrapping()
 {
     vfsStream::setup('wproot3', null, ['wp' => ['wp-load.php' => 'some content']]);
     $this->config['wpRootFolder'] = vfsStream::url('wproot3/wp');
     $this->restorer->restoreGlobalVariables(Argument::any())->shouldBeCalled();
     $this->restorer->restoreStaticAttributes(Argument::any())->shouldBeCalled();
     $sut = $this->make_instance();
     $sut->_initialize();
     global $someVar;
     $someVar = 'foo';
     $sut->bootstrapWp();
     $someVar = null;
     $sut->bootstrapWp();
     $this->assertEquals('foo', $someVar);
 }
コード例 #2
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);
 }
コード例 #3
0
ファイル: TestCase.php プロジェクト: emsdog/lumen-todo
 private function restoreGlobalState()
 {
     if (!$this->snapshot instanceof Snapshot) {
         return;
     }
     $backupGlobals = $this->backupGlobals === null || $this->backupGlobals === true;
     if ($this->disallowChangesToGlobalState) {
         $this->compareGlobalStateSnapshots($this->snapshot, $this->createGlobalStateSnapshot($backupGlobals));
     }
     $restorer = new Restorer();
     if ($backupGlobals) {
         $restorer->restoreGlobalVariables($this->snapshot);
     }
     if ($this->backupStaticAttributes) {
         $restorer->restoreStaticAttributes($this->snapshot);
     }
     $this->snapshot = null;
 }
コード例 #4
0
ファイル: TestCase.php プロジェクト: alvarobfdev/applog
 private function restoreGlobalState()
 {
     if (!$this->snapshot instanceof Snapshot) {
         return;
     }
     $backupGlobals = $this->backupGlobals === null || $this->backupGlobals === true;
     if ($this->disallowChangesToGlobalState) {
         try {
             $this->compareGlobalStateSnapshots($this->snapshot, $this->createGlobalStateSnapshot($backupGlobals));
         } catch (PHPUnit_Framework_RiskyTestError $rte) {
             // Intentionally left empty
         }
     }
     $restorer = new Restorer();
     if ($backupGlobals) {
         $restorer->restoreGlobalVariables($this->snapshot);
     }
     if ($this->backupStaticAttributes) {
         $restorer->restoreStaticAttributes($this->snapshot);
     }
     $this->snapshot = null;
     if (isset($rte)) {
         throw $rte;
     }
 }
コード例 #5
0
ファイル: TestCase.php プロジェクト: no-chris/connector
 private function restoreGlobalState()
 {
     if (!$this->snapshot instanceof Snapshot) {
         return;
     }
     $restorer = new Restorer();
     if ($this->backupGlobals === null || $this->backupGlobals === true) {
         $restorer->restoreGlobalVariables($this->snapshot);
     }
     if ($this->backupStaticAttributes) {
         $restorer->restoreStaticAttributes($this->snapshot);
     }
     $this->snapshot = null;
 }