2011-04-30 19:11:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Facebook, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
abstract class PhabricatorTestCase extends ArcanistPhutilTestCase {
|
|
|
|
|
2011-04-30 19:11:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, put Lisk in process-isolated mode for the duration of the tests so
|
|
|
|
* that it will establish only isolated, side-effect-free database
|
|
|
|
* connections. Defaults to true.
|
|
|
|
*
|
|
|
|
* NOTE: You should disable this only in rare circumstances. Unit tests should
|
|
|
|
* not rely on external resources like databases, and should not produce
|
|
|
|
* side effects.
|
|
|
|
*/
|
|
|
|
const PHABRICATOR_TESTCONFIG_ISOLATE_LISK = 'isolate-lisk';
|
|
|
|
|
|
|
|
private $configuration;
|
|
|
|
|
|
|
|
protected function getPhabricatorTestCaseConfiguration() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getComputedConfiguration() {
|
|
|
|
return $this->getPhabricatorTestCaseConfiguration() + array(
|
|
|
|
self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK => true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-04-30 19:11:41 +02:00
|
|
|
protected function willRunTests() {
|
|
|
|
$root = dirname(phutil_get_library_root('phabricator'));
|
2011-10-01 17:59:42 +02:00
|
|
|
require_once $root.'/scripts/__init_script__.php';
|
2011-04-30 19:11:59 +02:00
|
|
|
|
|
|
|
$config = $this->getComputedConfiguration();
|
|
|
|
|
|
|
|
if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) {
|
|
|
|
LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function didRunTests() {
|
|
|
|
$config = $this->getComputedConfiguration();
|
|
|
|
|
|
|
|
if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) {
|
|
|
|
LiskDAO::endIsolateAllLiskEffectsToCurrentProcess();
|
|
|
|
}
|
2011-04-30 19:11:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|