本文整理汇总了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');
}
示例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');