当前位置: 首页>>代码示例>>PHP>>正文


PHP Env::pop方法代码示例

本文整理汇总了PHP中Env::pop方法的典型用法代码示例。如果您正苦于以下问题:PHP Env::pop方法的具体用法?PHP Env::pop怎么用?PHP Env::pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Env的用法示例。


在下文中一共展示了Env::pop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: catch

    Env::get('_test_foo');
    $this->assert(false, 'Exception accessing unknown Env value');
} catch (\Exception $e) {
    $this->assert(true, 'Exception accessing unknown Env value');
}
Env::set('_test_foo', 'bar');
$this->assertEqual(Env::get('_test_foo'), 'bar', 'Read Env value');
Env::set('_test_foo', 'a', 10);
$this->assertEqual(Env::get('_test_foo'), 'a', 'Apply higher priority value');
Env::set('_test_foo', 'b', -5);
$this->assertEqual(Env::get('_test_foo'), 'a', 'Ignore low priority value');
Env::push('_test_foo', 'c');
$this->assertEqual(Env::get('_test_foo'), 'c', 'Push env value');
Env::push('_test_foo', 'd');
$this->assertEqual(Env::get('_test_foo'), 'd', 'Push another env value');
Env::pop('_test_foo');
$this->assertEqual(Env::get('_test_foo'), 'c', 'Pop env value');
Env::pop('_test_foo');
$this->assertEqual(Env::get('_test_foo'), 'a', 'Pop another env value');
try {
    Env::pop('_test_foo');
    $this->assert(false, 'Exception popping too many times');
} catch (\Exception $e) {
    $this->assert(true, 'Exception popping too many times');
}
try {
    Env::pop('_test_bar', 'c');
    $this->assert(false, 'Exception popping unknown Env value');
} catch (\Exception $e) {
    $this->assert(true, 'Exception popping unknown Env value');
}
开发者ID:fierce,项目名称:fierce,代码行数:31,代码来源:fierce-test-env.php

示例2: function

$returnedId = Auth::userIdIfCredentialsValid($email, $password);
$this->assertEqual($returnedId, null, 'Verify incorrect email fails');
// correct username, incorrect password
$email = 'justine';
$password = 'san';
$id = Auth::userIdByEmail($email);
$db->User->prepareForCall('byId', [$id], (object) ['id' => $id, 'type' => 'test', 'email' => 'justine', 'password' => $passwordHash, 'signature' => '8e82e581a143b6f8d30206891ca2549214e05afc']);
$returnedId = Auth::userIdIfCredentialsValid($email, $password);
$this->assertEqual($returnedId, null, 'Verify incorrect password fails');
// correct password
$password = 'sane';
$returnedId = Auth::userIdIfCredentialsValid($email, $password);
$this->assertEqual($returnedId, $id, 'Verify correct credentials succeed');
// no cookie should mean no logged in user
$cookieManager->prepareForCall('get', ['u'], null);
$u = Auth::loggedInUser();
$this->assertEqual($u, null, "Check for no logged in user");
// logged in user with bad cookie should mean no logged in user
$cookieManager->prepareForCall('get', ['u'], 'blah');
$cookieManager->prepareForCall('clear', ['u']);
$db->LoginSession->prepareForCall('byId', ['blah'], function () {
    throw new \Exception("Invalid id");
});
$db->LoginSession->prepareForCall('purge', ['blah']);
$u = Auth::loggedInUser();
$this->assertEqual($u, null, "Check for no logged in user with invalid cookie");
Env::pop('cookie');
// more!
$this->fail('TODO: test more stuff');
Env::pop('db');
开发者ID:fierce,项目名称:fierce,代码行数:30,代码来源:fierce-test-auth.php


注:本文中的Env::pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。