Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter and SimpleTest -- How to make my first test?

I'm used to web development using LAMP, PHP5, MySQL plus NetBeans with Xdebug.

Now I want to improve my development, by learning how to use (A) proper testing and (B) a framework. So I have set up CodeIgniter, SimpleTest and the easy Xdebug add-in for Firefox. This is great fun because maroonbytes provided me with clear instructions and a configured setup ready for download. I am standing on the shoulders of giants, and very grateful.

I've used SimpleTest a bit in the past. Here is a the kind of thing I wrote:

<?php
require_once('../simpletest/unit_tester.php');
require_once('../simpletest/reporter.php');

class TestOfMysqlTransaction extends UnitTestCase {
  function testDB_ViewTable() {
    $this->assertEqual(1,1);   // a pseudo-test
  }
}
$test = new TestOfMysqlTransaction();
$test->run(new HtmlReporter())
?>

So I hope I know what a test looks like. What I can't figure out is where and how to put a test in my new setup. I don't see any sample tests in the maroonbytes package, and Google so far has led me to posts that assume unit testing is already functionally available. What do I do?

like image 491
Smandoli Avatar asked Feb 18 '26 15:02

Smandoli


1 Answers

Edit:

If you are following the maroonbytes setup, just follow the instructions:

  1. Download the SimpleTest framework and extract the files into your @codeigniter directory.
  2. In both your main folder and your admin/application folder create a new folder called tests.
  3. Within the new tests folder setup additional folders called ‘models’, ‘views’, ‘controllers’, ‘libraries’ and ‘helpers’.

Any file ending in .php and with a UnitTestCase inside any of those folders, should be run. :)

like image 84
Favio Avatar answered Feb 21 '26 03:02

Favio