[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/test/PHPUnit/ -> Skeleton.php (sommaire)

PHP Version 4 Copyright (c) 2002-2005, Sebastian Bergmann <sb@sebastian-bergmann.de>. All rights reserved.

Author: Scott Mattocks <scott@crisscott.com>
Copyright: 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
License: http://www.opensource.org/licenses/bsd-license.php BSD License
Version: CVS: $Id: Skeleton.php,v 1.8 2005/11/10 09:47:14 sebastian Exp $
Poids: 448 lignes (14 kb)
Inclus ou requis:0 fois
Référencé: 1 fois
Nécessite: 0 fichiers

Définit 1 class

PHPUnit_Skeleton:: (11 méthodes):
  PHPUnit_Skeleton()
  setConfigFile()
  createTestClass()
  _createDefinition()
  _createConstructor()
  _createSetUpTearDown()
  _createMethod()
  _finishClass()
  _createTest()
  writeTestClass()
  _handleErrors()


Classe: PHPUnit_Skeleton  - X-Ref

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.

PHPUnit_Skeleton($className, $classPath, $includeParents = FALSE, $includePrivate = TRUE)   X-Ref
Constructor. Sets the class members and check that the class
to test is accessible.

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

setConfigFile($configFile)   X-Ref
The class to test may require a special config file before it can be
instantiated. This method lets you set that file.

param: string $configPath
return: void

createTestClass()   X-Ref
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.

param: none
return: void

_createDefinition()   X-Ref
Create the class definition.

The definition consist of a header comment, require statment
for getting the PHPUnit file, the actual class definition,
and the definition of the class member variable.

All of the code needed for the new class is stored in the
testClass member.

param: none
return: void

_createConstructor()   X-Ref
Create the class constructor. (PHP4 style)

The constructor simply calls the PHPUnit_TestCase method.
This code is taken from the PHPUnit documentation.

All of the code needed for the new class is stored in the
testClass member.

param: none
return: void

_createSetUpTearDown()   X-Ref
Create setUp and tearDown methods.

The setUp method creates the instance of the object to test.
The tearDown method releases the instance.
This code is taken from the PHPUnit documentation.

All of the code needed for the new class is stored in the
testClass member.

param: none
return: void

_createMethod($methodName)   X-Ref
Create a basic skeleton for test methods.

This code is taken from the PHPUnit documentation.

All of the code needed for the new class is stored in the
testClass member.

param: none
return: void

_finishClass()   X-Ref
Add the closing brace needed for a proper class definition.

All of the code needed for the new class is stored in the
testClass member.

param: none
return: void

_createTest()   X-Ref
Create the code that will actually run the test.

This code is added by default so that the test can be run
just by running the file. To have it not added pass false
as the second parameter to the writeTestClass method.
This code is taken from the PHPUnit documentation.

All of the code needed for the new class is stored in the
testClass member.

param: none
return: void

writeTestClass($destination = './', $addTest = TRUE)   X-Ref
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.

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

_handleErrors($message, $type = E_USER_ERROR)   X-Ref
Error handler.

This method should be rewritten to use the prefered error
handling method. (PEAR_ErrorStack)

param: string  $message The error message.
param: integer $type    An indication of the severity of the error.
return: void             Code may cause PHP to exit.



Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics