本文整理汇总了PHP中PhabricatorEnv::beginScopedEnv方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorEnv::beginScopedEnv方法的具体用法?PHP PhabricatorEnv::beginScopedEnv怎么用?PHP PhabricatorEnv::beginScopedEnv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorEnv
的用法示例。
在下文中一共展示了PhabricatorEnv::beginScopedEnv方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOverrideOrder
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);
}
示例2: testDropUnconfiguredPublicMail
public function testDropUnconfiguredPublicMail()
{
list($task, $user, $mail) = $this->buildMail('public');
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('metamta.public-replies', false);
$mail->save();
$mail->processReceivedMail();
$this->assertEqual(MetaMTAReceivedMailStatus::STATUS_NO_PUBLIC_MAIL, $mail->getStatus());
}
示例3: willRunTests
protected function willRunTests()
{
$root = dirname(phutil_get_library_root('phabricator'));
require_once $root . '/scripts/__init_script__.php';
$config = $this->getComputedConfiguration();
if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) {
LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess();
}
$this->env = PhabricatorEnv::beginScopedEnv();
}
示例4: assertEmail
private function assertEmail($expect, $herald_hints)
{
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('phabricator.production-uri', 'http://test.com/');
$env->overrideEnvConfig('metamta.herald.show-hints', $herald_hints);
$body = new PhabricatorMetaMTAMailBody();
$body->addRawSection('salmon');
$body->addTextSection('HEADER', "bass\ntrout\n");
$body->addHeraldSection('/xscript/');
$this->assertEqual($expect, $body->render());
}
示例5: testDropDisabledSenderMail
public function testDropDisabledSenderMail()
{
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('metamta.maniphest.public-create-email', 'bugs@example.com');
$user = $this->generateNewTestUser()->setIsDisabled(true)->save();
$mail = new PhabricatorMetaMTAReceivedMail();
$mail->setHeaders(array('Message-ID' => 'test@example.com', 'From' => $user->loadPrimaryEmail()->getAddress(), 'To' => 'bugs@example.com'));
$mail->save();
$mail->processReceivedMail();
$this->assertEqual(MetaMTAReceivedMailStatus::STATUS_DISABLED_SENDER, $mail->getStatus());
}
示例6: testRegistrationEmailDomain
public function testRegistrationEmailDomain()
{
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('auth.email-domains', array('example.com'));
$caught = null;
try {
$this->registerUser('PhabricatorUserEditorTestCaseDomain', 'PhabricatorUserEditorTest@whitehouse.gov');
} catch (Exception $ex) {
$caught = $ex;
}
$this->assertTrue($caught instanceof Exception);
}
示例7: testDropUnknownSenderMail
public function testDropUnknownSenderMail()
{
$this->setManiphestCreateEmail();
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('phabricator.allow-email-users', false);
$env->overrideEnvConfig('metamta.maniphest.default-public-author', null);
$mail = new PhabricatorMetaMTAReceivedMail();
$mail->setHeaders(array('Message-ID' => 'test@example.com', 'To' => 'bugs@example.com', 'From' => 'does+not+exist@example.com'));
$mail->save();
$mail->processReceivedMail();
$this->assertEqual(MetaMTAReceivedMailStatus::STATUS_UNKNOWN_SENDER, $mail->getStatus());
}
示例8: testMultiplePaymentProviders
public function testMultiplePaymentProviders()
{
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('phortune.test.enabled', true);
$method = id(new PhortunePaymentMethod())->setMetadataValue('type', 'test.multiple');
$caught = null;
try {
$provider = $method->buildPaymentProvider();
} catch (Exception $ex) {
$caught = $ex;
}
$this->assertTrue($caught instanceof PhortuneMultiplePaymentProvidersException, 'Expect exception when more than one provider handles a payment method.');
}
示例9: testAddressSimilarity
public function testAddressSimilarity()
{
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('metamta.single-reply-handler-prefix', 'prefix');
$base = 'alincoln@example.com';
$same = array('alincoln@example.com', '"Abrahamn Lincoln" <alincoln@example.com>', 'ALincoln@example.com', 'prefix+alincoln@example.com');
foreach ($same as $address) {
$this->assertTrue(PhabricatorMailReceiver::matchAddresses($base, $address), pht('Address %s', $address));
}
$diff = array('a.lincoln@example.com', 'aluncoln@example.com', 'prefixalincoln@example.com', 'badprefix+alincoln@example.com', 'bad+prefix+alincoln@example.com', 'prefix+alincoln+sufffix@example.com');
foreach ($diff as $address) {
$this->assertFalse(PhabricatorMailReceiver::matchAddresses($base, $address), pht('Address: %s', $address));
}
}
示例10: testControllerAccessControls
public function testControllerAccessControls()
{
$root = dirname(phutil_get_library_root('phabricator'));
require_once $root . '/support/PhabricatorStartup.php';
$application_configuration = new AphrontDefaultApplicationConfiguration();
$host = 'meow.example.com';
$_SERVER['REQUEST_METHOD'] = 'GET';
$request = id(new AphrontRequest($host, '/'))->setApplicationConfiguration($application_configuration)->setRequestData(array());
$controller = new PhabricatorTestController();
$controller->setRequest($request);
$u_public = id(new PhabricatorUser())->setUsername('public');
$u_unverified = $this->generateNewTestUser()->setUsername('unverified')->save();
$u_unverified->setIsEmailVerified(0)->save();
$u_normal = $this->generateNewTestUser()->setUsername('normal')->save();
$u_disabled = $this->generateNewTestUser()->setIsDisabled(true)->setUsername('disabled')->save();
$u_admin = $this->generateNewTestUser()->setIsAdmin(true)->setUsername('admin')->save();
$u_notapproved = $this->generateNewTestUser()->setIsApproved(0)->setUsername('notapproved')->save();
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('phabricator.base-uri', 'http://' . $host);
$env->overrideEnvConfig('policy.allow-public', false);
$env->overrideEnvConfig('auth.require-email-verification', false);
$env->overrideEnvConfig('auth.email-domains', array());
$env->overrideEnvConfig('security.require-multi-factor-auth', false);
// Test standard defaults.
$this->checkAccess(pht('Default'), id(clone $controller), $request, array($u_normal, $u_admin, $u_unverified), array($u_public, $u_disabled, $u_notapproved));
// Test email verification.
$env->overrideEnvConfig('auth.require-email-verification', true);
$this->checkAccess(pht('Email Verification Required'), id(clone $controller), $request, array($u_normal, $u_admin), array($u_unverified, $u_public, $u_disabled, $u_notapproved));
$this->checkAccess(pht('Email Verification Required, With Exception'), id(clone $controller)->setConfig('email', false), $request, array($u_normal, $u_admin, $u_unverified), array($u_public, $u_disabled, $u_notapproved));
$env->overrideEnvConfig('auth.require-email-verification', false);
// Test admin access.
$this->checkAccess(pht('Admin Required'), id(clone $controller)->setConfig('admin', true), $request, array($u_admin), array($u_normal, $u_unverified, $u_public, $u_disabled, $u_notapproved));
// Test disabled access.
$this->checkAccess(pht('Allow Disabled'), id(clone $controller)->setConfig('enabled', false), $request, array($u_normal, $u_unverified, $u_admin, $u_disabled, $u_notapproved), array($u_public));
// Test no login required.
$this->checkAccess(pht('No Login Required'), id(clone $controller)->setConfig('login', false), $request, array($u_normal, $u_unverified, $u_admin, $u_public), array($u_disabled, $u_notapproved));
// Test public access.
$this->checkAccess(pht('Public Access'), id(clone $controller)->setConfig('public', true), $request, array($u_normal, $u_unverified, $u_admin), array($u_disabled, $u_public));
$env->overrideEnvConfig('policy.allow-public', true);
$this->checkAccess(pht('Public + configured'), id(clone $controller)->setConfig('public', true), $request, array($u_normal, $u_unverified, $u_admin, $u_public), array($u_disabled, $u_notapproved));
$env->overrideEnvConfig('policy.allow-public', false);
$app = PhabricatorApplication::getByClass('PhabricatorTestApplication');
$app->reset();
$app->setPolicy(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicies::POLICY_NOONE);
$app_controller = id(clone $controller)->setCurrentApplication($app);
$this->checkAccess(pht('Application Controller'), $app_controller, $request, array(), array($u_normal, $u_unverified, $u_admin, $u_public, $u_disabled, $u_notapproved));
$this->checkAccess(pht('Application Controller'), id(clone $app_controller)->setConfig('login', false), $request, array($u_normal, $u_unverified, $u_admin, $u_public), array($u_disabled, $u_notapproved));
}
示例11: willRunTests
protected function willRunTests()
{
$root = dirname(phutil_get_library_root('phabricator'));
require_once $root . '/scripts/__init_script__.php';
$config = $this->getComputedConfiguration();
if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) {
LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess();
}
if ($config[self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES]) {
++self::$storageFixtureReferences;
if (!self::$storageFixture) {
self::$storageFixture = $this->newStorageFixture();
}
}
$this->env = PhabricatorEnv::beginScopedEnv();
}
示例12: testOverrideOrder
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);
}
示例13: willRunTests
protected function willRunTests()
{
$config = $this->getComputedConfiguration();
if ($config[self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK]) {
LiskDAO::beginIsolateAllLiskEffectsToCurrentProcess();
}
$this->env = PhabricatorEnv::beginScopedEnv();
// NOTE: While running unit tests, we act as though all applications are
// installed, regardless of the install's configuration. Tests which need
// to uninstall applications are responsible for adjusting state themselves
// (such tests are exceedingly rare).
$this->env->overrideEnvConfig('phabricator.uninstalled-applications', array());
$this->env->overrideEnvConfig('phabricator.show-beta-applications', true);
// Reset application settings to defaults, particularly policies.
$this->env->overrideEnvConfig('phabricator.application-settings', array());
// We can't stub this service right now, and it's not generally useful
// to publish notifications about test execution.
$this->env->overrideEnvConfig('notification.enabled', false);
// TODO: Remove this when we remove "releeph.installed".
$this->env->overrideEnvConfig('releeph.installed', true);
$this->env->overrideEnvConfig('phabricator.base-uri', 'http://phabricator.example.com');
}
示例14: testPublicPolicyDisabled
/**
* Verify that POLICY_PUBLIC is interpreted as POLICY_USER when public
* policies are disallowed.
*/
public function testPublicPolicyDisabled()
{
$env = PhabricatorEnv::beginScopedEnv();
$env->overrideEnvConfig('policy.allow-public', false);
$this->expectVisibility($this->buildObject(PhabricatorPolicies::POLICY_PUBLIC), array('public' => false, 'user' => true, 'admin' => true), 'Public Policy (Disabled in Config)');
}