summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2007-05-16 01:54:57 +0000
committerwei <>2007-05-16 01:54:57 +0000
commitc5acb6c053ddf7428c0a56af61e26732a51685d4 (patch)
treec89d6ce111845c1571f55b2999145748b9282f40
parentf52dd35b28701da6ca62b9d8bde059fcc9974104 (diff)
update phing simpletest task
-rw-r--r--.gitattributes4
-rw-r--r--buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php72
-rw-r--r--buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php18
-rw-r--r--buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php48
-rw-r--r--buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php4
-rw-r--r--buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php46
-rw-r--r--buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php154
-rw-r--r--buildscripts/phing/tasks/PradoSimpleTestTask.php40
-rwxr-xr-xframework/prado-cli.php17
-rw-r--r--prado-cli3
-rw-r--r--prado-cli.bat39
11 files changed, 372 insertions, 73 deletions
diff --git a/.gitattributes b/.gitattributes
index dc6b40bc..b81b92d4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -494,6 +494,7 @@ buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultForma
buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php -text
buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php -text
buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php -text
+buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php -text
buildscripts/phing/classes/phing/tasks/ext/svn/SvnBaseTask.php -text
buildscripts/phing/classes/phing/tasks/ext/svn/SvnExportTask.php -text
buildscripts/phing/classes/phing/tasks/ext/svn/SvnLastRevisionTask.php -text
@@ -618,6 +619,7 @@ buildscripts/phing/tasks/PradoDocTask.php -text
buildscripts/phing/tasks/PradoPackageTask.php -text
buildscripts/phing/tasks/PradoPearTask.php -text
buildscripts/phing/tasks/PradoQuickStartDocs.php -text
+buildscripts/phing/tasks/PradoSimpleTestTask.php -text
buildscripts/phing/tasks/PradoTestTask.php -text
buildscripts/phing/tasks/PradoVersionTask.php -text
buildscripts/phing/tasks/QuickstartIndexTask.php -text
@@ -2195,6 +2197,8 @@ framework/prado.php -text
/index.html -text
/phing -text
/phing.bat -text
+/prado-cli -text
+/prado-cli.bat -text
requirements/index.php -text
requirements/messages-bg.txt -text
requirements/messages-zh.txt -text
diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php
index fab27315..82bf5776 100644
--- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php
+++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php
@@ -21,7 +21,7 @@
require_once 'phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php';
require_once 'phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php';
-require_once 'phing/tasks/ext/phpunit2/FormatterElement.php';
+require_once 'phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php';
/**
* Child class of "FormatterElement", overrides setType to provide other
@@ -32,16 +32,26 @@ require_once 'phing/tasks/ext/phpunit2/FormatterElement.php';
* @package phing.tasks.ext.simpletest
* @since 2.2.0
*/
-class SimpleTestFormatterElement extends FormatterElement
+class SimpleTestFormatterElement
{
+ protected $formatter = NULL;
+
+ protected $type = "";
+
+ protected $useFile = true;
+
+ protected $toDir = ".";
+
+ protected $outfile = "";
+
function setType($type)
{
$this->type = $type;
if ($this->type == "xml")
{
- $destFile = new PhingFile($this->toDir, 'testsuites.xml');
- //$this->formatter = new SimpleTestXmlResultFormatter();
+ //$destFile = new PhingFile($this->toDir, 'testsuites.xml');
+ $this->formatter = new SimpleTestXmlResultFormatter();
}
else
if ($this->type == "plain")
@@ -58,5 +68,59 @@ class SimpleTestFormatterElement extends FormatterElement
throw new BuildException("Formatter '" . $this->type . "' not implemented");
}
}
+
+ function setClassName($className)
+ {
+ $classNameNoDot = Phing::import($className);
+
+ $this->formatter = new $classNameNoDot();
+ }
+
+ function setUseFile($useFile)
+ {
+ $this->useFile = $useFile;
+ }
+
+ function getUseFile()
+ {
+ return $this->useFile;
+ }
+
+ function setToDir($toDir)
+ {
+ $this->toDir = $toDir;
+ }
+
+ function getToDir()
+ {
+ return $this->toDir;
+ }
+
+ function setOutfile($outfile)
+ {
+ $this->outfile = $outfile;
+ }
+
+ function getOutfile()
+ {
+ if ($this->outfile)
+ {
+ return $this->outfile;
+ }
+ else
+ {
+ return $this->formatter->getPreferredOutfile() . $this->getExtension();
+ }
+ }
+
+ function getExtension()
+ {
+ return $this->formatter->getExtension();
+ }
+
+ function getFormatter()
+ {
+ return $this->formatter;
+ }
}
?> \ No newline at end of file
diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php
index f84ca815..688e2fe6 100644
--- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php
+++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php
@@ -32,12 +32,12 @@ require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php';
class SimpleTestPlainResultFormatter extends SimpleTestResultFormatter
{
private $inner = "";
-
+
function getExtension()
{
return ".txt";
}
-
+
function getPreferredOutfile()
{
return "testresults";
@@ -46,18 +46,18 @@ class SimpleTestPlainResultFormatter extends SimpleTestResultFormatter
function paintCaseStart($test_name)
{
parent::paintCaseStart($test_name);
-
+
$this->inner = "";
}
-
+
function paintCaseEnd($test_name)
{
parent::paintCaseEnd($test_name);
-
+
/* Only count suites where more than one test was run */
if ($this->getRunCount())
{
- $sb.= "Testsuite: $test_name\n";
+ $sb = "Testsuite: $test_name\n";
$sb.= "Tests run: " . $this->getRunCount();
$sb.= ", Failures: " . $this->getFailureCount();
$sb.= ", Errors: " . $this->getErrorCount();
@@ -75,21 +75,21 @@ class SimpleTestPlainResultFormatter extends SimpleTestResultFormatter
function paintError($message)
{
parent::paintError($message);
-
+
$this->formatError("ERROR", $message);
}
function paintFail($message)
{
parent::paintFail($message);
-
+
$this->formatError("FAILED", $message);
}
private function formatError($type, $message)
{
$this->inner.= $this->getTestName() . " " . $type . "\n";
- $this->inner.= $message . "\n";
+ $this->inner.= $message . "\n";
}
}
?> \ No newline at end of file
diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php
index 7f94892f..4583cf27 100644
--- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php
+++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php
@@ -19,7 +19,7 @@
* <http://phing.info>.
*/
-require_once 'simpletest/scorer.php';
+//require_once 'simpletest/scorer.php';
require_once 'phing/system/io/Writer.php';
@@ -34,25 +34,25 @@ require_once 'phing/system/io/Writer.php';
abstract class SimpleTestResultFormatter extends SimpleReporter
{
protected $out = NULL;
-
+
protected $project = NULL;
-
+
private $timer = NULL;
private $runCount = 0;
-
+
private $failureCount = 0;
-
- private $errorCount = 0;
+
+ private $errorCount = 0;
private $currentTest = "";
-
+
/**
* Sets the writer the formatter is supposed to write its results to.
*/
function setOutput(Writer $out)
{
- $this->out = $out;
+ $this->out = $out;
}
/**
@@ -74,56 +74,56 @@ abstract class SimpleTestResultFormatter extends SimpleReporter
{
$this->project = $project;
}
-
+
function getPreferredOutfile()
{
return "";
}
-
+
function paintMethodStart($test_name)
{
parent::paintMethodStart($test_name);
-
+
$this->currentTest = $test_name;
}
-
+
function paintMethodEnd($test_name)
{
parent::paintMethodEnd($test_name);
-
+
$this->runCount++;
}
-
+
function paintCaseStart($test_name)
{
parent::paintCaseStart($test_name);
-
+
$this->runCount = 0;
$this->failureCount = 0;
$this->errorCount = 0;
-
+
$this->timer = new Timer();
$this->timer->start();
}
-
+
function paintCaseEnd($test_name)
{
parent::paintCaseEnd($test_name);
-
+
$this->timer->stop();
}
function paintError($message)
{
parent::paintError($message);
-
+
$this->errorCount++;
}
function paintFail($message)
{
parent::paintFail($message);
-
+
$this->failureCount++;
}
@@ -131,22 +131,22 @@ abstract class SimpleTestResultFormatter extends SimpleReporter
{
return $this->runCount;
}
-
+
function getFailureCount()
{
return $this->failureCount;
}
-
+
function getErrorCount()
{
return $this->errorCount;
}
-
+
function getTestName()
{
return $this->currentTest;
}
-
+
function getElapsedTime()
{
if ($this->timer)
diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php
index 79494bc9..bd691374 100644
--- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php
+++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php
@@ -34,11 +34,11 @@ class SimpleTestSummaryResultFormatter extends SimpleTestResultFormatter
function paintCaseEnd($test_name)
{
parent::paintCaseEnd($test_name);
-
+
/* Only count suites where more than one test was run */
if ($this->getRunCount())
{
- $sb.= "Tests run: " . $this->getRunCount();
+ $sb= "Tests run: " . $this->getRunCount();
$sb.= ", Failures: " . $this->getFailureCount();
$sb.= ", Errors: " . $this->getErrorCount();
$sb.= ", Time elapsed: " . $this->getElapsedTime();
diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php
index 6aede68f..e32c31c6 100644
--- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php
+++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php
@@ -41,6 +41,7 @@ class SimpleTestTask extends Task
private $errorproperty;
private $printsummary = false;
private $testfailed = false;
+ private $filesets=array();
/**
* Initialize Task.
@@ -49,29 +50,24 @@ class SimpleTestTask extends Task
* because we may want this class to be loaded w/o triggering an error.
*/
function init() {
- @include_once 'simpletest/scorer.php';
-
+
if (!class_exists('SimpleReporter')) {
throw new BuildException("SimpleTestTask depends on SimpleTest package being installed.", $this->getLocation());
}
-
- require_once 'simpletest/reporter.php';
- require_once 'simpletest/xml.php';
- require_once 'simpletest/test_case.php';
require_once 'phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php';
require_once 'phing/tasks/ext/simpletest/SimpleTestFormatterElement.php';
}
-
+
function setFailureproperty($value)
{
$this->failureproperty = $value;
}
-
+
function setErrorproperty($value)
{
$this->errorproperty = $value;
}
-
+
function setHaltonerror($value)
{
$this->haltonerror = $value;
@@ -86,7 +82,7 @@ class SimpleTestTask extends Task
{
$this->printsummary = $printsummary;
}
-
+
/**
* Add a new formatter to all tests of this task.
*
@@ -144,14 +140,14 @@ class SimpleTestTask extends Task
function main()
{
$group = new GroupTest();
-
+
$filenames = $this->getFilenames();
-
+
foreach ($filenames as $testfile)
{
$group->addTestFile($testfile);
}
-
+
if ($this->printsummary)
{
$fe = new SimpleTestFormatterElement();
@@ -159,7 +155,7 @@ class SimpleTestTask extends Task
$fe->setUseFile(false);
$this->formatters[] = $fe;
}
-
+
foreach ($this->formatters as $fe)
{
$formatter = $fe->getFormatter();
@@ -168,7 +164,7 @@ class SimpleTestTask extends Task
if ($fe->getUseFile())
{
$destFile = new PhingFile($fe->getToDir(), $fe->getOutfile());
-
+
$writer = new FileWriter($destFile->getAbsolutePath());
$formatter->setOutput($writer);
@@ -178,39 +174,39 @@ class SimpleTestTask extends Task
$formatter->setOutput($this->getDefaultOutput());
}
}
-
+
$this->execute($group);
-
+
if ($this->testfailed)
{
throw new BuildException("One or more tests failed");
}
}
-
+
private function execute($suite)
{
$counter = new SimpleTestCountResultFormatter();
$reporter = new MultipleReporter();
$reporter->attachReporter($counter);
-
+
foreach ($this->formatters as $fe)
{
$formatter = $fe->getFormatter();
$reporter->attachReporter($formatter);
- }
-
+ }
+
$suite->run($reporter);
-
+
$retcode = $counter->getRetCode();
-
+
if ($retcode == SimpleTestCountResultFormatter::ERRORS)
{
if ($this->errorproperty)
{
$this->project->setNewProperty($this->errorproperty, true);
}
-
+
if ($this->haltonerror)
{
$this->testfailed = true;
@@ -222,7 +218,7 @@ class SimpleTestTask extends Task
{
$this->project->setNewProperty($this->failureproperty, true);
}
-
+
if ($this->haltonfailure)
{
$this->testfailed = true;
diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php
new file mode 100644
index 00000000..66c4ccd8
--- /dev/null
+++ b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php
@@ -0,0 +1,154 @@
+<?php
+/**
+ * $Id: SimpleTestPlainResultFormatter.php 59 2006-04-28 14:49:47Z mrook $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php';
+
+/**
+ * Prints plain text output of the test to a specified Writer.
+ *
+ * @author Michiel Rook <michiel@trendserver.nl>
+ * @version $Id: SimpleTestPlainResultFormatter.php 59 2006-04-28 14:49:47Z mrook $
+ * @package phing.tasks.ext.simpletest
+ * @since 2.2.0
+ */
+class SimpleTestXmlResultFormatter extends SimpleTestResultFormatter
+{
+ private $results=array();
+ private $currentSuite;
+ private $currentTest;
+ private $methodCounts=0;
+ private $methodTime=0;
+
+ function paintFooter($test_name)
+ {
+ if($test_name=='GroupTest')
+ $this->printXml($test_name);
+ }
+
+ protected function printXml($test_name)
+ {
+ $suites = $this->printXmlSuites($this->results);
+$content = <<<EOD
+<?xml version="1.0" encoding="UTF-8"?>
+<testsuites total="{$this->getRunCount()}" name="{$test_name}">
+$suites
+</testsuites>
+EOD;
+ $this->out->write($content);
+ }
+
+ protected function printXmlSuites($results)
+ {
+ $contents = '';
+ foreach($results as $suiteName => $suite)
+ {
+ $tests = $this->printXmlTests($suite['tests'],$suiteName);
+$contents .= <<<EOD
+<testsuite name="{$suiteName}" tests="{$suite['total']}" failures="{$suite['failures']}" errors="{$suite['errors']}" time="{$suite['time']}">
+ $tests
+</testsuite>
+EOD;
+ }
+ return $contents;
+ }
+
+ protected function printXmlTests($tests,$suiteName)
+ {
+ $contents = '';
+ foreach($tests as $name => $result)
+ {
+ if(count($result['results'])==0)
+ {
+ $contents .= <<<EOD
+<testcase name="{$name}" class="{$suiteName}" result="success" time="{$result['time']}"/>
+EOD;
+ }
+ else
+ {
+ $type = strtolower($result['results']['type']);
+ $message = htmlspecialchars($result['results']['message']);
+$contents .= <<<EOD
+<testcase name="{$name}" class="{$suiteName}" result="{$type}" time="{$result['time']}">
+ <{$type}>$message</{$type}>
+</testcase>
+EOD;
+ }
+ }
+ return $contents;
+ }
+
+ function paintCaseStart($test_name)
+ {
+ parent::paintCaseStart($test_name);
+ $this->results[$test_name] = array('tests'=>array());
+ $this->currentSuite=$test_name;
+ $this->methodCounts=0;
+ }
+
+ function paintCaseEnd($test_name)
+ {
+ parent::paintCaseEnd($test_name);
+ $details = array(
+ 'total' => $this->methodCounts,
+ 'failures' => $this->getFailureCount(),
+ 'errors' => $this->getErrorCount(),
+ 'time' => $this->getElapsedTime());
+
+ $this->results[$test_name] = array_merge($this->results[$test_name],$details);
+ }
+
+ function paintMethodStart($test_name)
+ {
+ $this->currentTest=$test_name;
+ parent::paintMethodStart($test_name);
+ $this->results[$this->currentSuite]['tests'][$test_name]['results'] = array();
+ $this->methodCounts++;
+ $this->methodTime = new Timer();
+ $this->methodTime->start();
+ }
+
+ function paintMethodEnd($test_name)
+ {
+ parent::paintMethodEnd($test_name);
+ $this->methodTime->stop();
+ $this->results[$this->currentSuite]['tests'][$test_name]['time'] = $this->methodTime->getElapsedTime();
+ }
+
+ function paintError($message)
+ {
+ parent::paintError($message);
+ $this->formatError("ERROR", $message);
+ }
+
+ function paintFail($message)
+ {
+ parent::paintFail($message);
+ $this->formatError("FAILED", $message);
+ }
+
+ private function formatError($type, $message)
+ {
+ $result = array('type'=>$type, 'message' => $message);
+ $this->results[$this->currentSuite]['tests'][$this->currentTest]['results'] =
+ $result;
+ }
+}
+?> \ No newline at end of file
diff --git a/buildscripts/phing/tasks/PradoSimpleTestTask.php b/buildscripts/phing/tasks/PradoSimpleTestTask.php
new file mode 100644
index 00000000..4d6317b5
--- /dev/null
+++ b/buildscripts/phing/tasks/PradoSimpleTestTask.php
@@ -0,0 +1,40 @@
+<?php
+require_once 'phing/Task.php';
+require_once 'phing/tasks/ext/simpletest/SimpleTestTask.php';
+
+/**
+ * Task to run PRADO unit tests
+ */
+class PradoSimpleTestTask extends SimpleTestTask
+{
+ private $_appdir;
+
+ public function setAppdir($value)
+ {
+ $this->_appdir=$value;
+ }
+
+ function init()
+ {
+ $tools= realpath(dirname(__FILE__).'/../../../tests/test_tools/');
+ include_once "$tools/unit_tests.php";
+
+ if (!class_exists('SimpleReporter',false))
+ throw new BuildException("SimpleTestTask depends on SimpleTest package being installed.", $this->getLocation());
+
+ require_once 'phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php';
+ require_once 'phing/tasks/ext/simpletest/SimpleTestFormatterElement.php';
+ }
+
+ function main()
+ {
+ if($this->_appdir)
+ {
+ $app = new TShellApplication($this->_appdir);
+ $app->run();
+ }
+ parent::main();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/prado-cli.php b/framework/prado-cli.php
index efefca3d..652f0548 100755
--- a/framework/prado-cli.php
+++ b/framework/prado-cli.php
@@ -1,4 +1,3 @@
-#!/usr/bin/env php
<?php
/**
@@ -190,7 +189,7 @@ EOD;
protected function initializePradoApplication($directory)
{
$app_dir = realpath($directory.'/protected/');
- if($app_dir !== false)
+ if($app_dir !== false && is_dir($app_dir))
{
if(Prado::getApplication()===null)
{
@@ -482,7 +481,7 @@ class PradoCommandLineUnitTest extends PradoCommandLineAction
public function performAction($args)
{
$dir = realpath($args[1]);
- if($dir !== false)
+ if($dir !== false && is_dir($dir))
$this->runUnitTests($dir,$args);
else
echo '** Unable to find directory "'.$args[1]."\".\n";
@@ -524,7 +523,7 @@ class PradoCommandLineUnitTest extends PradoCommandLineAction
protected function getAppDir($dir)
{
$app_dir = realpath($dir.'/protected');
- if($app_dir !== false)
+ if($app_dir !== false && is_dir($app_dir))
return $app_dir;
return realpath($dir.'/../protected');
}
@@ -532,7 +531,7 @@ class PradoCommandLineUnitTest extends PradoCommandLineAction
protected function getTestDir($dir)
{
$test_dir = realpath($dir.'/unit');
- if($test_dir !== false)
+ if($test_dir !== false && is_dir($test_dir))
return $test_dir;
return realpath($dir.'/tests/unit/');
}
@@ -614,7 +613,7 @@ class PradoCommandLineActiveRecordGen extends PradoCommandLineAction
{
if(is_dir($dir))
return realpath($dir);
- if(false !== ($app_dir = realpath($dir.'/protected/')))
+ if(false !== ($app_dir = realpath($dir.'/protected/')) && is_dir($app_dir))
return $app_dir;
echo '** Unable to find directory "'.$dir."\".\n";
return false;
@@ -622,9 +621,9 @@ class PradoCommandLineActiveRecordGen extends PradoCommandLineAction
protected function getXmlFile($app_dir)
{
- if(false !== ($xml = realpath($app_dir.'/application.xml')))
+ if(false !== ($xml = realpath($app_dir.'/application.xml')) && is_file($xml))
return $xml;
- if(false !== ($xml = realpath($app_dir.'/protected/application.xml')))
+ if(false !== ($xml = realpath($app_dir.'/protected/application.xml')) && is_file($xml))
return $xml;
echo '** Unable to find application.xml in '.$app_dir."\n";
return false;
@@ -650,7 +649,7 @@ class PradoCommandLineActiveRecordGen extends PradoCommandLineAction
if(is_file($namespace) && strpos($namespace, $app_dir)===0)
return $namespace;
$file = Prado::getPathOfNamespace($namespace, ".php");
- if($file !== null && false !== ($path = realpath(dirname($file))))
+ if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path))
{
if(strpos($path, $app_dir)===0)
return $file;
diff --git a/prado-cli b/prado-cli
new file mode 100644
index 00000000..02751316
--- /dev/null
+++ b/prado-cli
@@ -0,0 +1,3 @@
+#!/usr/bin/env php
+<?php
+include(dirname(__FILE__).'/framework/prado-cli.php'); \ No newline at end of file
diff --git a/prado-cli.bat b/prado-cli.bat
new file mode 100644
index 00000000..b3fe9f3e
--- /dev/null
+++ b/prado-cli.bat
@@ -0,0 +1,39 @@
+@echo off
+
+rem *************************************************************
+rem ** CLI for Windows based systems (based on phing.bat)
+rem *************************************************************
+
+rem This script will do the following:
+rem - check for PHP_COMMAND env, if found, use it.
+rem - if not found detect php, if found use it, otherwise err and terminate
+
+if "%OS%"=="Windows_NT" @setlocal
+
+rem %~dp0 is expanded pathname of the current script under NT
+set PRADO_DIR=%~dp0
+
+goto init
+
+:init
+
+if "%PHP_COMMAND%" == "" goto no_phpcommand
+
+IF EXIST ".\framework\prado-cli.php" (
+ %PHP_COMMAND% -d html_errors=off -d open_basedir= -q ".\framwork\prado-cli.php" %1 %2 %3 %4 %5 %6 %7 %8 %9
+) ELSE (
+ %PHP_COMMAND% -d html_errors=off -d open_basedir= -q "%PRADO_DIR%\framework\prado-cli.php" %1 %2 %3 %4 %5 %6 %7 %8 %9
+)
+goto cleanup
+
+:no_phpcommand
+rem echo ------------------------------------------------------------------------
+rem echo WARNING: Set environment var PHP_COMMAND to the location of your php.exe
+rem echo executable (e.g. C:\PHP\php.exe). (assuming php.exe on PATH)
+rem echo ------------------------------------------------------------------------
+set PHP_COMMAND=php.exe
+goto init
+
+:cleanup
+if "%OS%"=="Windows_NT" @endlocal
+rem pause