Skip to content

CI_Unit_test

Mathieu Nayrolles edited this page Jan 20, 2016 · 1 revision

CI_Unit_test

Unit Testing Class

Simple testing class

  • Class name: CI_Unit_test
  • Namespace:

Properties

$active

public boolean $active = TRUE

Active flag

  • Visibility: public

$results

public array $results = array()

Test results

  • Visibility: public

$strict

public boolean $strict = FALSE

Strict comparison flag

Whether to use === or == when comparing

  • Visibility: public

$_template

protected string $_template = NULL

Template

  • Visibility: protected

$_template_rows

protected string $_template_rows = NULL

Template rows

  • Visibility: protected

$_test_items_visible

protected array $_test_items_visible = array('test_name', 'test_datatype', 'res_datatype', 'result', 'file', 'line', 'notes')

List of visible test items

  • Visibility: protected

Methods

__construct

void CI_Unit_test::__construct()

Constructor

  • Visibility: public

set_test_items

void CI_Unit_test::set_test_items(array $items)

Run the tests

Runs the supplied tests

  • Visibility: public

Arguments

  • $items array

run

string CI_Unit_test::run(mixed $test, mixed $expected, string $test_name, string $notes)

Run the tests

Runs the supplied tests

  • Visibility: public

Arguments

  • $test mixed
  • $expected mixed
  • $test_name string
  • $notes string

report

string CI_Unit_test::report(array $result)

Generate a report

Displays a table with the test data

  • Visibility: public

Arguments

  • $result array

use_strict

void CI_Unit_test::use_strict(boolean $state)

Use strict comparison

Causes the evaluation to use === rather than ==

  • Visibility: public

Arguments

  • $state boolean

active

void CI_Unit_test::active($state)

Make Unit testing active

Enables/disables unit testing

  • Visibility: public

Arguments

  • $state mixed

result

array CI_Unit_test::result(array $results)

Result Array

Returns the raw result data

  • Visibility: public

Arguments

  • $results array

set_template

void CI_Unit_test::set_template($template)

Set the template

This lets us set the template to be used to display results

  • Visibility: public

Arguments

  • $template mixed

_backtrace

array CI_Unit_test::_backtrace()

Generate a backtrace

This lets us show file names and line numbers

  • Visibility: protected

_default_template

string CI_Unit_test::_default_template()

Get Default Template

  • Visibility: protected

_parse_template

void CI_Unit_test::_parse_template()

Parse Template

Harvests the data within the template {pseudo-variables}

  • Visibility: protected
Clone this wiki locally