public function testOverrideOrder() { $outer = PhabricatorEnv::beginScopedEnv(); $middle = PhabricatorEnv::beginScopedEnv(); $inner = PhabricatorEnv::beginScopedEnv(); $caught = null; try { if (phutil_is_hiphop_runtime()) { $middle->__destruct(); } unset($middle); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception, "Destroying a scoped environment which is not on the top of the stack " . "should throw."); $caught = null; try { if (phutil_is_hiphop_runtime()) { $inner->__destruct(); } unset($inner); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception, "Destroying a scoped environment which is not on the top of the stack " . "should throw."); // Although we popped the other two out-of-order, we still expect to end // up in the right state after handling the exceptions, so this should // execute without issues. if (phutil_is_hiphop_runtime()) { $outer->__destruct(); } unset($outer); }
public function testLogWriteFailure() { $caught = null; try { if (phutil_is_hiphop_runtime()) { // In HipHop exceptions thrown in destructors are not normally // catchable, so call __destruct() explicitly. $log = new PhutilDeferredLog('/derp/derp/derp/derp/derp', 'derp'); $log->__destruct(); } else { new PhutilDeferredLog('/derp/derp/derp/derp/derp', 'derp'); } } catch (Exception $ex) { $caught = $ex; } $this->assertTrue($caught instanceof Exception); }
protected function didRunTests() { $config = $this->getComputedConfiguration(); if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) { LiskDAO::endIsolateAllLiskEffectsToCurrentProcess(); } try { if (phutil_is_hiphop_runtime()) { $this->env->__destruct(); } unset($this->env); } catch (Exception $ex) { throw new Exception('Some test called PhabricatorEnv::beginScopedEnv(), but is still ' . 'holding a reference to the scoped environment!'); } }
public function testOverrideOrder() { $outer = PhabricatorEnv::beginScopedEnv(); $inner = PhabricatorEnv::beginScopedEnv(); $caught = null; try { $outer->__destruct(); } catch (Exception $ex) { $caught = $ex; } $this->assertTrue($caught instanceof Exception, 'Destroying a scoped environment which is not on the top of the stack ' . 'should throw.'); if (phutil_is_hiphop_runtime()) { $inner->__destruct(); } unset($inner); if (phutil_is_hiphop_runtime()) { $outer->__destruct(); } unset($outer); }