diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-04-20 18:34:43 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-04-20 18:34:43 +0000 |
commit | ffc0e93c4eb0555a08f0b58bed0735416e6ba41f (patch) | |
tree | 7f741d0b40124633c5b337dc7210711bfcd4b876 /modules/simpletest/invoker.php | |
parent | af474609e3e80db9ba1d16b9ad2eae89775f51c8 (diff) | |
download | brdo-ffc0e93c4eb0555a08f0b58bed0735416e6ba41f.tar.gz brdo-ffc0e93c4eb0555a08f0b58bed0735416e6ba41f.tar.bz2 |
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
Diffstat (limited to 'modules/simpletest/invoker.php')
-rw-r--r-- | modules/simpletest/invoker.php | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/modules/simpletest/invoker.php b/modules/simpletest/invoker.php new file mode 100644 index 000000000..7944c1b4f --- /dev/null +++ b/modules/simpletest/invoker.php @@ -0,0 +1,119 @@ +<?php +// $Id$ + +/** + * This is called by the class runner to run a + * single test method. Will also run the setUp() + * and tearDown() methods. + * @package SimpleTest + * @subpackage UnitTester + */ +class SimpleInvoker { + var $_test_case; + + /** + * Stashes the test case for later. + * @param SimpleTestCase $test_case Test case to run. + */ + function SimpleInvoker(&$test_case) { + $this->_test_case = &$test_case; + } + + /** + * Accessor for test case being run. + * @return SimpleTestCase Test case. + * @access public + */ + function &getTestCase() { + return $this->_test_case; + } + + /** + * Runs test level set up. Used for changing + * the mechanics of base test cases. + * @param string $method Test method to call. + * @access public + */ + function before($method) { + $this->_test_case->before($method); + } + + /** + * Invokes a test method and buffered with setUp() + * and tearDown() calls. + * @param string $method Test method to call. + * @access public + */ + function invoke($method) { + $this->_test_case->setUp(); + $this->_test_case->$method(); + $this->_test_case->tearDown(); + } + + /** + * Runs test level clean up. Used for changing + * the mechanics of base test cases. + * @param string $method Test method to call. + * @access public + */ + function after($method) { + $this->_test_case->after($method); + } +} + +/** + * Do nothing decorator. Just passes the invocation + * straight through. + * @package SimpleTest + * @subpackage UnitTester + */ +class SimpleInvokerDecorator { + var $_invoker; + + /** + * Stores the invoker to wrap. + * @param SimpleInvoker $invoker Test method runner. + */ + function SimpleInvokerDecorator(&$invoker) { + $this->_invoker = &$invoker; + } + + /** + * Accessor for test case being run. + * @return SimpleTestCase Test case. + * @access public + */ + function &getTestCase() { + return $this->_invoker->getTestCase(); + } + + /** + * Runs test level set up. Used for changing + * the mechanics of base test cases. + * @param string $method Test method to call. + * @access public + */ + function before($method) { + $this->_invoker->before($method); + } + + /** + * Invokes a test method and buffered with setUp() + * and tearDown() calls. + * @param string $method Test method to call. + * @access public + */ + function invoke($method) { + $this->_invoker->invoke($method); + } + + /** + * Runs test level clean up. Used for changing + * the mechanics of base test cases. + * @param string $method Test method to call. + * @access public + */ + function after($method) { + $this->_invoker->after($method); + } +} |