znt/module/user/test/model/islogon.php

49 lines
1.8 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 userModel::isLogon();
timeout=0
cid=19646
- 步骤1正常登录用户admin的状态检查 @1
- 步骤2正常登录用户user1的状态检查 @1
- 步骤3guest用户的登录状态检查 @0
- 步骤4session中用户为false时的状态检查 @0
- 步骤5用户对象存在但account为空的状态检查 @0
- 步骤6用户对象存在但account为null的状态检查 @0
- 步骤7session中完全没有user时的状态检查 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
zenData('user')->gen(2);
$userTest = new userModelTest();
$_SESSION['user'] = $userTest->getbyIdTest('admin');
r($userTest->isLogonTest()) && p() && e(1); // 步骤1正常登录用户admin的状态检查
$_SESSION['user'] = $userTest->getbyIdTest('user1');
r($userTest->isLogonTest()) && p() && e(1); // 步骤2正常登录用户user1的状态检查
$_SESSION['user'] = (object)array('account' => 'guest');
r($userTest->isLogonTest()) && p() && e(0); // 步骤3guest用户的登录状态检查
$_SESSION['user'] = $userTest->getbyIdTest('test999');
r($userTest->isLogonTest()) && p() && e(0); // session 中用户为 test999 时获取用户的登录状态。
$_SESSION['user'] = false;
r($userTest->isLogonTest()) && p() && e(0); // 步骤4session中用户为false时的状态检查
$_SESSION['user'] = (object)array('account' => '');
r($userTest->isLogonTest()) && p() && e(0); // 步骤5用户对象存在但account为空的状态检查
$_SESSION['user'] = (object)array('account' => null);
r($userTest->isLogonTest()) && p() && e(0); // 步骤6用户对象存在但account为null的状态检查
unset($_SESSION['user']);
r($userTest->isLogonTest()) && p() && e(0); // 步骤7session中完全没有user时的状态检查