Browse files

updated simpletest to version 1.1.0

  • Loading branch information...
1 parent 16d13eb commit e4916c007d7dd8bdc36458f86ae5bd0b38fdc5f6 @mikz mikz committed Jun 7, 2012
Showing with 5,979 additions and 4,890 deletions.
  1. +53 −2 lib/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE
  2. 0 lib/simpletest/LICENSE
  3. +35 −41 lib/simpletest/README
  4. +1 −1 lib/simpletest/VERSION
  5. +224 −0 lib/simpletest/arguments.php
  6. +45 −46 lib/simpletest/authentication.php
  7. +42 −28 lib/simpletest/autorun.php
  8. +217 −171 lib/simpletest/browser.php
  9. +15 −15 lib/simpletest/collector.php
  10. +21 −28 lib/simpletest/compatibility.php
  11. +79 −79 lib/simpletest/cookies.php
  12. +67 −37 lib/simpletest/default_reporter.php
  13. +19 −19 lib/simpletest/detached.php
  14. +43 −20 lib/simpletest/docs/en/authentication_documentation.html
  15. +81 −27 lib/simpletest/docs/en/browser_documentation.html
  16. 0 lib/simpletest/docs/en/docs.css
  17. +74 −20 lib/simpletest/docs/en/expectation_documentation.html
  18. +31 −22 lib/simpletest/docs/en/form_testing_documentation.html
  19. +110 −244 lib/simpletest/docs/en/group_test_documentation.html
  20. +11 −7 lib/simpletest/docs/en/index.html
  21. +514 −401 lib/simpletest/docs/en/mock_objects_documentation.html
  22. +110 −109 lib/simpletest/docs/en/overview.html
  23. +74 −62 lib/simpletest/docs/en/partial_mocks_documentation.html
  24. +144 −47 lib/simpletest/docs/en/reporter_documentation.html
  25. +23 −12 lib/simpletest/docs/en/unit_test_documentation.html
  26. +9 −5 lib/simpletest/docs/en/web_tester_documentation.html
  27. +46 −6 lib/simpletest/docs/fr/authentication_documentation.html
  28. +69 −15 lib/simpletest/docs/fr/browser_documentation.html
  29. 0 lib/simpletest/docs/fr/docs.css
  30. +92 −24 lib/simpletest/docs/fr/expectation_documentation.html
  31. +39 −25 lib/simpletest/docs/fr/form_testing_documentation.html
  32. +127 −260 lib/simpletest/docs/fr/group_test_documentation.html
  33. +9 −5 lib/simpletest/docs/fr/index.html
  34. +702 −547 lib/simpletest/docs/fr/mock_objects_documentation.html
  35. +6 −3 lib/simpletest/docs/fr/overview.html
  36. +72 −57 lib/simpletest/docs/fr/partial_mocks_documentation.html
  37. +154 −58 lib/simpletest/docs/fr/reporter_documentation.html
  38. 0 lib/simpletest/docs/fr/server_stubs_documentation.html
  39. +45 −45 lib/simpletest/docs/fr/unit_test_documentation.html
  40. +8 −4 lib/simpletest/docs/fr/web_tester_documentation.html
  41. +92 −45 lib/simpletest/dumper.php
  42. +70 −70 lib/simpletest/eclipse.php
  43. +215 −118 lib/simpletest/encoding.php
  44. +61 −82 lib/simpletest/errors.php
  45. +39 −11 lib/simpletest/exceptions.php
  46. +230 −141 lib/simpletest/expectation.php
  47. +13 −15 lib/simpletest/extensions/pear_test_case.php
  48. +0 −96 lib/simpletest/extensions/phpunit_test_case.php
  49. +18 −7 lib/simpletest/extensions/testdox.php
  50. +6 −7 lib/simpletest/extensions/testdox/test.php
  51. +106 −100 lib/simpletest/form.php
  52. +121 −125 lib/simpletest/frames.php
  53. +186 −182 lib/simpletest/http.php
  54. +19 −19 lib/simpletest/invoker.php
  55. +519 −459 lib/simpletest/mock_objects.php
  56. +122 −563 lib/simpletest/page.php
  57. +507 −217 lib/simpletest/{parser.php → php_parser.php}
  58. +101 −0 lib/simpletest/recorder.php
  59. +2 −2 lib/simpletest/reflection_php4.php
  60. +51 −45 lib/simpletest/reflection_php5.php
  61. +33 −35 lib/simpletest/remote.php
  62. +57 −59 lib/simpletest/reporter.php
Sorry, we could not display the entire diff because it was too big.
View
55 lib/simpletest/HELP_MY_TESTS_DONT_WORK_ANYMORE 100644 → 100755
@@ -5,13 +5,64 @@ written with earlier versions will fail with the newest ones. The most
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
+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.
+
+Fatal error: Call to undefined method Classname::classname()
+------------------------------------------------------------
+SimpleTest renamed all of its constructors from
+Classname to __construct; derived classes invoking
+their parent constructors should replace parent::Classname()
+with parent::__construct().
+
+Custom CSS in HtmlReporter not being applied
+--------------------------------------------
+Batch rename of protected and private methods
+means that _getCss() was renamed to getCss().
+Please rename your method and it should work again.
+
+setReturnReference() throws errors in E_STRICT
+----------------------------------------------
+Happens when an object is passed by reference.
+This also happens with setReturnReferenceAt().
+If you want to return objects then replace these
+with calls to returns() and returnsAt() with the
+same arguments. This change was forced in the 1.1
+version for E_STRICT compatibility.
+
+assertReference() throws errors in E_STRICT
+-------------------------------------------
+Due to language restrictions you cannot compare
+both variables and objects in E_STRICT mode. Use
+assertSame() in this mode with objects. This change
+was forced the 1.1 version.
+
+Cannot create GroupTest
+-----------------------
+The GroupTest has been renamed TestSuite (see below).
+It was removed completely in 1.1 in favour of this
+name.
+
No method getRelativeUrls() or getAbsoluteUrls()
------------------------------------------------
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
-------------------------------------
@@ -48,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
0 lib/simpletest/LICENSE 100644 → 100755
File mode changed.
View
76 lib/simpletest/README 100644 → 100755
@@ -1,14 +1,16 @@
SimpleTest
==========
-You probably got this package from...
-http://simpletest.sourceforge.net/projects/simpletest/
+
+You probably got this package from:
+
+ http://simpletest.org/en/download.html
If there is no licence agreement with this package please download
a version from the location above. You must read and accept that
licence to use this software. The file is titled simply LICENSE.
What is it? It's a framework for unit testing, web site testing and
-mock objects for PHP 4.2.0+ (and PHP 5.0 to 5.3 without E_STRICT).
+mock objects for PHP 5.0.5+.
If you have used JUnit, you will find this PHP unit testing version very
similar. Also included is a mock objects and server stubs generator.
@@ -21,68 +23,62 @@ A web tester similar in concept to JWebUnit is also included. There is no
JavaScript or tables support, but forms, authentication, cookies and
frames are handled.
-You can see a release schedule at http://www.lastcraft.com/overview.php
+You can see a release schedule at http://simpletest.org/en/overview.html
which is also copied to the documentation folder with this release.
A full PHPDocumenter API documentation exists at
-http://simpletest.sourceforge.net/.
+http://simpletest.org/api/.
-The user interface is minimal
-in the extreme, but a lot of information flows from the test suite.
-After version 1.0 we will release a better web UI, but we are leaving XUL
-and GTk versions to volunteers as everybody has their own opinion
-on a good GUI, and we don't want to discourage development by shipping
-one with the toolkit. YOucan download an Eclipse plug-in separately.
+The user interface is minimal in the extreme, but a lot of information
+flows from the test suite. After version 1.0 we will release a better
+web UI, but we are leaving XUL and GTK versions to volunteers as
+everybody has their own opinion on a good GUI, and we don't want to
+discourage development by shipping one with the toolkit. You can
+download an Eclipse plug-in separately.
-You are looking at a second full release. The unit tests for SimpleTest
-itself can be run here...
+The unit tests for SimpleTest itself can be run here:
-simpletest/test/unit_tests.php
+ test/unit_tests.php
-And tests involving live network connections as well are here...
+And tests involving live network connections as well are here:
-simpletest/test/all_tests.php
+ test/all_tests.php
The full tests will typically overrun the 8Mb limit often allowed
to a PHP process. A workaround is to run the tests on the command
-with a custom php.ini file if you do not have access to your server
-version.
-
-You will have to edit the all_tests.php file if you are accesssing
-the internet through a proxy server. See the comments in all_tests.php
-for instructions.
+with a custom php.ini file or with the switch -dmemory_limit=-1
+if you do not have access to your server version.
-The full tests read some test data from the LastCraft site. If the site
+The full tests read some test data from simpletest.org. If the site
is down or has been modified for a later version then you will get
spurious errors. A unit_tests.php failure on the other hand would be
-very serious. As far as we know we haven't yet managed to check in any
-unit test failures, so please correct us if you find one.
+very serious. Please notify us if you find one.
Even if all of the tests run please verify that your existing test suites
-also function as expected. If they don't see the file...
+also function as expected. The file:
-HELP_MY_TESTS_DONT_WORK_ANYMORE
+ HELP_MY_TESTS_DONT_WORK_ANYMORE
-This contains information on interface changes. It also points out
+...contains information on interface changes. It also points out
deprecated interfaces, so you should read this even if all of
your current tests appear to run.
There is a documentation folder which contains the core reference information
in English and French, although this information is fairly basic.
You can find a tutorial on...
-http://www.lastcraft.com/first_test_tutorial.php
+ http://simpletest.org/en/first_test_tutorial.html
...to get you started and this material will eventually become included
-with the project documentation. A French translation exists at...
+with the project documentation. A French translation exists at:
-http://www.onpk.net/index.php/2005/01/12/254-tutoriel-simpletest-decouvrir-les-tests-unitaires.
+ http://simpletest.org/fr/first_test_tutorial.html
If you download and use, and possibly even extend this tool, please let us
know. Any feedback, even bad, is always welcome and we will work to get
your suggestions into the next release. Ideally please send your
-comments to...
+comments to:
-simpletest-support@lists.sourceforge.net
+ simpletest-support@lists.sourceforge.net
...so that others can read them too. We usually try to respond within 48
hours.
@@ -93,16 +89,14 @@ status of any bugs, but if the bug is recent then it will be fixed in SVN only.
The SVN check-ins always have all the tests passing and so SVN snapshots should
be pretty usable, although the code may not look so good internally.
-Oh, yes. It is called "Simple" because it should be simple to
-use. We intend to add a complete set of tools for a test first
-and "test as you code" type of development. "Simple" does not
-mean "Lite" in this context.
+Oh, and one last thing: SimpleTest is called "Simple" because it should
+be simple to use. We intend to add a complete set of tools for a test
+first and "test as you code" type of development. "Simple" does not mean
+"Lite" in this context.
Thanks to everyone who has sent comments and offered suggestions. They
really are invaluable, but sadly you are too many to mention in full.
Thanks to all on the advanced PHP forum on SitePoint, especially Harry
-Feucks. Early adopters are always an inspiration.
+Fuecks. Early adopters are always an inspiration.
-Marcus Baker, Jason Sweat, Travis Swicegood, Perrick Penet and Edward Z. Yang.
---
-marcus@lastcraft.com
+ -- Marcus Baker, Jason Sweat, Travis Swicegood, Perrick Penet and Edward Z. Yang.
View
2 lib/simpletest/VERSION 100644 → 100755
@@ -1 +1 @@
-1.0.1
+1.1.0
View
224 lib/simpletest/arguments.php
@@ -0,0 +1,224 @@
+<?php
+/**
+ * base include file for SimpleTest
+ * @package SimpleTest
+ * @subpackage UnitTester
+ * @version $Id: dumper.php 1909 2009-07-29 15:58:11Z dgheath $
+ */
+
+/**
+ * Parses the command line arguments.
+ * @package SimpleTest
+ * @subpackage UnitTester
+ */
+class SimpleArguments {
+ private $all = array();
+
+ /**
+ * Parses the command line arguments. The usual formats
+ * are supported:
+ * -f value
+ * -f=value
+ * --flag=value
+ * --flag value
+ * -f (true)
+ * --flag (true)
+ * @param array $arguments Normally the PHP $argv.
+ */
+ function __construct($arguments) {
+ array_shift($arguments);
+ while (count($arguments) > 0) {
+ list($key, $value) = $this->parseArgument($arguments);
+ $this->assign($key, $value);
+ }
+ }
+
+ /**
+ * Sets the value in the argments object. If multiple
+ * values are added under the same key, the key will
+ * give an array value in the order they were added.
+ * @param string $key The variable to assign to.
+ * @param string value The value that would norally
+ * be colected on the command line.
+ */
+ function assign($key, $value) {
+ if ($this->$key === false) {
+ $this->all[$key] = $value;
+ } elseif (! is_array($this->$key)) {
+ $this->all[$key] = array($this->$key, $value);
+ } else {
+ $this->all[$key][] = $value;
+ }
+ }
+
+ /**
+ * Extracts the next key and value from the argument list.
+ * @param array $arguments The remaining arguments to be parsed.
+ * The argument list will be reduced.
+ * @return array Two item array of key and value.
+ * If no value can be found it will
+ * have the value true assigned instead.
+ */
+ private function parseArgument(&$arguments) {
+ $argument = array_shift($arguments);
+ if (preg_match('/^-(\w)=(.+)$/', $argument, $matches)) {
+ return array($matches[1], $matches[2]);
+ } elseif (preg_match('/^-(\w)$/', $argument, $matches)) {
+ return array($matches[1], $this->nextNonFlagElseTrue($arguments));
+ } elseif (preg_match('/^--(\w+)=(.+)$/', $argument, $matches)) {
+ return array($matches[1], $matches[2]);
+ } elseif (preg_match('/^--(\w+)$/', $argument, $matches)) {
+ return array($matches[1], $this->nextNonFlagElseTrue($arguments));
+ }
+ }
+
+ /**
+ * Attempts to use the next argument as a value. It
+ * won't use what it thinks is a flag.
+ * @param array $arguments Remaining arguments to be parsed.
+ * This variable is modified if there
+ * is a value to be extracted.
+ * @return string/boolean The next value unless it's a flag.
+ */
+ private function nextNonFlagElseTrue(&$arguments) {
+ return $this->valueIsNext($arguments) ? array_shift($arguments) : true;
+ }
+
+ /**
+ * Test to see if the next available argument is a valid value.
+ * If it starts with "-" or "--" it's a flag and doesn't count.
+ * @param array $arguments Remaining arguments to be parsed.
+ * Not affected by this call.
+ * boolean True if valid value.
+ */
+ function valueIsNext($arguments) {
+ return isset($arguments[0]) && ! $this->isFlag($arguments[0]);
+ }
+
+ /**
+ * It's a flag if it starts with "-" or "--".
+ * @param string $argument Value to be tested.
+ * @return boolean True if it's a flag.
+ */
+ function isFlag($argument) {
+ return strncmp($argument, '-', 1) == 0;
+ }
+
+ /**
+ * The arguments are available as individual member
+ * variables on the object.
+ * @param string $key Argument name.
+ * @return string/array/boolean Either false for no value,
+ * the value as a string or
+ * a list of multiple values if
+ * the flag had been specified more
+ * than once.
+ */
+ function __get($key) {
+ if (isset($this->all[$key])) {
+ return $this->all[$key];
+ }
+ return false;
+ }
+
+ /**
+ * The entire argument set as a hash.
+ * @return hash Each argument and it's value(s).
+ */
+ function all() {
+ return $this->all;
+ }
+}
+
+/**
+ * Renders the help for the command line arguments.
+ * @package SimpleTest
+ * @subpackage UnitTester
+ */
+class SimpleHelp {
+ private $overview;
+ private $flag_sets = array();
+ private $explanations = array();
+
+ /**
+ * Sets up the top level explanation for the program.
+ * @param string $overview Summary of program.
+ */
+ function __construct($overview = '') {
+ $this->overview = $overview;
+ }
+
+ /**
+ * Adds the explanation for a group of flags that all
+ * have the same function.
+ * @param string/array $flags Flag and alternates. Don't
+ * worry about leading dashes
+ * as these are inserted automatically.
+ * @param string $explanation What that flag group does.
+ */
+ function explainFlag($flags, $explanation) {
+ $flags = is_array($flags) ? $flags : array($flags);
+ $this->flag_sets[] = $flags;
+ $this->explanations[] = $explanation;
+ }
+
+ /**
+ * Generates the help text.
+ * @returns string The complete formatted text.
+ */
+ function render() {
+ $tab_stop = $this->longestFlag($this->flag_sets) + 4;
+ $text = $this->overview . "\n";
+ for ($i = 0; $i < count($this->flag_sets); $i++) {
+ $text .= $this->renderFlagSet($this->flag_sets[$i], $this->explanations[$i], $tab_stop);
+ }
+ return $this->noDuplicateNewLines($text);
+ }
+
+ /**
+ * Works out the longest flag for formatting purposes.
+ * @param array $flag_sets The internal flag set list.
+ */
+ private function longestFlag($flag_sets) {
+ $longest = 0;
+ foreach ($flag_sets as $flags) {
+ foreach ($flags as $flag) {
+ $longest = max($longest, strlen($this->renderFlag($flag)));
+ }
+ }
+ return $longest;
+ }
+
+ /**
+ * Generates the text for a single flag and it's alternate flags.
+ * @returns string Help text for that flag group.
+ */
+ private function renderFlagSet($flags, $explanation, $tab_stop) {
+ $flag = array_shift($flags);
+ $text = str_pad($this->renderFlag($flag), $tab_stop, ' ') . $explanation . "\n";
+ foreach ($flags as $flag) {
+ $text .= ' ' . $this->renderFlag($flag) . "\n";
+ }
+ return $text;
+ }
+
+ /**
+ * Generates the flag name including leading dashes.
+ * @param string $flag Just the name.
+ * @returns Fag with apropriate dashes.
+ */
+ private function renderFlag($flag) {
+ return (strlen($flag) == 1 ? '-' : '--') . $flag;
+ }
+
+ /**
+ * Converts multiple new lines into a single new line.
+ * Just there to trap accidental duplicate new lines.
+ * @param string $text Text to clean up.
+ * @returns string Text with no blank lines.
+ */
+ private function noDuplicateNewLines($text) {
+ return preg_replace('/(\n+)/', "\n", $text);
+ }
+}
+?>
View
91 lib/simpletest/authentication.php
@@ -3,7 +3,7 @@
* Base include file for SimpleTest
* @package SimpleTest
* @subpackage WebTester
- * @version $Id: authentication.php 1720 2008-04-07 02:32:43Z lastcraft $
+ * @version $Id: authentication.php 2011 2011-04-29 08:22:48Z pp11 $
*/
/**
* include http class
@@ -16,11 +16,11 @@
* @subpackage WebTester
*/
class SimpleRealm {
- var $_type;
- var $_root;
- var $_username;
- var $_password;
-
+ private $type;
+ private $root;
+ private $username;
+ private $password;
+
/**
* Starts with the initial entry directory.
* @param string $type Authentication type for this
@@ -30,29 +30,29 @@ class SimpleRealm {
* @access public
*/
function SimpleRealm($type, $url) {
- $this->_type = $type;
- $this->_root = $url->getBasePath();
- $this->_username = false;
- $this->_password = false;
+ $this->type = $type;
+ $this->root = $url->getBasePath();
+ $this->username = false;
+ $this->password = false;
}
-
+
/**
* Adds another location to the realm.
* @param SimpleUrl $url Somewhere in realm.
* @access public
*/
function stretch($url) {
- $this->_root = $this->_getCommonPath($this->_root, $url->getPath());
+ $this->root = $this->getCommonPath($this->root, $url->getPath());
}
-
+
/**
* Finds the common starting path.
* @param string $first Path to compare.
* @param string $second Path to compare.
* @return string Common directories.
* @access private
*/
- function _getCommonPath($first, $second) {
+ protected function getCommonPath($first, $second) {
$first = explode('/', $first);
$second = explode('/', $second);
for ($i = 0; $i < min(count($first), count($second)); $i++) {
@@ -62,36 +62,36 @@ function _getCommonPath($first, $second) {
}
return implode('/', $first) . '/';
}
-
+
/**
* Sets the identity to try within this realm.
* @param string $username Username in authentication dialog.
* @param string $username Password in authentication dialog.
* @access public
*/
function setIdentity($username, $password) {
- $this->_username = $username;
- $this->_password = $password;
+ $this->username = $username;
+ $this->password = $password;
}
-
+
/**
* Accessor for current identity.
* @return string Last succesful username.
* @access public
*/
function getUsername() {
- return $this->_username;
+ return $this->username;
}
-
+
/**
* Accessor for current identity.
* @return string Last succesful password.
* @access public
*/
function getPassword() {
- return $this->_password;
+ return $this->password;
}
-
+
/**
* Test to see if the URL is within the directory
* tree of the realm.
@@ -100,15 +100,15 @@ function getPassword() {
* @access public
*/
function isWithin($url) {
- if ($this->_isIn($this->_root, $url->getBasePath())) {
+ if ($this->isIn($this->root, $url->getBasePath())) {
return true;
}
- if ($this->_isIn($this->_root, $url->getBasePath() . $url->getPage() . '/')) {
+ if ($this->isIn($this->root, $url->getBasePath() . $url->getPage() . '/')) {
return true;
}
return false;
}
-
+
/**
* Tests to see if one string is a substring of
* another.
@@ -118,7 +118,7 @@ function isWithin($url) {
* in the big bit.
* @access private
*/
- function _isIn($part, $whole) {
+ protected function isIn($part, $whole) {
return strpos($whole, $part) === 0;
}
}
@@ -129,27 +129,27 @@ function _isIn($part, $whole) {
* @subpackage WebTester
*/
class SimpleAuthenticator {
- var $_realms;
-
+ private $realms;
+
/**
* Clears the realms.
* @access public
*/
function SimpleAuthenticator() {
$this->restartSession();
}
-
+
/**
* Starts with no realms set up.
* @access public
*/
function restartSession() {
- $this->_realms = array();
+ $this->realms = array();
}
-
+
/**
* Adds a new realm centered the current URL.
- * Browsers vary wildly on their behaviour in this
+ * Browsers privatey wildly on their behaviour in this
* regard. Mozilla ignores the realm and presents
* only when challenged, wasting bandwidth. IE
* just carries on presenting until a new challenge
@@ -164,9 +164,9 @@ function restartSession() {
* @access public
*/
function addRealm($url, $type, $realm) {
- $this->_realms[$url->getHost()][$realm] = new SimpleRealm($type, $url);
+ $this->realms[$url->getHost()][$realm] = new SimpleRealm($type, $url);
}
-
+
/**
* Sets the current identity to be presented
* against that realm.
@@ -177,29 +177,29 @@ function addRealm($url, $type, $realm) {
* @access public
*/
function setIdentityForRealm($host, $realm, $username, $password) {
- if (isset($this->_realms[$host][$realm])) {
- $this->_realms[$host][$realm]->setIdentity($username, $password);
+ if (isset($this->realms[$host][$realm])) {
+ $this->realms[$host][$realm]->setIdentity($username, $password);
}
}
-
+
/**
* Finds the name of the realm by comparing URLs.
* @param SimpleUrl $url URL to test.
* @return SimpleRealm Name of realm.
* @access private
*/
- function _findRealmFromUrl($url) {
- if (! isset($this->_realms[$url->getHost()])) {
+ protected function findRealmFromUrl($url) {
+ if (! isset($this->realms[$url->getHost()])) {
return false;
}
- foreach ($this->_realms[$url->getHost()] as $name => $realm) {
+ foreach ($this->realms[$url->getHost()] as $name => $realm) {
if ($realm->isWithin($url)) {
return $realm;
}
}
return false;
}
-
+
/**
* Presents the appropriate headers for this location.
* @param SimpleHttpRequest $request Request to modify.
@@ -210,28 +210,27 @@ function addHeaders(&$request, $url) {
if ($url->getUsername() && $url->getPassword()) {
$username = $url->getUsername();
$password = $url->getPassword();
- } elseif ($realm = $this->_findRealmFromUrl($url)) {
+ } elseif ($realm = $this->findRealmFromUrl($url)) {
$username = $realm->getUsername();
$password = $realm->getPassword();
} else {
return;
}
$this->addBasicHeaders($request, $username, $password);
}
-
+
/**
* Presents the appropriate headers for this
* location for basic authentication.
* @param SimpleHttpRequest $request Request to modify.
* @param string $username Username for realm.
* @param string $password Password for realm.
* @access public
- * @static
*/
- function addBasicHeaders(&$request, $username, $password) {
+ static function addBasicHeaders(&$request, $username, $password) {
if ($username && $password) {
$request->addHeaderLine(
- 'Authorization: Basic ' . base64_encode("$username:$password"));
+ 'Authorization: Basic ' . base64_encode("$username:$password"));
}
}
}
View
70 lib/simpletest/autorun.php
@@ -3,39 +3,62 @@
* Autorunner which runs all tests cases found in a file
* that includes this module.
* @package SimpleTest
- * @version $Id: autorun.php 1721 2008-04-07 19:27:10Z lastcraft $
+ * @version $Id: autorun.php 2037 2011-11-30 17:58:21Z pp11 $
+ */
+
+/**#@+
+ * include simpletest files
*/
require_once dirname(__FILE__) . '/unit_tester.php';
require_once dirname(__FILE__) . '/mock_objects.php';
require_once dirname(__FILE__) . '/collector.php';
require_once dirname(__FILE__) . '/default_reporter.php';
+/**#@-*/
$GLOBALS['SIMPLETEST_AUTORUNNER_INITIAL_CLASSES'] = get_declared_classes();
+$GLOBALS['SIMPLETEST_AUTORUNNER_INITIAL_PATH'] = getcwd();
register_shutdown_function('simpletest_autorun');
/**
- * Exit handler to run all recent test cases if no test has
- * so far been run. Uses the DefaultReporter which can have
- * it's output controlled with SimpleTest::prefer().
+ * Exit handler to run all recent test cases and exit system if in CLI
*/
function simpletest_autorun() {
+ chdir($GLOBALS['SIMPLETEST_AUTORUNNER_INITIAL_PATH']);
if (tests_have_run()) {
return;
}
- $candidates = array_intersect(
- capture_new_classes(),
- classes_defined_in_initial_file());
- $loader = new SimpleFileLoader();
- $suite = $loader->createSuiteFromClasses(
- basename(initial_file()),
- $loader->selectRunnableTests($candidates));
- $result = $suite->run(new DefaultReporter());
+ $result = run_local_tests();
if (SimpleReporter::inCli()) {
exit($result ? 0 : 1);
}
}
/**
+ * run all recent test cases if no test has
+ * so far been run. Uses the DefaultReporter which can have
+ * it's output controlled with SimpleTest::prefer().
+ * @return boolean/null false if there were test failures, true if
+ * there were no failures, null if tests are
+ * already running
+ */
+function run_local_tests() {
+ try {
+ if (tests_have_run()) {
+ return;
+ }
+ $candidates = capture_new_classes();
+ $loader = new SimpleFileLoader();
+ $suite = $loader->createSuiteFromClasses(
+ basename(initial_file()),
+ $loader->selectRunnableTests($candidates));
+ return $suite->run(new DefaultReporter());
+ } catch (Exception $stack_frame_fix) {
+ print $stack_frame_fix->getMessage();
+ return false;
+ }
+}
+
+/**
* Checks the current test context to see if a test has
* ever been run.
* @return boolean True if tests have run.
@@ -54,28 +77,19 @@ function tests_have_run() {
function initial_file() {
static $file = false;
if (! $file) {
- $file = reset(get_included_files());
+ if (isset($_SERVER, $_SERVER['SCRIPT_FILENAME'])) {
+ $file = $_SERVER['SCRIPT_FILENAME'];
+ } else {
+ $included_files = get_included_files();
+ $file = reset($included_files);
+ }
}
return $file;
}
/**
- * Just the classes from the first autorun script. May
- * get a few false positives, as it just does a regex based
- * on following the word "class".
- * @return array List of all possible classes in first
- * autorun script.
- */
-function classes_defined_in_initial_file() {
- if (preg_match_all('/\bclass\s+(\w+)/i', file_get_contents(initial_file()), $matches)) {
- return array_map('strtolower', $matches[1]);
- }
- return array();
-}
-
-/**
* Every class since the first autorun include. This
- * is safe enough if require_once() is alwyas used.
+ * is safe enough if require_once() is always used.
* @return array Class names.
*/
function capture_new_classes() {
View
388 lib/simpletest/browser.php
@@ -3,7 +3,7 @@
* Base include file for SimpleTest
* @package SimpleTest
* @subpackage WebTester
- * @version $Id: browser.php 1723 2008-04-08 00:34:10Z lastcraft $
+ * @version $Id: browser.php 2013 2011-04-29 09:29:45Z pp11 $
*/
/**#@+
@@ -13,12 +13,18 @@
require_once(dirname(__FILE__) . '/http.php');
require_once(dirname(__FILE__) . '/encoding.php');
require_once(dirname(__FILE__) . '/page.php');
+require_once(dirname(__FILE__) . '/php_parser.php');
+require_once(dirname(__FILE__) . '/tidy_parser.php');
require_once(dirname(__FILE__) . '/selector.php');
require_once(dirname(__FILE__) . '/frames.php');
require_once(dirname(__FILE__) . '/user_agent.php');
+if (! SimpleTest::getParsers()) {
+ SimpleTest::setParsers(array(new SimpleTidyPageBuilder(), new SimplePHPPageBuilder()));
+ //SimpleTest::setParsers(array(new SimplePHPPageBuilder()));
+}
/**#@-*/
-if (!defined('DEFAULT_MAX_NESTED_FRAMES')) {
+if (! defined('DEFAULT_MAX_NESTED_FRAMES')) {
define('DEFAULT_MAX_NESTED_FRAMES', 3);
}
@@ -28,43 +34,34 @@
* @subpackage WebTester
*/
class SimpleBrowserHistory {
- var $_sequence;
- var $_position;
-
- /**
- * Starts empty.
- * @access public
- */
- function SimpleBrowserHistory() {
- $this->_sequence = array();
- $this->_position = -1;
- }
+ private $sequence = array();
+ private $position = -1;
/**
* Test for no entries yet.
* @return boolean True if empty.
* @access private
*/
- function _isEmpty() {
- return ($this->_position == -1);
+ protected function isEmpty() {
+ return ($this->position == -1);
}
/**
* Test for being at the beginning.
* @return boolean True if first.
* @access private
*/
- function _atBeginning() {
- return ($this->_position == 0) && ! $this->_isEmpty();
+ protected function atBeginning() {
+ return ($this->position == 0) && ! $this->isEmpty();
}
/**
* Test for being at the last entry.
* @return boolean True if last.
* @access private
*/
- function _atEnd() {
- return ($this->_position + 1 >= count($this->_sequence)) && ! $this->_isEmpty();
+ protected function atEnd() {
+ return ($this->position + 1 >= count($this->sequence)) && ! $this->isEmpty();
}
/**
@@ -74,11 +71,11 @@ function _atEnd() {
* @access public
*/
function recordEntry($url, $parameters) {
- $this->_dropFuture();
+ $this->dropFuture();
array_push(
- $this->_sequence,
+ $this->sequence,
array('url' => $url, 'parameters' => $parameters));
- $this->_position++;
+ $this->position++;
}
/**
@@ -88,10 +85,10 @@ function recordEntry($url, $parameters) {
* @access public
*/
function getUrl() {
- if ($this->_isEmpty()) {
+ if ($this->isEmpty()) {
return false;
}
- return $this->_sequence[$this->_position]['url'];
+ return $this->sequence[$this->position]['url'];
}
/**
@@ -101,10 +98,10 @@ function getUrl() {
* @access public
*/
function getParameters() {
- if ($this->_isEmpty()) {
+ if ($this->isEmpty()) {
return false;
}
- return $this->_sequence[$this->_position]['parameters'];
+ return $this->sequence[$this->position]['parameters'];
}
/**
@@ -114,10 +111,10 @@ function getParameters() {
* @access public
*/
function back() {
- if ($this->_isEmpty() || $this->_atBeginning()) {
+ if ($this->isEmpty() || $this->atBeginning()) {
return false;
}
- $this->_position--;
+ $this->position--;
return true;
}
@@ -128,10 +125,10 @@ function back() {
* @access public
*/
function forward() {
- if ($this->_isEmpty() || $this->_atEnd()) {
+ if ($this->isEmpty() || $this->atEnd()) {
return false;
}
- $this->_position++;
+ $this->position++;
return true;
}
@@ -140,12 +137,12 @@ function forward() {
* point.
* @access private
*/
- function _dropFuture() {
- if ($this->_isEmpty()) {
+ protected function dropFuture() {
+ if ($this->isEmpty()) {
return;
}
- while (! $this->_atEnd()) {
- array_pop($this->_sequence);
+ while (! $this->atEnd()) {
+ array_pop($this->sequence);
}
}
}
@@ -158,11 +155,12 @@ function _dropFuture() {
* @subpackage WebTester
*/
class SimpleBrowser {
- var $_user_agent;
- var $_page;
- var $_history;
- var $_ignore_frames;
- var $_maximum_nested_frames;
+ private $user_agent;
+ private $page;
+ private $history;
+ private $ignore_frames;
+ private $maximum_nested_frames;
+ private $parser;
/**
* Starts with a fresh browser with no
@@ -171,36 +169,59 @@ class SimpleBrowser {
* set up if specified in the options.
* @access public
*/
- function SimpleBrowser() {
- $this->_user_agent = &$this->_createUserAgent();
- $this->_user_agent->useProxy(
+ function __construct() {
+ $this->user_agent = $this->createUserAgent();
+ $this->user_agent->useProxy(
SimpleTest::getDefaultProxy(),
SimpleTest::getDefaultProxyUsername(),
SimpleTest::getDefaultProxyPassword());
- $this->_page = &new SimplePage();
- $this->_history = &$this->_createHistory();
- $this->_ignore_frames = false;
- $this->_maximum_nested_frames = DEFAULT_MAX_NESTED_FRAMES;
+ $this->page = new SimplePage();
+ $this->history = $this->createHistory();
+ $this->ignore_frames = false;
+ $this->maximum_nested_frames = DEFAULT_MAX_NESTED_FRAMES;
}
/**
* Creates the underlying user agent.
* @return SimpleFetcher Content fetcher.
* @access protected
*/
- function &_createUserAgent() {
- $user_agent = &new SimpleUserAgent();
- return $user_agent;
+ protected function createUserAgent() {
+ return new SimpleUserAgent();
}
/**
* Creates a new empty history list.
* @return SimpleBrowserHistory New list.
* @access protected
*/
- function &_createHistory() {
- $history = &new SimpleBrowserHistory();
- return $history;
+ protected function createHistory() {
+ return new SimpleBrowserHistory();
+ }
+
+ /**
+ * Get the HTML parser to use. Can be overridden by
+ * setParser. Otherwise scans through the available parsers and
+ * uses the first one which is available.
+ * @return object SimplePHPPageBuilder or SimpleTidyPageBuilder
+ */
+ protected function getParser() {
+ if ($this->parser) {
+ return $this->parser;
+ }
+ foreach (SimpleTest::getParsers() as $parser) {
+ if ($parser->can()) {
+ return $parser;
+ }
+ }
+ }
+
+ /**
+ * Override the default HTML parser, allowing parsers to be plugged in.
+ * @param object A parser object instance.
+ */
+ public function setParser($parser) {
+ $this->parser = $parser;
}
/**
@@ -209,7 +230,7 @@ function &_createHistory() {
* @access public
*/
function ignoreFrames() {
- $this->_ignore_frames = true;
+ $this->ignore_frames = true;
}
/**
@@ -218,23 +239,23 @@ function ignoreFrames() {
* @access public
*/
function useFrames() {
- $this->_ignore_frames = false;
+ $this->ignore_frames = false;
}
-
+
/**
* Switches off cookie sending and recieving.
* @access public
*/
function ignoreCookies() {
- $this->_user_agent->ignoreCookies();
+ $this->user_agent->ignoreCookies();
}
-
+
/**
* Switches back on the cookie sending and recieving.
* @access public
*/
function useCookies() {
- $this->_user_agent->useCookies();
+ $this->user_agent->useCookies();
}
/**
@@ -245,52 +266,45 @@ function useCookies() {
* @return SimplePage Parsed HTML.
* @access private
*/
- function &_parse($response, $depth = 0) {
- $page = &$this->_buildPage($response);
- if ($this->_ignore_frames || ! $page->hasFrames() || ($depth > $this->_maximum_nested_frames)) {
+ protected function parse($response, $depth = 0) {
+ $page = $this->buildPage($response);
+ if ($this->ignore_frames || ! $page->hasFrames() || ($depth > $this->maximum_nested_frames)) {
return $page;
}
- $frameset = &new SimpleFrameset($page);
+ $frameset = new SimpleFrameset($page);
foreach ($page->getFrameset() as $key => $url) {
- $frame = &$this->_fetch($url, new SimpleGetEncoding(), $depth + 1);
+ $frame = $this->fetch($url, new SimpleGetEncoding(), $depth + 1);
$frameset->addFrame($frame, $key);
}
return $frameset;
}
-
+
/**
* Assembles the parsing machinery and actually parses
* a single page. Frees all of the builder memory and so
* unjams the PHP memory management.
* @param SimpleHttpResponse $response Response from fetch.
* @return SimplePage Parsed top level page.
- * @access protected
*/
- function &_buildPage($response) {
- $builder = &new SimplePageBuilder();
- $page = &$builder->parse($response);
- $builder->free();
- unset($builder);
- return $page;
+ protected function buildPage($response) {
+ return $this->getParser()->parse($response);
}
/**
- * Fetches a page. Jointly recursive with the _parse()
+ * Fetches a page. Jointly recursive with the parse()
* method as it descends a frameset.
* @param string/SimpleUrl $url Target to fetch.
* @param SimpleEncoding $encoding GET/POST parameters.
* @param integer $depth Nested frameset depth protection.
* @return SimplePage Parsed page.
* @access private
*/
- function &_fetch($url, $encoding, $depth = 0) {
- $response = &$this->_user_agent->fetchResponse($url, $encoding);
+ protected function fetch($url, $encoding, $depth = 0) {
+ $response = $this->user_agent->fetchResponse($url, $encoding);
if ($response->isError()) {
- $page = &new SimplePage($response);
- } else {
- $page = &$this->_parse($response, $depth);
+ return new SimplePage($response);
}
- return $page;
+ return $this->parse($response, $depth);
}
/**
@@ -301,12 +315,12 @@ function &_fetch($url, $encoding, $depth = 0) {
* @return string Raw content of page.
* @access private
*/
- function _load($url, $parameters) {
+ protected function load($url, $parameters) {
$frame = $url->getTarget();
- if (! $frame || ! $this->_page->hasFrames() || (strtolower($frame) == '_top')) {
- return $this->_loadPage($url, $parameters);
+ if (! $frame || ! $this->page->hasFrames() || (strtolower($frame) == '_top')) {
+ return $this->loadPage($url, $parameters);
}
- return $this->_loadFrame(array($frame), $url, $parameters);
+ return $this->loadFrame(array($frame), $url, $parameters);
}
/**
@@ -316,12 +330,12 @@ function _load($url, $parameters) {
* @return string Raw content of page.
* @access private
*/
- function _loadPage($url, $parameters) {
- $this->_page = &$this->_fetch($url, $parameters);
- $this->_history->recordEntry(
- $this->_page->getUrl(),
- $this->_page->getRequestData());
- return $this->_page->getRaw();
+ protected function loadPage($url, $parameters) {
+ $this->page = $this->fetch($url, $parameters);
+ $this->history->recordEntry(
+ $this->page->getUrl(),
+ $this->page->getRequestData());
+ return $this->page->getRaw();
}
/**
@@ -333,9 +347,9 @@ function _loadPage($url, $parameters) {
* @return string Raw content of page.
* @access private
*/
- function _loadFrame($frames, $url, $parameters) {
- $page = &$this->_fetch($url, $parameters);
- $this->_page->setFrame($frames, $page);
+ protected function loadFrame($frames, $url, $parameters) {
+ $page = $this->fetch($url, $parameters);
+ $this->page->setFrame($frames, $page);
return $page->getRaw();
}
@@ -348,7 +362,7 @@ function _loadFrame($frames, $url, $parameters) {
* @access public
*/
function restart($date = false) {
- $this->_user_agent->restart($date);
+ $this->user_agent->restart($date);
}
/**
@@ -358,7 +372,7 @@ function restart($date = false) {
* @access public
*/
function addHeader($header) {
- $this->_user_agent->addHeader($header);
+ $this->user_agent->addHeader($header);
}
/**
@@ -367,7 +381,7 @@ function addHeader($header) {
* @access public
*/
function ageCookies($interval) {
- $this->_user_agent->ageCookies($interval);
+ $this->user_agent->ageCookies($interval);
}
/**
@@ -381,7 +395,7 @@ function ageCookies($interval) {
* @access public
*/
function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
- $this->_user_agent->setCookie($name, $value, $host, $path, $expiry);
+ $this->user_agent->setCookie($name, $value, $host, $path, $expiry);
}
/**
@@ -395,7 +409,7 @@ function setCookie($name, $value, $host = false, $path = '/', $expiry = false) {
* @access public
*/
function getCookieValue($host, $path, $name) {
- return $this->_user_agent->getCookieValue($host, $path, $name);
+ return $this->user_agent->getCookieValue($host, $path, $name);
}
/**
@@ -406,7 +420,7 @@ function getCookieValue($host, $path, $name) {
* @access public
*/
function getCurrentCookieValue($name) {
- return $this->_user_agent->getBaseCookieValue($name, $this->_page->getUrl());
+ return $this->user_agent->getBaseCookieValue($name, $this->page->getUrl());
}
/**
@@ -416,7 +430,7 @@ function getCurrentCookieValue($name) {
* @access public
*/
function setMaximumRedirects($max) {
- $this->_user_agent->setMaximumRedirects($max);
+ $this->user_agent->setMaximumRedirects($max);
}
/**
@@ -426,7 +440,7 @@ function setMaximumRedirects($max) {
* @access public
*/
function setMaximumNestedFrames($max) {
- $this->_maximum_nested_frames = $max;
+ $this->maximum_nested_frames = $max;
}
/**
@@ -435,7 +449,7 @@ function setMaximumNestedFrames($max) {
* @access public
*/
function setConnectionTimeout($timeout) {
- $this->_user_agent->setConnectionTimeout($timeout);
+ $this->user_agent->setConnectionTimeout($timeout);
}
/**
@@ -448,7 +462,7 @@ function setConnectionTimeout($timeout) {
* @access public
*/
function useProxy($proxy, $username = false, $password = false) {
- $this->_user_agent->useProxy($proxy, $username, $password);
+ $this->user_agent->useProxy($proxy, $username, $password);
}
/**
@@ -467,7 +481,8 @@ function head($url, $parameters = false) {
if ($this->getUrl()) {
$url = $url->makeAbsolute($this->getUrl());
}
- $response = &$this->_user_agent->fetchResponse($url, new SimpleHeadEncoding($parameters));
+ $response = $this->user_agent->fetchResponse($url, new SimpleHeadEncoding($parameters));
+ $this->page = new SimplePage($response);
return ! $response->isError();
}
@@ -486,24 +501,55 @@ function get($url, $parameters = false) {
if ($this->getUrl()) {
$url = $url->makeAbsolute($this->getUrl());
}
- return $this->_load($url, new SimpleGetEncoding($parameters));
+ return $this->load($url, new SimpleGetEncoding($parameters));
}
/**
* Fetches the page content with a POST request.
* @param string/SimpleUrl $url Target to fetch as string.
- * @param hash/SimpleFormEncoding $parameters POST parameters.
+ * @param hash/SimpleFormEncoding $parameters POST parameters or request body.
+ * @param string $content_type MIME Content-Type of the request body
* @return string Content of page.
* @access public
*/
- function post($url, $parameters = false) {
+ function post($url, $parameters = false, $content_type = false) {
if (! is_object($url)) {
$url = new SimpleUrl($url);
}
if ($this->getUrl()) {
$url = $url->makeAbsolute($this->getUrl());
}
- return $this->_load($url, new SimplePostEncoding($parameters));
+ return $this->load($url, new SimplePostEncoding($parameters, $content_type));
+ }
+
+ /**
+ * Fetches the page content with a PUT request.
+ * @param string/SimpleUrl $url Target to fetch as string.
+ * @param hash/SimpleFormEncoding $parameters PUT request body.
+ * @param string $content_type MIME Content-Type of the request body
+ * @return string Content of page.
+ * @access public
+ */
+ function put($url, $parameters = false, $content_type = false) {
+ if (! is_object($url)) {
+ $url = new SimpleUrl($url);
+ }
+ return $this->load($url, new SimplePutEncoding($parameters, $content_type));
+ }
+
+ /**
+ * Sends a DELETE request and fetches the response.
+ * @param string/SimpleUrl $url Target to fetch.
+ * @param hash/SimpleFormEncoding $parameters Additional parameters for
+ * DELETE request.
+ * @return string Content of page or false.
+ * @access public
+ */
+ function delete($url, $parameters = false) {
+ if (! is_object($url)) {
+ $url = new SimpleUrl($url);
+ }
+ return $this->load($url, new SimpleDeleteEncoding($parameters));
}
/**
@@ -515,17 +561,17 @@ function post($url, $parameters = false) {
* @access public
*/
function retry() {
- $frames = $this->_page->getFrameFocus();
+ $frames = $this->page->getFrameFocus();
if (count($frames) > 0) {
- $this->_loadFrame(
+ $this->loadFrame(
$frames,
- $this->_page->getUrl(),
- $this->_page->getRequestData());
- return $this->_page->getRaw();
+ $this->page->getUrl(),
+ $this->page->getRequestData());
+ return $this->page->getRaw();
}
- if ($url = $this->_history->getUrl()) {
- $this->_page = &$this->_fetch($url, $this->_history->getParameters());
- return $this->_page->getRaw();
+ if ($url = $this->history->getUrl()) {
+ $this->page = $this->fetch($url, $this->history->getParameters());
+ return $this->page->getRaw();
}
return false;
}
@@ -540,12 +586,12 @@ function retry() {
* @access public
*/
function back() {
- if (! $this->_history->back()) {
+ if (! $this->history->back()) {
return false;
}
$content = $this->retry();
if (! $content) {
- $this->_history->forward();
+ $this->history->forward();
}
return $content;
}
@@ -560,12 +606,12 @@ function back() {
* @access public
*/
function forward() {
- if (! $this->_history->forward()) {
+ if (! $this->history->forward()) {
return false;
}
$content = $this->retry();
if (! $content) {
- $this->_history->back();
+ $this->history->back();
}
return $content;
}
@@ -581,16 +627,16 @@ function forward() {
* @access public
*/
function authenticate($username, $password) {
- if (! $this->_page->getRealm()) {
+ if (! $this->page->getRealm()) {
return false;
}
- $url = $this->_page->getUrl();
+ $url = $this->page->getUrl();
if (! $url) {
return false;
}
- $this->_user_agent->setIdentity(
+ $this->user_agent->setIdentity(
$url->getHost(),
- $this->_page->getRealm(),
+ $this->page->getRealm(),
$username,
$password);
return $this->retry();
@@ -603,7 +649,7 @@ function authenticate($username, $password) {
* @access public
*/
function getFrames() {
- return $this->_page->getFrames();
+ return $this->page->getFrames();
}
/**
@@ -615,7 +661,7 @@ function getFrames() {
* @access public
*/
function getFrameFocus() {
- return $this->_page->getFrameFocus();
+ return $this->page->getFrameFocus();
}
/**
@@ -625,7 +671,7 @@ function getFrameFocus() {
* @access public
*/
function setFrameFocusByIndex($choice) {
- return $this->_page->setFrameFocusByIndex($choice);
+ return $this->page->setFrameFocusByIndex($choice);
}
/**
@@ -635,7 +681,7 @@ function setFrameFocusByIndex($choice) {
* @access public
*/
function setFrameFocus($name) {
- return $this->_page->setFrameFocus($name);
+ return $this->page->setFrameFocus($name);
}
/**
@@ -644,7 +690,7 @@ function setFrameFocus($name) {
* @access public
*/
function clearFrameFocus() {
- return $this->_page->clearFrameFocus();
+ return $this->page->clearFrameFocus();
}
/**
@@ -653,7 +699,7 @@ function clearFrameFocus() {
* @access public
*/
function getTransportError() {
- return $this->_page->getTransportError();
+ return $this->page->getTransportError();
}
/**
@@ -662,7 +708,7 @@ function getTransportError() {
* @access public
*/
function getMimeType() {
- return $this->_page->getMimeType();
+ return $this->page->getMimeType();
}
/**
@@ -671,7 +717,7 @@ function getMimeType() {
* @access public
*/
function getResponseCode() {
- return $this->_page->getResponseCode();
+ return $this->page->getResponseCode();
}
/**
@@ -681,7 +727,7 @@ function getResponseCode() {
* @access public
*/
function getAuthentication() {
- return $this->_page->getAuthentication();
+ return $this->page->getAuthentication();
}
/**
@@ -691,7 +737,7 @@ function getAuthentication() {
* @access public
*/
function getRealm() {
- return $this->_page->getRealm();
+ return $this->page->getRealm();
}
/**
@@ -701,7 +747,7 @@ function getRealm() {
* a string.
*/
function getUrl() {
- $url = $this->_page->getUrl();
+ $url = $this->page->getUrl();
return $url ? $url->asString() : false;
}
@@ -710,7 +756,7 @@ function getUrl() {
* @return string base URL
*/
function getBaseUrl() {
- $url = $this->_page->getBaseUrl();
+ $url = $this->page->getBaseUrl();
return $url ? $url->asString() : false;
}
@@ -720,7 +766,7 @@ function getBaseUrl() {
* @access public
*/
function getRequest() {
- return $this->_page->getRequest();
+ return $this->page->getRequest();
}
/**
@@ -729,7 +775,7 @@ function getRequest() {
* @access public
*/
function getHeaders() {
- return $this->_page->getHeaders();
+ return $this->page->getHeaders();
}
/**
@@ -738,7 +784,7 @@ function getHeaders() {
* @access public
*/
function getContent() {
- return $this->_page->getRaw();
+ return $this->page->getRaw();
}
/**
@@ -747,7 +793,7 @@ function getContent() {
* @access public
*/
function getContentAsText() {
- return $this->_page->getText();
+ return $this->page->getText();
}
/**
@@ -756,7 +802,7 @@ function getContentAsText() {
* @access public
*/
function getTitle() {
- return $this->_page->getTitle();
+ return $this->page->getTitle();
}
/**
@@ -766,7 +812,7 @@ function getTitle() {
* @access public
*/
function getUrls() {
- return $this->_page->getUrls();
+ return $this->page->getUrls();
}
/**
@@ -777,7 +823,7 @@ function getUrls() {
* @access public
*/
function setField($label, $value, $position=false) {
- return $this->_page->setField(new SimpleByLabelOrName($label), $value, $position);
+ return $this->page->setField(new SimpleByLabelOrName($label), $value, $position);
}
/**
@@ -789,7 +835,7 @@ function setField($label, $value, $position=false) {
* @access public
*/
function setFieldByName($name, $value, $position=false) {
- return $this->_page->setField(new SimpleByName($name), $value, $position);
+ return $this->page->setField(new SimpleByName($name), $value, $position);
}
/**
@@ -800,7 +846,7 @@ function setFieldByName($name, $value, $position=false) {
* @access public
*/
function setFieldById($id, $value) {
- return $this->_page->setField(new SimpleById($id), $value);
+ return $this->page->setField(new SimpleById($id), $value);
}
/**
@@ -813,7 +859,7 @@ function setFieldById($id, $value) {
* @access public
*/
function getField($label) {
- return $this->_page->getField(new SimpleByLabelOrName($label));
+ return $this->page->getField(new SimpleByLabelOrName($label));
}
/**
@@ -826,7 +872,7 @@ function getField($label) {
* @access public
*/
function getFieldByName($name) {
- return $this->_page->getField(new SimpleByName($name));
+ return $this->page->getField(new SimpleByName($name));
}
/**
@@ -838,7 +884,7 @@ function getFieldByName($name) {
* @access public
*/
function getFieldById($id) {
- return $this->_page->getField(new SimpleById($id));
+ return $this->page->getField(new SimpleById($id));
}
/**
@@ -851,10 +897,10 @@ function getFieldById($id) {
* @access public
*/
function clickSubmit($label = 'Submit', $additional = false) {
- if (! ($form = &$this->_page->getFormBySubmit(new SimpleByLabel($label)))) {
+ if (! ($form = $this->page->getFormBySubmit(new SimpleByLabel($label)))) {
return false;
}
- $success = $this->_load(
+ $success = $this->load(
$form->getAction(),
$form->submitButton(new SimpleByLabel($label), $additional));
return ($success ? $this->getContent() : $success);
@@ -869,10 +915,10 @@ function clickSubmit($label = 'Submit', $additional = false) {
* @access public
*/
function clickSubmitByName($name, $additional = false) {
- if (! ($form = &$this->_page->getFormBySubmit(new SimpleByName($name)))) {
+ if (! ($form = $this->page->getFormBySubmit(new SimpleByName($name)))) {
return false;
}
- $success = $this->_load(
+ $success = $this->load(
$form->getAction(),
$form->submitButton(new SimpleByName($name), $additional));
return ($success ? $this->getContent() : $success);
@@ -887,15 +933,15 @@ function clickSubmitByName($name, $additional = false) {
* @access public
*/
function clickSubmitById($id, $additional = false) {
- if (! ($form = &$this->_page->getFormBySubmit(new SimpleById($id)))) {
+ if (! ($form = $this->page->getFormBySubmit(new SimpleById($id)))) {
return false;
}
- $success = $this->_load(
+ $success = $this->load(
$form->getAction(),
$form->submitButton(new SimpleById($id), $additional));
return ($success ? $this->getContent() : $success);
}
-
+
/**
* Tests to see if a submit button exists with this
* label.
@@ -904,7 +950,7 @@ function clickSubmitById($id, $additional = false) {
* @access public
*/
function isSubmit($label) {
- return (boolean)$this->_page->getFormBySubmit(new SimpleByLabel($label));
+ return (boolean)$this->page->getFormBySubmit(new SimpleByLabel($label));
}
/**
@@ -921,10 +967,10 @@ function isSubmit($label) {
* @access public
*/
function clickImage($label, $x = 1, $y = 1, $additional = false) {
- if (! ($form = &$this->_page->getFormByImage(new SimpleByLabel($label)))) {
+ if (! ($form = $this->page->getFormByImage(new SimpleByLabel($label)))) {
return false;
}
- $success = $this->_load(
+ $success = $this->load(
$form->getAction(),
$form->submitImage(new SimpleByLabel($label), $x, $y, $additional));
return ($success ? $this->getContent() : $success);
@@ -944,10 +990,10 @@ function clickImage($label, $x = 1, $y = 1, $additional = false) {
* @access public
*/
function clickImageByName($name, $x = 1, $y = 1, $additional = false) {
- if (! ($form = &$this->_page->getFormByImage(new SimpleByName($name)))) {
+ if (! ($form = $this->page->getFormByImage(new SimpleByName($name)))) {
return false;
}
- $success = $this->_load(
+ $success = $this->load(
$form->getAction(),
$form->submitImage(new SimpleByName($name), $x, $y, $additional));
return ($success ? $this->getContent() : $success);
@@ -966,15 +1012,15 @@ function clickImageByName($name, $x = 1, $y = 1, $additional = false) {
* @access public
*/
function clickImageById($id, $x = 1, $y = 1, $additional = false) {
- if (! ($form = &$this->_page->getFormByImage(new SimpleById($id)))) {
+ if (! ($form = $this->page->getFormByImage(new SimpleById($id)))) {
return false;
}
- $success = $this->_load(
+ $success = $this->load(
$form->getAction(),
$form->submitImage(new SimpleById($id), $x, $y, $additional));
return ($success ? $this->getContent() : $success);
}
-
+
/**
* Tests to see if an image exists with this
* title or alt text.
@@ -983,7 +1029,7 @@ function clickImageById($id, $x = 1, $y = 1, $additional = false) {
* @access public
*/
function isImage($label) {
- return (boolean)$this->_page->getFormByImage(new SimpleByLabel($label));
+ return (boolean)$this->page->getFormByImage(new SimpleByLabel($label));
}
/**
@@ -993,13 +1039,13 @@ function isImage($label) {
* @return string/boolean Page on success.
* @access public
*/
- function submitFormById($id) {
- if (! ($form = &$this->_page->getFormById($id))) {
+ function submitFormById($id, $additional = false) {
+ if (! ($form = $this->page->getFormById($id))) {
return false;
}
- $success = $this->_load(
+ $success = $this->load(
$form->getAction(),
- $form->submit());
+ $form->submit($additional));
return ($success ? $this->getContent() : $success);
}
@@ -1014,7 +1060,7 @@ function submitFormById($id) {
* @access public
*/
function getLink($label, $index = 0) {
- $urls = $this->_page->getUrlsByLabel($label);
+ $urls = $this->page->getUrlsByLabel($label);
if (count($urls) == 0) {
return false;