Source for file Skeleton.php
Documentation is available at Skeleton.php
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License, |
// | that is available at http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +------------------------------------------------------------------------+
// $Id: Skeleton.php,v 1.15.2.5 2005/06/03 05:48:09 sebastian Exp $
* Class for creating a PHPUnit2_Framework_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 PHPUnit2_Framework_TestCase
* require_once 'PHPUnit2/Util/Skeleton.php';
* $skeleton = new PHPUnit2_Util_Skeleton(
* 'PHPUnit2_Util_Skeleton',
* 'PHPUnit2/Util/Skeleton.php'
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright Copyright © 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
// {{{ Instance Variables
if (!defined("PHPUnit2_MAIN_METHOD")) {
define("PHPUnit2_MAIN_METHOD", "{className}Test::main");
require_once "PHPUnit2/Framework/IncompleteTestError.php";
require_once "PHPUnit2/Framework/TestCase.php";
require_once "PHPUnit2/Framework/TestSuite.php";
require_once "{classFile}";
* Test class for {className}.
* Generated by PHPUnit2_Util_Skeleton on {date} at {time}.
class {className}Test extends PHPUnit2_Framework_TestCase {
public static function main() {
require_once "PHPUnit2/TextUI/TestRunner.php";
$suite = new PHPUnit2_Framework_TestSuite("{className}Test");
$result = PHPUnit2_TextUI_TestRunner::run($suite);
if (PHPUnit2_MAIN_METHOD == "{className}Test::main") {
* @todo Implement test{methodName}().
public function test{methodName}() {
throw new PHPUnit2_Framework_IncompleteTestError;
// {{{ public function __construct($className, $classSourceFile = '')
* @param string $className
* @param string $classSourceFile
public function __construct($className, $classSourceFile = '') {
if ($classSourceFile == '') {
$classSourceFile = $className . '.php';
'Could not find class "%s" in %s.',
// {{{ public function generate()
* Generates the test class' source.
$class = new ReflectionClass ($this->className);
foreach ($class->getMethods () as $method) {
if (!$method->isConstructor () &&
!$method->isAbstract () &&
$method->isUserDefined () &&
$method->getDeclaringClass ()->getName () == $this->className) {
$testClassSource .= $this->testMethod($method->getName ());
// {{{ public function write()
* Generates the test class and writes it to a source file.
public function write($file = '') {
if ($fp = @fopen($file, 'w')) {
// {{{ public function setTemplates($classHeader, $classFooter, $method)
* Sets the templates for class header, class footer, and method.
* @param string $classHeader
* @param string $classFooter
public function setTemplates($classHeader, $classFooter, $method) {
// {{{ protected function testClassHeader($className, $classSourceFile)
* @param string $className
* @param string $classSourceFile
// {{{ protected function testClassFooter($className)
* @param string $className
// {{{ protected function testMethod($methodName)
* @param string $methodName
* vim600: et sw=2 ts=2 fdm=marker
Documentation generated on Mon, 11 Mar 2019 14:19:19 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|