/[drupal]/contributions/modules/simpletest/simpletest.module
ViewVC logotype

Contents of /contributions/modules/simpletest/simpletest.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Fri Feb 27 04:21:41 2004 UTC (5 years, 8 months ago) by weitzman
Branch: MAIN
File MIME type: text/x-php
from the README

Description
------------------
A framework for running unit tests in Drupal.

Status
------------------
No tests have been written. This framework should work though.

Requirements
----------------

- Install the simpletest framework to a new directory called 'simpletest' right under Drupal root.
You can find it at http://www.lastcraft.com/simple_test.php

Install
-----------------------

- Copy this module package to your /modules directory
- Activate the simpletest.module
- Visit the admin/simpletest page

Simpletest hook
-----------------------

This module offers a new 'simpletest' hook. Modules implementing this hook should an array of paths which
point to test files. These paths should be relative to the /simpletest directory.

Writing Tests
-----------------------
Please write some tests. I'm a bit new at this and haven't decided on a worthy approach.

Author
---------------------
<Moshe Weitzman < weitzman at tejasa dot com >
1 <?php
2
3 function simpletest_help($section) {
4 $output = "";
5
6 switch ($section) {
7 case 'admin/system/modules#description':
8 $output = t("Simple unit testing suite");
9 break;
10 case 'admin/system/modules/simpletest':
11 $output = '';
12 break;
13 }
14
15 return $output;
16 }
17
18 function simpletest_link($type) {
19 if ($type == 'system') {
20 menu('admin/simpletest', 'simpletest', 'simpletest_admin');
21 }
22 }
23
24 function simpletest_admin() {
25 if (!defined("SIMPLE_TEST")) {
26 define("SIMPLE_TEST", "simpletest/");
27 }
28 require_once(SIMPLE_TEST . 'unit_tester.php');
29 require_once(SIMPLE_TEST . 'web_tester.php');
30 require_once(SIMPLE_TEST . 'shell_tester.php');
31 require_once(SIMPLE_TEST . 'reporter.php');
32 require_once(SIMPLE_TEST . 'mock_objects.php');
33 require_once(SIMPLE_TEST . 'extensions/pear_test_case.php');
34 require_once(SIMPLE_TEST . 'extensions/phpunit_test_case.php');
35
36 class UnitTests extends GroupTest {
37 function UnitTests() {
38 $this->GroupTest("Drupal unit tests");
39 $files = module_invoke_all('simpletest');
40 foreach ($files as $file) {
41 $this->addTestFile($file);
42 }
43 }
44 }
45
46 if (! defined("TEST_RUNNING")) {
47 define("TEST_RUNNING", true);
48 $test = &new UnitTests();
49 if (SimpleReporter::inCli()) {
50 exit ($test->run(new TextReporter()) ? 0 : 1);
51 }
52 $test->run(new HtmlReporter());
53 }
54 }
55
56
57 ?>

  ViewVC Help
Powered by ViewVC 1.1.2