codeigniter3 全面集成 phpunit

目录

ci-phpunit-test for CodeIgniter 3.x

Requirements

Optional

Change Log

Folder Structure

Installation

Installation via Composer

Upgrading

Upgrading via Composer


ci-phpunit-test for CodeIgniter 3.x

An easier way to use PHPUnit with CodeIgniter 3.x.

  • You don't have to modify CodeIgniter core files at all.
  • You can write controller tests easily.
  • Nothing is untestable, maybe.
  • Well documented.

Screenshot: Running tests on NetBeans 8.1

Requirements

  • PHP 5.4.0 or later (5.6 or later is recommended)
  • CodeIgniter 3.x
  • PHPUnit 4.3 to 7.5 (4.8 or later is recommended)
    • If you want to use PHPUnit 8 or later, please use ci-phpunit-test 2.x.
    • If you use PHPUnit 6.0, please use ci-phpunit-test v0.14.0 or later.
    • You can download old version of phpunit.phar from https://phar.phpunit.de/.

Optional

  • NetBeans
    • Go to Project Properties > Testing > PHPUnit, check Use Custom Test Suite checkbox, and select application/tests/_ci_phpunit_test/TestSuiteProvider.php.

Change Log

See Change Log.

Folder Structure

codeigniter/
├── application/
│   └── tests/
│        ├── _ci_phpunit_test/ ... don't touch! files ci-phpunit-test uses
│        ├── Bootstrap.php     ... bootstrap file for PHPUnit
│        ├── DbTestCase.php    ... DbTestCase class
│        ├── TestCase.php      ... TestCase class
│        ├── controllers/      ... put your controller tests
│        ├── libraries/        ... put your library tests
│        ├── mocks/
│        │   └── libraries/    ... mock libraries
│        ├── models/           ... put your model tests
│        └── phpunit.xml       ... config file for PHPUnit
└── vendor/

Installation

  1. Download latest ci-phpunit-test from https://github.com/kenjis/ci-phpunit-test/releases.
  2. Unzip and copy application/tests folder into your application folder in CodeIgniter project.

That's it.

Installation via Composer

If you like Composer:

$ cd /path/to/codeigniter/
$ composer require kenjis/ci-phpunit-test --dev

And run install.php:

$ php vendor/kenjis/ci-phpunit-test/install.php
  • The above command always overwrites exisiting files.
  • You must run it at CodeIgniter project root folder.
  • You can specify your application and public folder with option arguments, if you use custom folder paths.
$ php vendor/kenjis/ci-phpunit-test/install.php -a <application_dir> -p <public_dir>

Upgrading

  1. Download latest ci-phpunit-test from https://github.com/kenjis/ci-phpunit-test/releases.
  2. Unzip and replace application/tests/_ci_phpunit_test folder.
  3. Read Change Log.

Upgrading via Composer

If you like Composer:

$ cd /path/to/codeigniter/
$ composer update kenjis/ci-phpunit-test
$ php vendor/kenjis/ci-phpunit-test/update.php [-a <application_dir> -p <public_dir>]

Read Change Log.

 

 

 

 


参考链接(学术无国界,知识only for勤劳的人):

https://github.com/kenjis/ci-phpunit-test

https://github.com/kenjis/ci-phpunit-test/blob/master/docs/HowToWriteTests.md

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值