Leanpub Header

Skip to main content

PHPUnit in Action

The Easy Way

通过一个完整的实战项目学习 PHPUnit/DbUnit.

Minimum price

$9.90

$19.90

You pay

$19.90

Author earns

$15.92
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
About

About

About the Book

本书通过一个完整的实战项目介绍了云招 OurATS 9年来实践 PHPUnit/DbUnit 的经验.

Author

About the Author

何广宇

PHP Developer @ CloudRecruit Tech.

Contents

Table of Contents

前言

关于作者

1. PHPUnit Hello World

  1. 1.1 安装LAMP环境
  2. 1.2 安装PHPUnit
  3. 1.3 Hello World
  4. 1.4 Hello World 重构
  5. 1.5 Hello World Test
  6. 1.6 phpunit.xml
  7. 1.7 本章小结

2. 继续 Hello World

  1. 2.1 测试异常
  2. 2.2 @dataProvider
  3. 2.3 @group
  4. 2.4 Code Coverage
  5. 2.5 关于 Code Coverage 的进一步思考
  6. 2.6 PHPUnit 手册
  7. 2.7 本章小结

3. 实战项目 OurBlog 第一阶段介绍

  1. 3.1 用户注册
  2. 3.2 用户登录
  3. 3.3 后台首页
  4. 3.4 添加文章
  5. 3.5 编辑文章
  6. 3.6 删除文章
  7. 3.7 前台首页
  8. 3.8 文章详情页面
  9. 3.9 用户退出
  10. 3.10 本章小结

4. OurBlog 目录结构及数据库

  1. 4.1 OurBlog 目录结构
  2. 4.2 OurBlog 数据库
  3. 4.3 本章小结

5. OurBlog 用户注册

  1. 5.1 注册表单
  2. 5.2 提交表单
  3. 5.3 autoload
  4. 5.4 测试提交表单逻辑
  5. 5.5 reg 准备
  6. 5.6 reg
  7. 5.7 测试要连着数据库测吗?
  8. 5.8 DbUnit
  9. 5.9 phpunit-no-namespace
  10. 5.10 reg tests 准备
  11. 5.11 reg tests
  12. 5.12 再次测试提交注册表单
  13. 5.13 本章小结

6. OurBlog 用户登录

  1. 6.1 登录页面逻辑
  2. 6.2 测试登录逻辑
  3. 6.3 auth
  4. 6.4 auth tests 准备
  5. 6.5 auth tests
  6. 6.6 本章小结

7. OurBlog 后台首页

  1. 7.1 check login
  2. 7.2 header footer
  3. 7.3 后台首页
  4. 7.4 本章小结

8. OurBlog 添加文章

  1. 8.1 添加表单
  2. 8.2 测试添加表单
  3. 8.3 add
  4. 8.4 add tests
  5. 8.5 本章小结

9. OurBlog 编辑文章

  1. 9.1 编辑表单
  2. 9.2 edit
  3. 9.3 edit tests
  4. 9.4 本章小结

10. OurBlog 删除文章

  1. 10.1 delete
  2. 10.2 delete tests
  3. 10.3 本章小结

11. OurBlog 前台首页

  1. 11.1 header footer
  2. 11.2 文章列表
  3. 11.3 本章小结

12. OurBlog 文章详情页面

13. OurBlog 用户退出

14. 实战项目 OurBlog 第二阶段介绍

  1. 14.1 用户注册发送激活邮件
  2. 14.2 增加打标签功能
  3. 14.3 增加文件上传功能
  4. 14.4 增加外部文章功能
  5. 14.5 本章小结

15. OurBlog 用户注册发送激活邮件

  1. 15.1 邮件发送方式?
  2. 15.2 怎么判断用户是否已激活?
  3. 15.3 生成随机 token
  4. 15.4 实现发送激活邮件逻辑
  5. 15.5 写测试
  6. 15.6 注册成功提示
  7. 15.7 发送邮件 cronjob
  8. 15.8 实现激活逻辑
  9. 15.9 写测试
  10. 15.10 激活成功提示
  11. 15.11 修改登录验证逻辑
  12. 15.12 写测试
  13. 15.13 run-all-tests.sh
  14. 15.14 本章小结

16. OurBlog 增加打标签功能

  1. 16.1 新增数据库表
  2. 16.2 添加文章打标签
  3. 16.3 写测试
  4. 16.4 编辑文章打标签
  5. 16.5 写测试
  6. 16.6 删除文章时也删除标签
  7. 16.7 写测试
  8. 16.8 本章小结

17. OurBlog 增加文件上传功能

  1. 17.1 文件上传页面
  2. 17.2 文件上传逻辑
  3. 17.3 写测试
  4. 17.4 本章小结

18. OurBlog 增加外部文章功能

  1. 18.1 数据库
  2. 18.2 添加文章
  3. 18.3 同步字段修改
  4. 18.4 写测试
  5. 18.5 编辑文章
  6. 18.6 写测试
  7. 18.7 前台文章详情页面
  8. 18.8 本章小结

19. 让测试跑的更快

  1. 19.1 DbUnit
  2. 19.2 SSD
  3. 19.3 MySQL in memory
  4. 19.4 使用 MySQL in memory
  5. 19.5 本章小结

20. 真实项目分享1: OurATS

21. 真实项目分享2: BobParser

22. 结束语

附录:Bob Test Theroy

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub