2017 © Pedro Pelรกez
 

library codeigniter-phpunit

CodeIgniter 3 PHPUnit Test extension library

image

yidas/codeigniter-phpunit

CodeIgniter 3 PHPUnit Test extension library

  • Monday, April 30, 2018
  • by yidas
  • Repository
  • 1 Watchers
  • 1 Stars
  • 15 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 150 % Grown

The README.md

, (*1)

CodeIgniter PHPUnit Test


CodeIgniter 3 PHPUnit Test extension library, (*2)

Latest Stable Version License, (*3)

This RESTful API extension is collected into yidas/codeigniter-pack which is a complete solution for Codeigniter framework., (*4)

FEATURES

  • *PHPUnit Test in **Codeigniter 3 Framework*, (*5)

  • Easy to install into your Codeigniter project by Composer, (*6)


OUTLINE

REQUIREMENTS

This library requires the following:, (*7)

  • PHP 5.3.0+
  • CodeIgniter 3.0.0+

INSTALLATION

Run Composer in your Codeigniter project under the folder \application:, (*8)

composer require yidas/codeigniter-phpunit

DIRECTORY STRUCTURE

codeigniter/
โ””โ”€โ”€ application/
    โ”œโ”€โ”€ tests/          Test cases
    โ”œโ”€โ”€ vendor/         Vendor included yidas/codeigniter-phpunit
    โ””โ”€โ”€ phpunit.xml     PHPUnit XML

CONFIGURATION

According to Directory Structure, create and configure phpunit.xml under application directory:, (*9)

<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="vendor/yidas/codeigniter-phpunit/bootstrap.php">
  <testsuites>
    <testsuite name="TestSuite">
      <directory>tests</directory>
    </testsuite>
  </testsuites>
</phpunit>

For this phpunit.xml template, the test cases directory is application/test, make sure you would create every test cases under it., (*10)


USAGE

In the application directory of this library, run phpunit from vendor:, (*11)

$ ./vendor/bin/phpunit

Or using absolute path commands like:, (*12)

$ /var/www/html/codeigniter3/application/vendor/bin/phpunit -c /var/www/html/codeigniter3/application/phpunit.xml
$ phpunit -c /var/www/html/codeigniter3/application/phpunit.xml

Then the result would like:, (*13)

PHPUnit 5.7.27 by Sebastian Bergmann and contributors.



Time: 40 ms, Memory: 2.75MB

No tests executed!

TEST CASE

With this extension libaray, you could write test cases with loading Codeigniter framework., (*14)

For example, write a test case application/tests/CodeigniterTest.php for testing Codeigniter config component:, (*15)

<?php

use PHPUnit\Framework\TestCase;

final class CodeigniterTest extends TestCase
{
    function __construct() 
    {
        parent::__construct();
        // Load CI application
        $this->CI = & get_instance();
    }

    public function testConfigItem()
    {
        $indexPage = $this->CI->config->item('index_page');

        $this->assertSame('index.php', $indexPage);
    }
}

Then you would get the result OK (1 test, 1 assertion) by running PHPUnit test., (*16)

The Versions

30/04 2018

dev-master

9999999-dev https://github.com/yidas/codeigniter-phpunit

CodeIgniter 3 PHPUnit Test extension library

  Sources   Download

MIT

The Requires

 

phpunit codeigniter unit-test test-driven-development

30/04 2018

1.0.0

1.0.0.0 https://github.com/yidas/codeigniter-phpunit

CodeIgniter 3 PHPUnit Test extension library

  Sources   Download

MIT

The Requires

 

phpunit codeigniter unit-test test-driven-development