Skip to content

Commit

Permalink
Upgraded simpletestlib from 1.0.1alpha3 to 1.0.1beta
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Apr 26, 2007
1 parent eba8cd6 commit 85414e8
Show file tree
Hide file tree
Showing 27 changed files with 1,354 additions and 621 deletions.
26 changes: 24 additions & 2 deletions lib/simpletestlib/HELP_MY_TESTS_DONT_WORK_ANYMORE
Expand Up @@ -5,6 +5,28 @@ 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...

No method _getTest() on mocks
-----------------------------
This has finally been removed. It was a pretty esoteric
flex point anyway. It was there to allow the mocks to
work with other test tools, but no one does this anyway.

No method assertError(), assertNoErrors(), swallowErrors()
----------------------------------------------------------
These have been deprecated in 1.0.1beta in favour of
expectError() and expectException(). assertNoErrors() is
redundant if you use expectError() as failures are now reporterted
immediately.

No method TestCase::signal()
----------------------------
This has been deprecated in favour of triggering an error or
throwing an exception. Deprecated as of 1.0.1beta.

No method TestCase::sendMessage()
---------------------------------
This has been deprecated as of 1.0.1beta.

Failure to connect now emits failures
-------------------------------------
It used to be that you would have to use the
Expand Down Expand Up @@ -46,7 +68,7 @@ No method addPartialMockCode()
------------------------------
The ability to insert arbitrary partial mock code
has been removed. This was a low value feature
causing needless complications.It was removed
causing needless complications. It was removed
in the 1.0.1beta release.

No method setMockBaseClass()
Expand Down Expand Up @@ -139,7 +161,7 @@ My custom test case ignored by tally()
The _assertTrue method has had it's signature changed due to a bug
in the PHP 5.0.1 release. You must now use getTest() from within
that method to get the test case. Mock compatibility with other
unit testers is now deprecated as of 1.0.1alpha as PEAR::PHUnit2
unit testers is now deprecated as of 1.0.1alpha as PEAR::PHPUnit2
should soon have mock support of it's own.

Broken code extending SimpleRunner
Expand Down
4 changes: 2 additions & 2 deletions lib/simpletestlib/LICENSE
Expand Up @@ -2,7 +2,7 @@
Version 2.1, February 1999

Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Also add information on how to contact you by electronic and paper mail.

Expand Down
2 changes: 1 addition & 1 deletion lib/simpletestlib/README
@@ -1,7 +1,7 @@
SimpleTest
==========
You probably got this package from...
http://sourceforge.net/projects/simpletest/
http://simpletest.sourceforge.net/projects/simpletest/

If there is no licence agreement with this package please download
a version from the location above. You must read and accept that
Expand Down
2 changes: 1 addition & 1 deletion lib/simpletestlib/VERSION
@@ -1 +1 @@
1.0.1alpha3
1.0.1beta
82 changes: 61 additions & 21 deletions lib/simpletestlib/browser.php
Expand Up @@ -894,6 +894,17 @@ function clickSubmitById($id, $additional = false) {
$form->submitButton(new SimpleById($id), $additional));
return ($success ? $this->getContent() : $success);
}

/**
* Tests to see if a submit button exists with this
* label.
* @param string $label Button label.
* @return boolean True if present.
* @access public
*/
function isSubmit($label) {
return (boolean)$this->_page->getFormBySubmit(new SimpleByLabel($label));
}

/**
* Clicks the submit image by some kind of label. Usually
Expand Down Expand Up @@ -962,6 +973,17 @@ function clickImageById($id, $x = 1, $y = 1, $additional = false) {
$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.
* @param string $label Image text.
* @return boolean True if present.
* @access public
*/
function isImage($label) {
return (boolean)$this->_page->getFormByImage(new SimpleByLabel($label));
}

/**
* Submits a form by the ID.
Expand All @@ -981,35 +1003,53 @@ function submitFormById($id) {
}

/**
* Follows a link by label. Will click the first link
* Finds a URL by label. Will find the first link
* found with this link text by default, or a later
* one if an index is given. The match ignores case and
* white space issues.
* @param string $label Text between the anchor tags.
* @param integer $index Link position counting from zero.
* @return string/boolean Page on success.
* @return string/boolean URL on success.
* @access public
*/
function clickLink($label, $index = 0) {
function getLink($label, $index = 0) {
$urls = $this->_page->getUrlsByLabel($label);
if (count($urls) == 0) {
return false;
}
if (count($urls) < $index + 1) {
return false;
}
$this->_load($urls[$index], new SimpleGetEncoding());
return $this->getContent();
return $urls[$index];
}

/**
* Tests to see if a link is present by label.
* @param string $label Text of value attribute.
* @return boolean True if link present.
* Follows a link by label. Will click the first link
* found with this link text by default, or a later
* one if an index is given. The match ignores case and
* white space issues.
* @param string $label Text between the anchor tags.
* @param integer $index Link position counting from zero.
* @return string/boolean Page on success.
* @access public
*/
function clickLink($label, $index = 0) {
$url = $this->getLink($label, $index);
if ($url === false) {
return false;
}
$this->_load($url, new SimpleGetEncoding());
return $this->getContent();
}

/**
* Finds a link by id attribute.
* @param string $id ID attribute value.
* @return string/boolean URL on success.
* @access public
*/
function isLink($label) {
return (count($this->_page->getUrlsByLabel($label)) > 0);
function getLinkById($id) {
return $this->_page->getUrlById($id);
}

/**
Expand All @@ -1019,23 +1059,13 @@ function isLink($label) {
* @access public
*/
function clickLinkById($id) {
if (! ($url = $this->_page->getUrlById($id))) {
if (! ($url = $this->getLinkById($id))) {
return false;
}
$this->_load($url, new SimpleGetEncoding());
return $this->getContent();
}

/**
* Tests to see if a link is present by ID attribute.
* @param string $id Text of id attribute.
* @return boolean True if link present.
* @access public
*/
function isLinkById($id) {
return (boolean)$this->_page->getUrlById($id);
}

/**
* Clicks a visible text item. Will first try buttons,
* then links and then images.
Expand All @@ -1053,5 +1083,15 @@ function click($label) {
}
return $raw;
}

/**
* Tests to see if a click target exists.
* @param string $label Visible text or alt text.
* @return boolean True if target present.
* @access public
*/
function isClickable($label) {
return $this->isSubmit($label) || ($this->getLink($label) !== false) || $this->isImage($label);
}
}
?>

0 comments on commit 85414e8

Please sign in to comment.