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

Class: PHPUnit_Skeleton

Source Location: /PHPUnit-1.3.2/PHPUnit/Skeleton.php

Class Overview


Class for creating a PHPUnit_TestCase skeleton file.


Author(s):

Version:

  • Release: @package_version@

Copyright:

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

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 87]
Class for creating a PHPUnit_TestCase skeleton file.

This class will take a classname as a parameter on construction and will create a PHP file that contains the skeleton of a PHPUnit_TestCase subclass. The test case will contain a test foreach method of the class. Methods of the parent class will, by default, be excluded from the test class. Passing and optional construction parameter will include them.

Example

<?php require_once 'PHPUnit/Skeleton.php'; $ps = new PHPUnit_Skeleton('PHPUnit_Skeleton', 'PHPUnit/Skeleton.php');

// Generate the test class. // Default settings will not include any parent class methods, but // will include private methods. $ps->createTestClass();

// Write the new test class to file. // By default, code to run the test will be included. $ps->writeTestClass(); ?>

Now open the skeleton class and fill in the details. If you run the test as is, all tests will fail and you will see plenty of undefined constant errors.



[ Top ]


Class Variables

$className =

[line 98]

The name of the class

Type:   string


[ Top ]

$classPath =

[line 92]

Path to the class file to create a skeleton for.

Type:   string


[ Top ]

$configFile =

[line 104]

Path to the configuration file needed by class to test.

Type:   string


[ Top ]

$includeParents =

[line 110]

Whether or not to include the methods of the parent class when testing.

Type:   boolean


[ Top ]

$includePrivate =

[line 116]

Whether or not to test private methods.

Type:   boolean


[ Top ]

$testClass =

[line 122]

The test class that will be created.

Type:   string


[ Top ]



Method Detail

PHPUnit_Skeleton (Constructor)   [line 134]

void PHPUnit_Skeleton( string $className, string $classPath, [boolean $includeParents = FALSE], [mixed $includePrivate = TRUE])

Constructor. Sets the class members and check that the class to test is accessible.
  • Access: public

Parameters:

string   $className     
string   $classPath     
boolean   $includeParents     Wheter to include the parent's methods in the test.

[ Top ]

createTestClass   [line 178]

void createTestClass( none 0)

Create the code that will be the skeleton of the test case.

The test case must have a clss definition, one var, a constructor setUp, tearDown, and methods. Optionally and by default the code to run the test is added when the class is written to file.

  • Access: public

Parameters:

none   0     

[ Top ]

setConfigFile   [line 158]

void setConfigFile( mixed $configFile, string $configPath)

The class to test may require a special config file before it can be instantiated. This method lets you set that file.
  • Access: public

Parameters:

string   $configPath     

[ Top ]

writeTestClass   [line 395]

void writeTestClass( [string $destination = './'], [boolean $addTest = TRUE])

Write the test class to file.

This will write the test class created using the createTestClass method to a file called <className>Test.php. By default the file is written to the current directory and will have code to run the test appended to the bottom of the file.

  • Access: public

Parameters:

string   $destination     The directory to write the file to.
boolean   $addTest     Wheter to add the test running code.

[ Top ]


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