<?
/**
* This file contains methods for performing the automated build process for Emailr
*
* Since the Emailr is written in PHP, a scripting language, the automated process does
* not actually compile any code. It does however execute all unit tests and generate the api
* documentation for Emailr. By running this build script for every change, the
* the documentation will stay up to date (assuming proper comments) and bugs will be caught
* early by the unit tests.
* @package Emailr
* @subpackage Build
* @author Jon Herron
* @version 0.0.0.1
* @since 02.23.2008
*/
require_once realpath(dirname(__file__) . "/../common/Environment.inc");
//-----------------------------------------------------------------------------
$rootFolder = realpath(dirname(__file__) . "/../");
// get the execute prefix that needs to be used before calling phpdoc and phpunit. This is
// required if the path to these php programs are not available in the users path, and are passed
// into the script as a command line parameter.
$executionPrefix = GetExecutionPrefix($argc, $argv);
print "\n\n--------------------------------------------------";
RunUnitTests($rootFolder, $executionPrefix);
print "\n\n--------------------------------------------------";
GenerateDocumentation($rootFolder, $executionPrefix);
print "\n\n--------------------------------------------------\n\n";
//-----------------------------------------------------------------------------
/**
* Generate Emailr documentation via phpdoc
*
* This method will call phpdoc via the command line to generate the API Documentation for
* Emailr. Flags are passed in to ignore phpMyAdmin and existing generated documentation.
* @access public
* @author Jon Herron
* @param string $directory the root directory for Emailr
* @param string $prefix execution prefix to use when calling phpdoc
* @version 0.0.0.1
* @since 02.23.2008
*/
function GenerateDocumentation($directory, $prefix = "")
{
// change the current directory back to the root directory of the Eddy Framework
chdir($directory);
print "\n\nGenerating Documentation...\n\n";
print exec($prefix . "phpdoc -s on -pp on -o HTML:frames:earthli -d ./ -i *phpMyAdmin* -t public/static/docs");
}
/**
* Return the execute prefix, if one is passed in as a command line parameter
*
* get the execute prefix that needs to be used before calling phpdoc and phpunit. This is
* required if the path to these php programs are not available in the users path, and are passed
* into the script as a command line parameter.
* @access public
* @author Jon Herron
* @param int $argumentCount arugment count from command line
* @param array $argumentArray an array of arguments passed in via the command line
* @returns string execute prefix passed in as command line argument (if one is available)
* @version 0.1.5
* @since 03.16.2008
*/
function GetExecutionPrefix($argumentCount, $argumentArray)
{
$prefix = "";
// check to see if we have any command line arguments passed in
if($argumentCount > 1)
{
// we do, pull the parameter in as the prefix
$prefix = $argumentArray[1];
// replace all \ with / in case we are in a windows environment
$prefix = ereg_replace("[\\]", "/", $prefix);
// check to see if prefix ends with a /, if not add one
if(!(ereg("/$", $prefix)))
{
$prefix .= "/";
}
}
return($prefix);
}
/**
* Runs Emailr Unit Tests
*
* This method will call phpunit via the command line to execute all Emailr Unit Tests. This should
* be run after each change, to help in finding bugs, breaks, etc.
* @access public
* @author Jon Herron
* @param string $directory the root directory for Emailr
* @param string $prefix execution prefix to use when calling phpdoc
* @version 0.0.0.1
* @since 02.24.2008
*/
function RunUnitTests($directory, $prefix = "")
{
chdir($directory . "/tests");
print "\n\nRunning Unit Tests...\n";
// pull all the items in the tests folder
$tests = scandir(".");
// loop through each one, looking for test fixtures
foreach($tests as $test)
{
if(preg_match('/((.+?)Test).php$/i', $test, $matches))
{
// got one, run it
print "\n\t* Executing $matches[1]: ";
print exec($prefix . "phpunit $matches[1]");
}
}
print "\n\ndone";
}
?>