celc/ciunit

此包已被废弃且不再维护。没有建议的替代包。

启用使用PHPUnit测试CodeIgniter 2.1

维护者

详细信息

github.com/kitsunde/CIUnit

源代码

安装数: 29,575

依赖者: 0

建议者: 0

安全: 0

星星: 47

关注者: 7

分支: 33

1.0.0 2015-06-25 02:46 UTC

This package is not auto-updated.

Last update: 2020-11-13 20:02:15 UTC


README

注意:此包与CodeIgniter 3不兼容。我-ciunit的原作者为此创建了一个新项目,详情请见:https://github.com/kenjis/ci-phpunit-test

示例

控制器

class LoginActionTest extends CIUnit_TestCase
{
    public function setUp()
    {
        $this->CI = set_controller('login');
    }

    public function testLogin()
    {
        $_POST['useremail'] = 'kitsunde@example.org';
        $_POST['password'] = '123';
        $this->CI->login_action();
        $out = output();
        $this->assertRedirects($GLOBALS['OUT'], 'employee/index');
    }

    public function testTemplateRendered()
    {
        $this->CI->login_action();
        $views = output_views();
        $this->assertContains('login', $views);
    }
}

通过composer安装

composer require Celc/ciunit dev-master

将示例测试目录复制到项目的根目录(与applicationsystem同一文件夹)

cp -R vendor/celc/ciunit/tests ./

为数据库测试创建application/config/testing/database.php。数据库名必须以_test结尾。

编写测试

tests目录是一个示例。您应该用您自己的测试替换它。

运行测试

tests目录运行

../vendor/phpunit