## 测试目录结构
测试文件主要在 tests 文件下面,主要有以下几个文件夹
- conf 测试环境配置文件。
- script 测试环境配置脚本。
- thinkphp 测试用例和相关文件,与项目文件夹结构一致。
- mock.php 测试入口文件。
## 主要测试流程
thinkphp5 的测试的主要流程是跟 thinkphp 的系统流程是相似的,大体的流程为:
1. 引用 mock.php 文件加载框架
2. 根据文件目录,添加测试文件
3. 执行单元测试,输出结果
## 测试举例
例如测试 thinkphp 里的 apc 缓存,将分为以下几个过程:
1. 创建 apcTest.php 文件
该文件应与 apc.php 目录路径 `thinkphp/library/think/cache/driver` 一致,命名空间与目录所在一致,并引用 `PHPUnit_Framework_TestCase`。
```php
<?php
namespace tests\thinkphp\library\think\cache\driver;
class apcTest extends \PHPUnit_Framework_TestCase
{
//设定基境
public function setUp()
{
}
}
```
2. 编写测试文件
- 引用 app、config 和 cache
```php
use think\app;
use think\cache;
use think\config;
```
- 在 setUp 函数中设定 require 条件
```php
if(!extension_loaded('apc')){
$this->markTestSkipped('apc扩展不可用!');
};
```
- 编写测试用例
*具体写法参照 [PHPUnit 官方文档](https://phpunit.de/manual/4.8/zh_cn/index.html)*
```php
public function testGet()
{
App::run();
$this->assertInstanceOf(
'\think\cache\driver\Apc',
Cache::connect(['type' => 'apc', 'expire' => 1])
);
$this->assertTrue(Cache::set('key', 'value'));
$this->assertEquals('value', Cache::get('key'));
$this->assertTrue(Cache::rm('key'));
$this->assertFalse(Cache::get('key'));
$this->assertTrue(Cache::clear('key'));
Config::reset();
}
```
3. 执行单元测试命令
在项目根目录执行
```bash
$ phpunit
```
若想看到所有结果,请添加-v参数
```bash
$ phpunit -v
```
4. 输出结果
## 相关文档
[各个部分单元测试说明](http://www.kancloud.cn/brother_simon/tp5_test/96971 "各部分单元测试说明")
## 大家一起来
单元测试的内容会跟框架同步,测试内容方方面面,是一个相对复杂的模块,同时也是一个值得重视的部分。希望大家能够多多提出意见,多多参与。如果你有任何问题或想法,可以随时提 issue,我们期待着收到听大家的质疑和讨论。
## 任务进度
单元测试任务进度,请大家认领模块
|模块|认领人|进度|
|---|---|---|
|Base|||
|App|Haotong Lin|√|
|Build|刘志淳||
|Config|Haotong Lin|√|
|Cache|||
|Controller|Haotong Lin|√|
|Cookie|Haotong Lin|√|
|Db|||
|Debug|大漠|√|
|Error|大漠||
|Exception|Haotong Lin|√|
|Hook|流年|√|
|Input|Haotong Lin|√|
|Lang|流年|√|
|Loader|流年||
|Log|||
|Model|||
|Response|大漠|√|
|Route|流年||
|Session|大漠|√|
|Template|oldrind||
|Url|流年||
|View|mahuan||
没有合适的资源?快使用搜索试试~ 我知道了~
基于think PHP5 .0 vue2.0 QueryList爬虫的淘宝客平台
共336个文件
php:217个
html:33个
log:17个
5星 · 超过95%的资源 需积分: 14 45 下载量 160 浏览量
2017-10-15
20:56:09
上传
评论 5
收藏 2.64MB RAR 举报
温馨提示
1.环境是php5.6和MySQL5.4 及nginx1.9 ,其他环境下请自己修改代码 2.安装,文件里有数据库文件,先导入自己的数据库,配置数据库文件, 3.pc版是基于mvc架构,wap版式API的前后端分离。
资源推荐
资源详情
资源评论
收起资源包目录
基于think PHP5 .0 vue2.0 QueryList爬虫的淘宝客平台 (336个子文件)
jquery.mobile-1.4.5.min.css 201KB
swiper-3.4.2.min.css 17KB
zhancoupon.css 6KB
coupon.css 4KB
hiddeninput.exe 9KB
1507693874-17_10_11.log.filepart 1.53MB
.gitignore 74B
.gitignore 43B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.gitignore 14B
.htaccess 13B
.htaccess 13B
base.html 8KB
index01.html 7KB
index01.html 7KB
meirong01.html 7KB
meish01i.html 7KB
shuma01.html 7KB
shenghuo01.html 7KB
muying01.html 7KB
fushi01.html 7KB
indexz.html 6KB
index.html 6KB
index.html 5KB
muban.html 3KB
index.html 1KB
extend2.html 327B
template.html 285B
include.html 65B
extend.html 59B
index.html 33B
sx.html 31B
layout2.html 25B
layout.html 25B
display.html 18B
include2.html 14B
index.html 2B
index.html 1B
index.html 1B
index.html 1B
index.html 1B
index.html 1B
index.html 1B
index.html 1B
index.html 1B
favicon.ico 1KB
apcu_bc.ini 53B
apcu.ini 36B
memcached.ini 23B
redis.ini 19B
timezone.ini 19B
config.ini 9B
pc4.jpg 251KB
pc1.jpg 178KB
pc3.jpg 159KB
pc2.jpg 157KB
ma.jpg 35KB
vue.js 258KB
swiper-3.4.2.min.js 94KB
zhuye.js 5KB
coupon.js 2KB
lunbo.js 286B
composer.json 869B
config.json 16B
LICENSE 1KB
1501625674-17_08_02.log 2.09MB
1502184152-17_08_08.log 2.09MB
1502891762-17_08_16.log 2.08MB
1502335574-17_08_10.log 2.08MB
1499622661-17_07_10.log 2.06MB
1504821072-17_09_08.log 2.06MB
1502176867-17_08_08.log 2.06MB
1499248276-17_07_05.log 2.05MB
1500991875-17_07_25.log 2.05MB
1502919671-17_08_17.log 2.04MB
1505036473-17_09_10.log 2.03MB
1502076373-17_08_07.log 2.01MB
1502205063-17_08_08.log 2MB
17_07_03.log 2KB
17_07_10.log 269B
17_07_23.log 269B
17_07_17.log 247B
CONTRIBUTING.md 4KB
README.md 3KB
README.md 216B
Query.php 90KB
Model.php 67KB
Route.php 60KB
Request.php 50KB
Template.php 46KB
Validate.php 40KB
Process.php 31KB
Builder.php 30KB
共 336 条
- 1
- 2
- 3
- 4
资源评论
- AldrinLin2019-08-13环境是php5.6和MySQL5.4 及nginx1.9 ,其他环境下请自己修改代码
qq_37221867
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于opencv的dnn模块实现Yolo-Fastest的目标检测python源码+模型+说明(高分项目).zip
- 使用Python调用微信本地ocr服务.zip
- 【精品推荐】人工智能在医疗中的应用.pptx
- 【精品推荐】电子医疗仪器人机接口-(1).ppt
- 【精品推荐】电子医疗仪器人机接口.ppt
- ubuntu镜像ubuntu镜像01
- 基于paddle搭建神经网络实现5种水果识别分类python源码+数据集(高分毕设).zip
- 【精品推荐】电子商务网店类型介绍.ppt
- 基于paddle搭建神经网络实现水果识别分类python源码+数据集(高分项目).zip
- 三菱plc编程口通信学习笔记.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功