Why is CIUnit needed in order to use PHPUnit with CodeIgniter?(为什么需要 CIUnit 才能将 PHPUnit 与 CodeIgniter 一起使用?)
问题描述
We've decided to use PHPUnit (with Jenkins) in our next project. We're considering different PHP frameworks, one of which is CodeIgniter. I see that a lot of people use My CIUNIT to "bridge" PHPUnit and Codeigniter. There is little to no explanation in the online documentation.
Why is it needed?
Other frameworks don't seem to need a "cool bridge" like this.
Reasons:
- Codeigniter's components are tightly coupled. You need some big basic parts running (the loader, the router, the CFG object) before you can use any other pieces.
- Codeigniter is not designed to run from a CLI. It has a great deal of bootstrapping code in its index.php front-controller, and it assumes a web server environment.
You do not absolutely require CIUNIT to unit-test CI. But you will have to do something. In my case, I wrote an alternative front controller to index.php which just loads the minimum necessary to get a CI superobject. I require_once
it at the top of my test files, and $this->CI =& get_instance()
in SetUp()
methods. If I were being an absolutely pure unit-tester, however, I should be destroying and re-creating the CI object after every test in case some state got trapped in it. I'm not sure if CIUNIT does this for you.
这篇关于为什么需要 CIUnit 才能将 PHPUnit 与 CodeIgniter 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么需要 CIUnit 才能将 PHPUnit 与 CodeIgniter 一起使用?


基础教程推荐
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01