易截截图软件、单文件、免安装、纯绿色、仅160KB

php的simpletest框架对uchome项目进行接口测试脚本

<?php
require_once ('unit_tester.php');
require_once ('reporter.php');
require_once ('../config.php');
require_once ('../source\modules\user\user_api.func.php');
require_once ('../source/base_model.class.php');
Class registertest extends UnitTestCase{
public function testAssertEqual(){
$base = new base_model();
$_ENV['base'] = $base;
$base->db->query("delete from uc_members where uid is not null");
$base->db->query("alter table uc_members AUTO_INCREMENT=1");
//testcase1
$this->assertEqual(1,$num=api_user_register("123","12","1234@12.cn"),"register success so ,expect result 1,reality:".$num.",line 15");
//testcase1
//testcase2
$this->assertEqual(-1,$num=api_user_register("12","321","1234@12.cn"),"register failed because of length of username fewer than 3 ,expect result -1,reality:".$num.",line 18");
//testcase2
//testcase3
$base->db->query("delete from uc_badwords");
$base->db->query("insert into uc_badwords(find,findpattern) values('草','/草/is')");
$this->assertEqual(-2,$num=api_user_register("3草f","232s","sdasx@fs.com"),"api_user_register(3草f,232s,sdasx@fs.com) ,register failed because of content bad words in it ,expect result -2,reality:".$num.",line 23");
//testcase3
//testcase4
$this->assertEqual(-1,$num=api_user_register("#@","dsx","sdxzc@fs.com"),"register failed because of unexpect symbols in username ,expect result -1,reality:".$num.",line 26");
//testcase4
//testcase5
$this->assertEqual(-1,$num=api_user_register("   Guest","098","sd78a@dscx.net"),"register failed becase of username content unexpected words as Guest ,expect result -1,reality:".$num.",line 28");
//testcase5
//testcase6
$this->assertEqual(-1,$num=api_user_register("sdads78778z23ws1","9890s","sd xa@83.com"),"register failed because of length of username more than 15 ,expect result -1,reality:".$num.",line 31");
//testcase6
//testcase7
$num=$base->db->result_first("select max(uid) from uc_members");


相关文档:

PHP 中获取文件名及路径


  为了脚本程序的兼容性,很多时候脚本的名称都不是固定的。所以我们需要通过动态获取当前脚本的路径、文件名来完成某些功能。
  PHP 中,我们可以使用常量 __FILE__ 来获取当前被执行脚本的完整路径。
  注意:当包含此变量的脚本被其他脚本include或者require的时候, __FILE__ 将仍然返回此脚本的地址,而不是 ......

PHP用户登录注册模块实现


PHP用户登录模块实现
项目包含的功能脚本:
login.php//登录
reg.php//注册用户
user_add.php//注册校验脚本
user_login_check.php//登录校验脚本
image.php//验证码图片生成脚本
流程:
设计数据库:
包含用户uid,用户名,密码,昵称,性别,邮箱,注册时间
sql语句如下
create table users (uid bigint(20) ......

[PHP]PDO的使用

1. 安装php5.1以上的版本,有支持pdo!为了使你的环境能提供对pdo的支持!在php.ini文件加入以下:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mssql.dll(支持mssql数据库)
2. 以下为PH中PDO的具体使用
 <?php
$dsn = 'mysql:dbname=MyDbName;host=localhost';
$user = 'root';
......

[PHP]PDO调用存储过程

1. 数据库中已创建存储过程user_logon_check, PHP调用示例如下,
<?php
$dsn = 'mssql:dbname=MyDbName;host=localhost';
$user = 'sa';
$password = '666666';
try {
$dbCon = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
print 'Connection failed: '.$e->getMessage();
......

[PHP]Pear的使用

1. PEAR的安装, 这里介绍利用PHP5自带的BAT文件安装,需要能上网。
   a. 在PHP5目录下找到go-pear.bat,双击安装(保证能上网, 以便下载),BAT自动从网上下载PEAR所需的东西;
   b. 按照提示输入一些设置信息,主要是要把局域网的网关加上,如http://192.168.0.1:80/ , pear要用这个地址访问Interne ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号