write() public method

Generates the code and writes it to a source file.
public write ( string $file = '' )
$file string
 /**
  * @param  string  $test
  * @param  string  $testFile
  * @access protected
  * @static
  */
 protected static function doSkeleton($test, $testFile)
 {
     if ($test !== FALSE) {
         PHPUnit_TextUI_TestRunner::printVersionString();
         try {
             $skeleton = new PHPUnit_Util_Skeleton($test, $testFile);
             $skeleton->write();
         } catch (Exception $e) {
             print $e->getMessage() . "\n";
             printf('Could not write test class skeleton for "%s" to "%s".' . "\n", $test, $testFile);
             exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
         }
         printf('Wrote test class skeleton for "%s" to "%s".' . "\n", $test, $skeleton->getTestSourceFile());
         exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
     }
 }
Esempio n. 2
0
<?php

// Use PHPUnit2 to create the skeletons.
//ATTENTION: needs phpunit2 bugfix
// http://pear.php.net/bugs/bug.php?id=6965
die("deactived for security reasons");
require_once 'PHPUnit/Util/Skeleton.php';
// Get all of the classes in PHP-GTK 2.
/* Get all classes and filter out Gtk classes only */
// Taken from Anant's updater script.
$classes = array();
$allClasses = get_declared_classes();
$extensions = array('Gtk', 'Gdk', 'Atk', 'Pango');
foreach ($extensions as $extension) {
    foreach ($allClasses as $oneClass) {
        if (strpos($oneClass, $extension) === 0) {
            $classes[] = $oneClass;
        }
    }
}
sort($classes);
foreach ($classes as $class) {
    // Create a skeleton for the class.
    $skeleton = new PHPUnit_Util_Skeleton($class);
    // Write the test.
    $skeleton->write();
}