aboutsummaryrefslogtreecommitdiff
path: root/vendors/simpletest/detached.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-02 18:40:04 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-02 18:40:04 +0000
commit322bb9cd2be9e51422cb2b82684692e825c2bfb7 (patch)
tree1e8e75c1ff0c47d6eda9db114a13dfa2b83adf72 /vendors/simpletest/detached.php
parent4ffb02ad9c1b95013a0fbf97cefde827600ecc3f (diff)
downloadelgg-322bb9cd2be9e51422cb2b82684692e825c2bfb7.tar.gz
elgg-322bb9cd2be9e51422cb2b82684692e825c2bfb7.tar.bz2
Added simpletest and start of unit tests.
git-svn-id: http://code.elgg.org/elgg/trunk@3503 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'vendors/simpletest/detached.php')
-rwxr-xr-xvendors/simpletest/detached.php96
1 files changed, 96 insertions, 0 deletions
diff --git a/vendors/simpletest/detached.php b/vendors/simpletest/detached.php
new file mode 100755
index 000000000..e323d8cd5
--- /dev/null
+++ b/vendors/simpletest/detached.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * base include file for SimpleTest
+ * @package SimpleTest
+ * @subpackage UnitTester
+ * @version $Id: detached.php 1723 2008-04-08 00:34:10Z lastcraft $
+ */
+
+/**#@+
+ * include other SimpleTest class files
+ */
+require_once(dirname(__FILE__) . '/xml.php');
+require_once(dirname(__FILE__) . '/shell_tester.php');
+/**#@-*/
+
+/**
+ * Runs an XML formated test in a separate process.
+ * @package SimpleTest
+ * @subpackage UnitTester
+ */
+class DetachedTestCase {
+ var $_command;
+ var $_dry_command;
+ var $_size;
+
+ /**
+ * Sets the location of the remote test.
+ * @param string $command Test script.
+ * @param string $dry_command Script for dry run.
+ * @access public
+ */
+ function DetachedTestCase($command, $dry_command = false) {
+ $this->_command = $command;
+ $this->_dry_command = $dry_command ? $dry_command : $command;
+ $this->_size = false;
+ }
+
+ /**
+ * Accessor for the test name for subclasses.
+ * @return string Name of the test.
+ * @access public
+ */
+ function getLabel() {
+ return $this->_command;
+ }
+
+ /**
+ * Runs the top level test for this class. Currently
+ * reads the data as a single chunk. I'll fix this
+ * once I have added iteration to the browser.
+ * @param SimpleReporter $reporter Target of test results.
+ * @returns boolean True if no failures.
+ * @access public
+ */
+ function run(&$reporter) {
+ $shell = &new SimpleShell();
+ $shell->execute($this->_command);
+ $parser = &$this->_createParser($reporter);
+ if (! $parser->parse($shell->getOutput())) {
+ trigger_error('Cannot parse incoming XML from [' . $this->_command . ']');
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Accessor for the number of subtests.
+ * @return integer Number of test cases.
+ * @access public
+ */
+ function getSize() {
+ if ($this->_size === false) {
+ $shell = &new SimpleShell();
+ $shell->execute($this->_dry_command);
+ $reporter = &new SimpleReporter();
+ $parser = &$this->_createParser($reporter);
+ if (! $parser->parse($shell->getOutput())) {
+ trigger_error('Cannot parse incoming XML from [' . $this->_dry_command . ']');
+ return false;
+ }
+ $this->_size = $reporter->getTestCaseCount();
+ }
+ return $this->_size;
+ }
+
+ /**
+ * Creates the XML parser.
+ * @param SimpleReporter $reporter Target of test results.
+ * @return SimpleTestXmlListener XML reader.
+ * @access protected
+ */
+ function &_createParser(&$reporter) {
+ return new SimpleTestXmlParser($reporter);
+ }
+}
+?> \ No newline at end of file