PHPUnit
[ class tree: PHPUnit ] [ index: PHPUnit ] [ all elements ]

Class: PHPUnit_GUI_SetupDecorator

Source Location: /PHPUnit-1.3.2/PHPUnit/GUI/SetupDecorator.php

Class Overview


This decorator actually just adds the functionality to read the test-suite classes from a given directory and instanciate them automatically, use it as given in the example below.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>

Methods


Inherited Variables

Inherited Methods


Class Details

[line 87]
This decorator actually just adds the functionality to read the test-suite classes from a given directory and instanciate them automatically, use it as given in the example below.


1 <?php
2 $gui = new PHPUnit_GUI_SetupDecorator(new PHPUnit_GUI_HTML());
3 $gui->getSuitesFromDir('/path/to/dir/tests','.*\.php$',array('index.php','sql.php'));
4 $gui->show();
5 ?>

The example calls this class and tells it to:

  • find all file under the directory /path/to/dir/tests
  • for files, which end with '.php' (this is a piece of a regexp, that's why the . is escaped)
  • and to exclude the files 'index.php' and 'sql.php'
  • and include all the files that are left in the tests.
Given that the path (the first parameter) ends with 'tests' it will be assumed that the classes are named tests_* where * is the directory plus the filename, according to PEAR standards.

So that:

  • 'testMe.php' in the dir 'tests' bill be assumed to contain a class tests_testMe
  • '/moretests/aTest.php' should contain a class 'tests_moretests_aTest'



[ Top ]


Method Detail

PHPUnit_GUI_SetupDecorator (Constructor)   [line 93]

PHPUnit_GUI_SetupDecorator PHPUnit_GUI_SetupDecorator( mixed &$gui)


[ Top ]

getSuitesFromDir   [line 119]

void getSuitesFromDir( string $dir, [string $filenamePattern = ''], [array $exclude = array()])

Setup test suites that can be found in the given directory

Using the second parameter you can also choose a subsets of the files found in the given directory. I.e. only all the files that contain '_UnitTest_', in order to do this simply call it like this:


1 getSuitesFromDir($dir,'.*_UnitTest_.*')
. There you can already see that the pattern is built for the use within a regular expression.


Parameters:

string   $dir     the directory where to search for test-suite files
string   $filenamePattern     the pattern (a regexp) by which to find the files
array   $exclude     an array of file names that shall be excluded

[ Top ]

show   [line 102]

void show( [mixed $showPassed = TRUE])

just forwarding the action to the decorated class.

[ Top ]


Documentation generated on Thu, 10 Nov 2005 05:02:22 -0500 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.