2017 © Pedro Peláez
 

library ciunit

Enables testing CodeIgniter 2.1 with PHPUnit

image

celc/ciunit

Enables testing CodeIgniter 2.1 with PHPUnit

  • Thursday, August 27, 2015
  • by kitsunde
  • Repository
  • 7 Watchers
  • 46 Stars
  • 7,996 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 30 Forks
  • 11 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

CIUnit for CodeIgniter 2

Note: This is not compatible with CodeIgniter 3. The original creator of my-ciunit has a new project for that here: https://github.com/kenjis/ci-phpunit-test., (*1)

Examples

Controller

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);
    }
}

Install via composer

composer require Celc/ciunit dev-master

Copy the example test directory into the root of your project (same folder as application and system):, (*2)

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

Create application/config/testing/database.php for database testing. The database name must end with _test., (*3)

Writing tests

The tests directory is an example. You are meant to replace the tests with your own., (*4)

Run Tests:

From the tests directory run:, (*5)

../vendor/phpunit

The Versions

27/08 2015

dev-master

9999999-dev

Enables testing CodeIgniter 2.1 with PHPUnit

  Sources   Download

MIT

The Requires

 

25/06 2015

1.0.0

1.0.0.0

Enables testing CodeIgniter 2.1 with PHPUnit

  Sources   Download

MIT

The Requires