1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-27 07:50:57 +01:00

Explicitly call __destruct() in PhabricatorEnvTestCase

Summary:
Required in order to run tests successfully in the HipHop interpreter.
Similar to D2362.

Test Plan: Run the tests in an HipHop runtime.

Reviewers: epriestley

Reviewed By: epriestley

CC: jungejason, aran, Koolvin, vrana

Differential Revision: https://secure.phabricator.com/D2365
This commit is contained in:
Edward Speyer 2012-05-01 13:11:45 -07:00
parent 4626c40fe3
commit bb96115fa6
2 changed files with 20 additions and 1 deletions

View file

@ -26,6 +26,7 @@
final class PhabricatorScopedEnv {
private $key;
private $isPopped = false;
/* -( Overriding Environment Configuration )------------------------------- */
@ -66,7 +67,10 @@ final class PhabricatorScopedEnv {
* @task internal
*/
public function __destruct() {
PhabricatorEnv::popEnvironment($this->key);
if (!$this->isPopped) {
PhabricatorEnv::popEnvironment($this->key);
$this->isPopped = true;
}
}
}

View file

@ -62,9 +62,15 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
$inner = PhabricatorEnv::beginScopedEnv();
$inner->overrideEnvConfig('test.value', 2);
$this->assertEqual(2, PhabricatorEnv::getEnvConfig('test.value'));
if (phutil_is_hiphop_runtime()) {
$inner->__destruct();
}
unset($inner);
$this->assertEqual(1, PhabricatorEnv::getEnvConfig('test.value'));
if (phutil_is_hiphop_runtime()) {
$outer->__destruct();
}
unset($outer);
}
@ -75,6 +81,9 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
$caught = null;
try {
if (phutil_is_hiphop_runtime()) {
$middle->__destruct();
}
unset($middle);
} catch (Exception $ex) {
$caught = $ex;
@ -88,6 +97,9 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
$caught = null;
try {
if (phutil_is_hiphop_runtime()) {
$inner->__destruct();
}
unset($inner);
} catch (Exception $ex) {
$caught = $ex;
@ -102,6 +114,9 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
// 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);
}