Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moving recoreder from extensions to core

  • Loading branch information...
commit cd6fdd6dd05c25f7a287a8c2b42d229ce21913e2 1 parent 63c7dc8
lastcraft authored
View
16 HELP_MY_TESTS_DONT_WORK_ANYMORE
@@ -6,21 +6,17 @@ dramatic changes are in the alpha releases. Here is a list of possible
problems and their fixes...
assertText() no longer finds a string inside a <script> tag
-===========================================================
-
+-----------------------------------------------------------
The assertText() method is intended to match only visible,
human-readable text on the web page. Therefore, the contents of script
tags should not be matched by this assertion. However there was a bug
in the text normalisation code of simpletest which meant that <script>
tags spanning multiple lines would not have their content stripped
-out.
-
-If you want to check the content of a <script> tag, use
+out. If you want to check the content of a <script> tag, use
assertPattern(), or write a custom expectation.
Overloaded method not working
-----------------------------
-
All protected and private methods had underscores
removed. This means that any private/protected methods that
you overloaded with those names need to be updated.
@@ -35,8 +31,8 @@ with parent::__construct().
Custom CSS in HtmlReporter not being applied
--------------------------------------------
Batch rename of protected and private methods
-means that _getCss() was renamed to getCss();
-replace your function definition accordingly.
+means that _getCss() was renamed to getCss().
+Please rename your method and it should work again.
setReturnReference() throws errors in E_STRICT
----------------------------------------------
@@ -66,7 +62,7 @@ These methods were always a bit weird anyway, and
the new parsing of the base tag makes them more so.
They have been replaced with getUrls() instead. If
you want the old functionality then simply chop
-off the current domain from getUrl().
+off the current domain from getUrls().
Method setWildcard() removed in mocks
-------------------------------------
@@ -103,7 +99,7 @@ getTransferError() call on the web tester to see if
there was a socket level error in a fetch. This check
is now always carried out by the WebTestCase unless
the fetch is prefaced with WebTestCase::ignoreErrors().
-The ignore directive only lasts for test case fetching
+The ignore directive only lasts for the next fetching
action such as get() and click().
No method SimpleTestOptions::ignore()
View
8 docs/source/en/reporter_documentation.xml
@@ -5,7 +5,7 @@
<content>
<introduction>
<p>
- SimpleTest pretty much follows the MVC pattern
+ SimpleTest pretty much follows the MVC-ish pattern
(Model-View-Controller).
The reporter classes are the view and the model is your
test cases and their hiearchy.
@@ -186,7 +186,7 @@ class HtmlReporter extends SimpleReporter {
One simple modification is to get the HtmlReporter to display
the passes as well as the failures and errors...
<php><![CDATA[
-<strong>class ShowPasses extends HtmlReporter {
+<strong>class ReporterShowingPasses extends HtmlReporter {
function paintPass($message) {
parent::paintPass($message);
@@ -237,7 +237,7 @@ class HtmlReporter extends SimpleReporter {
A do nothing display, a blank canvas for your own creation, would
be...
<php><![CDATA[
-<strong>require_once('simpletest/simple_test.php');</strong>
+<strong>require_once('simpletest/simpletest.php');</strong>
class MyDisplay extends SimpleReporter {<strong>
</strong>
@@ -412,7 +412,7 @@ require_once('../reporter.php');
$test_url = ...;
$dry_url = ...;
-$test = &new TestSuite('Remote tests');
+$test = new TestSuite('Remote tests');
$test->addTest(<strong>new RemoteTestCase($test_url, $dry_url)</strong>);
$test->run(new HtmlReporter());
?>
View
3  extensions/dom_tester.php
@@ -116,5 +116,4 @@ function assertElementsBySelector($selector, $elements, $message = '%s') {
$message);
}
}
-
-?>
+?>
View
4 extensions/junit_xml_reporter.php
@@ -22,7 +22,6 @@
class JUnitXMLReporter extends SimpleReporter {
function __construct() {
parent::__construct();
-
$this->doc = new DOMDocument();
$this->doc->loadXML('<testsuite/>');
$this->root = $this->doc->documentElement;
@@ -119,5 +118,4 @@ function terminateAbnormally($message) {
$this->currCase->appendChild($ch);
}
}
-?>
-
+?>
View
62 extensions/recorder.php
@@ -1,62 +0,0 @@
-<?php
-/**
- * base include file for SimpleTest
- * @package SimpleTest
- * @subpackage Extensions
- * @version $Id$
- */
-
-/**
- * include other SimpleTest class files
- */
-require_once(dirname(__FILE__) . '/../scorer.php');
-
-/**
- * Array-based test recorder. Returns an array
- * with timestamp, status, test name and message for each pass and failure.
- *
- * This code is made available under the same terms as SimpleTest. It is based
- * off of code that Rene vd O originally published in patch [ 1594212 ]
- * on the SimpleTest patches tracker.
- *
- * @author Rene vd O (original code)
- * @author Perrick Penet
- * @package SimpleTest
- * @subpackage Extensions
- */
-class Recorder extends SimpleReporter {
- var $results;
-
- function __construct() {
- parent::__construct();
- $this->results = array();
- }
-
- function paintPass($message) {
- parent::paintPass($message);
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- $test = implode("->", $breadcrumb);
-
- $result["time"] = time();
- $result["status"] = "Passed";
- $result["test"] = $test;
- $result["message"] = $message;
- $this->results[] = $result;
- }
-
- function paintFail($message) {
- parent::paintFail($message);
- $breadcrumb = $this->getTestList();
- array_shift($breadcrumb);
- $test = implode("->", $breadcrumb);
-
- $result["time"] = time();
- $result["status"] = "Failed";
- $result["test"] = $test;
- $result["message"] = $message;
- $this->results[] = $result;
- }
-}
-
-?>
View
21 extensions/recorder/test/test.php
@@ -1,30 +1,27 @@
<?php
// $Id: test.php 1500 2007-04-29 14:33:31Z pp11 $
require_once dirname(__FILE__) . '/../../../autorun.php';
-require_once(dirname(__FILE__) . '/../../recorder.php');
+require_once(dirname(__FILE__) . '/../../../recorder.php');
class TestOfRecorder extends UnitTestCase {
function testContentOfRecorderWithOnePassAndOneFailure() {
$test = new TestSuite();
$test->addFile(dirname(__FILE__) . '/sample.php');
- $recorder = new Recorder();
+ $recorder = new Recorder(new SimpleReporter());
$test->run($recorder);
$this->assertEqual(count($recorder->results), 2);
$d = '[\\\\\\/]'; // backslash or slash
- $this->assertEqual(count($recorder->results[0]), 4);
- $this->assertPattern("/".substr(time(), 9)."/", $recorder->results[0]['time']);
- $this->assertEqual($recorder->results[0]['status'], "Passed");
- $this->assertPattern("/sample\.php->SampleTestForRecorder->testTrueIsTrue/i", $recorder->results[0]['test']);
- $this->assertPattern("/ at \[.*recorder{$d}test{$d}sample\.php line 7\]/", $recorder->results[0]['message']);
+ $this->assertIsA($recorder->results[0], 'SimpleResultOfPass');
+ $this->assertEqual('testTrueIsTrue', array_pop($recorder->results[0]->breadcrumb));
+ $this->assertPattern("/ at \[.*recorder{$d}test{$d}sample\.php line 7\]/", $recorder->results[0]->message);
- $this->assertEqual(count($recorder->results[1]), 4);
- $this->assertPattern("/".substr(time(), 9)."/", $recorder->results[1]['time']);
- $this->assertEqual($recorder->results[1]['status'], "Failed");
- $this->assertPattern("/sample\.php->SampleTestForRecorder->testFalseIsTrue/i", $recorder->results[1]['test']);
- $this->assertPattern("/Expected false, got \[Boolean: true\] at \[.*recorder{$d}test{$d}sample\.php line 11\]/", $recorder->results[1]['message']);
+ $this->assertIsA($recorder->results[1], 'SimpleResultOfFail');
+ $this->assertEqual('testFalseIsTrue', array_pop($recorder->results[1]->breadcrumb));
+ $this->assertPattern("/Expected false, got \[Boolean: true\] at \[.*recorder{$d}test{$d}sample\.php line 11\]/",
+ $recorder->results[1]->message);
}
}
?>
View
8 extensions/testdox.php
@@ -5,13 +5,6 @@
* @subpackage Extensions
* @version $Id$
*/
-
-/**
- * base include file for SimpleTest
- * @package SimpleTest
- * @subpackage Extensions
- * @version $Id$
- */
class TestDoxReporter extends SimpleReporter
{
var $_test_case_pattern = '/^TestOf(.*)$/';
@@ -39,7 +32,6 @@ function paintMethodStart($test_name) {
return;
}
$test_name = $matches[1];
-
$test_name = preg_replace('/([A-Z])([A-Z])/', '$1 $2', $test_name);
echo '- ' . strtolower(preg_replace('/([a-zA-Z])([A-Z0-9])/', '$1 $2', $test_name));
}
View
85 recorder.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * base include file for SimpleTest
+ * @package SimpleTest
+ * @subpackage Extensions
+ * @author Rene vd O (original code)
+ * @author Perrick Penet
+ * @author Marcus Baker
+ * @version $Id$
+ */
+
+/**
+ * include other SimpleTest class files
+ */
+require_once(dirname(__FILE__) . '/scorer.php');
+
+/**
+ * A single test result.
+ */
+abstract class SimpleResult {
+ public $time;
+ public $breadcrumb;
+ public $message;
+
+ /**
+ * Records the test result as public members.
+ * @param array $breadcrumb Test stack at the time of the event.
+ * @param string $message The messsage to the human.
+ */
+ function __construct($breadcrumb, $message) {
+ list($this->time, $this->breadcrumb, $this->message) =
+ array(time(), $breadcrumb, $message);
+ }
+}
+
+/** A single pass captured for later. */
+class SimpleResultOfPass extends SimpleResult { }
+
+/** A single failure captured for later. */
+class SimpleResultOfFail extends SimpleResult { }
+
+/** A single exception captured for later. */
+class SimpleResultOfException extends SimpleResult { }
+
+/**
+ * Array-based test recorder. Returns an array
+ * with timestamp, status, test name and message for each pass and failure.
+ */
+class Recorder extends SimpleReporterDecorator {
+ public $results = array();
+
+ /**
+ * Stashes the pass as a SimpleResultOfPass
+ * for later retrieval.
+ * @param string $message Pass message to be displayed
+ * eventually.
+ */
+ function paintPass($message) {
+ parent::paintPass($message);
+ $this->results[] = new SimpleResultOfPass(parent::getTestList(), $message);
+ }
+
+ /**
+ * Stashes the fail as a SimpleResultOfFail
+ * for later retrieval.
+ * @param string $message Failure message to be displayed
+ * eventually.
+ */
+ function paintFail($message) {
+ parent::paintFail($message);
+ $this->results[] = new SimpleResultOfFail(parent::getTestList(), $message);
+ }
+
+ /**
+ * Stashes the exception as a SimpleResultOfException
+ * for later retrieval.
+ * @param string $message Exception message to be displayed
+ * eventually.
+ */
+ function paintException($message) {
+ parent::paintException($message);
+ $this->results[] = new SimpleResultOfException(parent::getTestList(), $message);
+ }
+}
+?>
View
1  reporter.php
@@ -105,7 +105,6 @@ function paintFooter($test_name) {
* top level test.
* @param string $message Failure message displayed in
* the context of the other tests.
- * @access public
*/
function paintFail($message) {
parent::paintFail($message);
View
21 scorer.php
@@ -255,8 +255,7 @@ function __construct() {
}
/**
- * Gets the formatter for privateiables and other small
- * generic data items.
+ * Gets the formatter for small generic data items.
* @return SimpleDumper Formatter.
* @access public
*/
@@ -448,8 +447,22 @@ function getStatus() {
}
/**
+ * The nesting of the test cases so far. Not
+ * all reporters have this facility.
+ * @return array Test list if accessible.
+ * @access public
+ */
+ function getTestList() {
+ if (method_exists($this->reporter, 'getTestList')) {
+ return $this->reporter->getTestList();
+ } else {
+ return array();
+ }
+ }
+
+ /**
* The reporter has a veto on what should be run.
- * @param string $test_case_name name of test case.
+ * @param string $test_case_name Name of test case.
* @param string $method Name of test method.
* @return boolean True if test should be run.
* @access public
@@ -459,7 +472,7 @@ function shouldInvoke($test_case_name, $method) {
}
/**
- * Can wrap the invoker in preperation for running
+ * Can wrap the invoker in preparation for running
* a test.
* @param SimpleInvoker $invoker Individual test runner.
* @return SimpleInvoker Wrapped test runner.
View
6 simpletest.php
@@ -9,11 +9,7 @@
/**#@+
* include SimpleTest files
*/
-if (version_compare(phpversion(), '5') >= 0) {
- require_once(dirname(__FILE__) . '/reflection_php5.php');
-} else {
- require_once(dirname(__FILE__) . '/reflection_php4.php');
-}
+require_once(dirname(__FILE__) . '/reflection_php5.php');
require_once(dirname(__FILE__) . '/default_reporter.php');
require_once(dirname(__FILE__) . '/compatibility.php');
/**#@-*/
Please sign in to comment.
Something went wrong with that request. Please try again.