Giter VIP home page Giter VIP logo

codeigniter-simpletest's Introduction

CodeIgniter with SimpleTest

Updates:

The CodeIgniter core is now being converted to using phpUnit so I'm using simpletest as a stopgap measure.

In additon to the original version I've added the ability to output the test results in Junit format for use in continuous integration systems based on work from https://techknowhow.library.emory.edu/blogs/rsutton/2009/07/24/using-hudson-php-simpletest

Overview

This has been adopted from: jamieonsoftware

With help from: John S. - http://github.com/juven14

Design From: Istvan Pusztai - http://codeigniter.com/forums/viewthread/129253/P10/#697201

Installation

The unit_test.php file should go in your CodeIgniter root. The same place as index.php

You should open that file and alter your paths at the top.

The tests directory can be moved any where you want but they are setup to be in the root as well.

All test files need to be named test_name_folder.php. For example:

test_whatever_bug.php
test_string_helper.php
test_auth_library.php
test_core_model.php

I have included a full download of simpletest and the only customization I have made is to the simpletest/extensions/my_reporter.php.

Usage:

Once you have installed you can either run tests through the browser or via command line.

  • Browser - Visit yoursite.com/unit_test.php
  • Command Link - $ php unit_test.php
  • XML Results - $ php unit_test_xml.php

NOTES:

Inside the "tests" directory I include two example test files. The test_users_model.php will not run on its own because your application would not include the same users model as the example file. It is supplied just as a guide.

This version is now compatible with PHP 5.3

Credits

codeigniter-simpletest's People

Contributors

chonthu avatar ericlbarnes avatar flashover avatar hfunai avatar jason-cooke avatar joetsuihk avatar kstep avatar slivero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter-simpletest's Issues

View test example

Well done!
I was really looking for something like this package!

A was wondering how do you handle the view test.
Using simpletest I solve the issue with a combination of:

$this->get('http://localhost/....../mypage.php');

$this->click('My link to click');

$this->assertText('Text to check');

Is that a correct approach?
What's the correct way using your package?

The action you have requested is not allowed.

Not sure whether I'm doing this right, but when I go to /unit_test.php and run any test, it throws this error

"The action you have requested is not allowed."

I'm running CI 2.0.2

true test but full of exceptions

Here is my simple controller test. It works perfectly, but it throws lots of exceptions.

class test_user_controller extends CodeIgniterWebTestCase
{
function __construct()
{
parent::__construct();
$this->WebTestCase('User Controller');
}

function testHomePage() {
$this->get('http://localhost/hekmat/');
$this->assertText('Main Page');
}
}

exceptions:
Exception: D:\wamp\www\Hekmat/tests/controllers/test_users_controller.php -> User Controller -> testHomePage -> Unexpected PHP error [Function split() is deprecated] severity [E_DEPRECATED] in [D:\wamp\www\Hekmat\tests\simpletest\url.php line 188]
Exception: D:\wamp\www\Hekmat/tests/controllers/test_users_controller.php -> User Controller -> testHomePage -> Unexpected PHP error [Function split() is deprecated] severity [E_DEPRECATED] in [D:\wamp\www\Hekmat\tests\simpletest\http.php line 524]
Exception: D:\wamp\www\Hekmat/tests/controllers/test_users_controller.php -> User Controller -> testHomePage -> Unexpected PHP error [Function split() is deprecated] severity [E_DEPRECATED] in [D:\wamp\www\Hekmat\tests\simpletest\http.php line 319]
Exception: D:\wamp\www\Hekmat/tests/controllers/test_users_controller.php -> User Controller -> testHomePage -> Unexpected PHP error [Function split() is deprecated] severity [E_DEPRECATED] in [D:\wamp\www\Hekmat\tests\simpletest\http.php line 460]
Exception: D:\wamp\www\Hekmat/tests/controllers/test_users_controller.php -> User Controller -> testHomePage -> Unexpected PHP error [Function split() is deprecated] severity [E_DEPRECATED] in [D:\wamp\www\Hekmat\tests\simpletest\url.php line 188]
Exception: D:\wamp\www\Hekmat/tests/controllers/test_users_controller.php -> User Controller -> testHomePage -> Unexpected PHP error [Function split() is deprecated] severity [E_DEPRECATED] in [D:\wamp\www\Hekmat\tests\simpletest\url.php line 188]

Suggest: Selenium

Add support for Selenium; PHPUnit has it yet i think its over-complicate with PHPUnit....

Isolated view test

Is there a decent way to test views in isolation (ie without invoking controllers/models, just setting up some variables) using simple_test?

Improve documentation

This library would be a lot more useful if some real-world documentation were included -- this should include basic installation scenarios (e.g. is it even possible to put the test files in a directory outside of document root? All my CodeIgniter files save for index.php are not in the docroot, but I see nothing in the comments or README that let me know if this was written in a way that respects that common scenario).

Here are a few examples:

  • from unit_test.php, What is this?:
    define('MAIN_PATH', realpath(dirname(FILE)).'/');
  • Please put a link back to http://www.simpletest.org/ prominently in your docs -- it's not clear from the de
  • From the README, this is useless: "All test files need to be named test_name_folder.php." -- you give example of the filename, but no explanation of where they're supposed to go. What directory?
  • Please explain your directory structure. I'm used to putting all my tests into one folder. Why would I put some into a folder named "bugs" and others in a folder named "libraries" etc.
  • Update your unit_test.php file so it's clear what areas should NOT be edited. Usually there's a note like "DO NOT EDIT BELOW THIS LINE."
  • Add at least one wiki page please: something that describes the project -- it's not even clear that this is an implementation of http://www.simpletest.org/ (include a link please)

With mediocre documentation, a project can never be more than mediocre.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.