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

Class: PHPUnit_Skeleton

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

Class Overview


Class for creating a PHPUnit_TestCase skeleton file.


Author(s):

Copyright:

  • Copyright &copy; 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 53]
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 64]

The name of the class

Type:   string


[ Top ]

$classPath =

[line 58]

Path to the class file to create a skeleton for.

Type:   string


[ Top ]

$configFile =

[line 70]

Path to the configuration file needed by class to test.

Type:   string


[ Top ]

$includeParents =

[line 76]

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

Type:   boolean


[ Top ]

$includePrivate =

[line 82]

Whether or not to test private methods.

Type:   boolean


[ Top ]

$testClass =

[line 88]

The test class that will be created.

Type:   string


[ Top ]



Method Detail

PHPUnit_Skeleton (Constructor)   [line 100]

void PHPUnit_Skeleton( string $className, string $classPath, [boolean $includeParents = FALSE], [ $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.
   $includePrivate   — 

[ Top ]

createTestClass   [line 144]

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

void setConfigFile( $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   — 
   $configFile   — 

[ Top ]

writeTestClass   [line 361]

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 Mon, 11 Mar 2019 14:22:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.