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

Class: PHPUnit_GUI_SetupDecorator

Source Location: /PHPUnit-1.2.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):

Methods


Inherited Variables

Inherited Methods


Class Details

[line 53]
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->getSuitesFromDir('/path/to/dir/tests','.*\.php$',array('index.php','sql.php'));
  3.  $gui->show();
  4.  ?>

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 59]

PHPUnit_GUI_SetupDecorator PHPUnit_GUI_SetupDecorator( &$gui)


Parameters:

   &$gui   — 

[ Top ]

getSuitesFromDir   [line 85]

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 68]

void show( [ $showPassed = TRUE])

just forwarding the action to the decorated class.

Parameters:

   $showPassed   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:22:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.