ENHANCEMENT Allowing to pass strings instead of arrays into FunctionalTest->assert*() methods, and convert them internally to arrays

MINOR PHPDoc for FunctionalTest

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65457 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-11-08 00:03:50 +00:00
parent 192078d3d2
commit 954bf465a1

View File

@ -132,15 +132,19 @@ class FunctionalTest extends SapphireTest {
/**
* Assert that the most recently queried page contains a number of content tags specified by a CSS selector.
*
* The given CSS selector will be applied to the HTML of the most recent page. The content of every matching tag
* will be examined.
*
* The assertion fails if one of the expectedMatches fails to appear.
* will be examined. The assertion fails if one of the expectedMatches fails to appear.
*
* Note:   characters are stripped from the content; make sure that your assertions take this into account.
*
* @param string $selector A basic CSS selector, e.g. 'li.jobs h3'
* @param array|string $expectedMatches The content of at least one of the matched tags
* @throws PHPUnit_Framework_AssertionFailedError
* @return boolean
*/
function assertPartialMatchBySelector($selector, $expectedMatches) {
if(is_string($expectedMatches)) $expectedMatches = array($expectedMatches);
$items = $this->cssParser()->getBySelector($selector);
$actuals = array();
@ -152,23 +156,28 @@ class FunctionalTest extends SapphireTest {
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n"
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
);
return;
return false;
}
}
return true;
}
/**
* Assert that the most recently queried page contains a number of content tags specified by a CSS selector.
*
* The given CSS selector will be applied to the HTML of the most recent page. The full HTML of every matching tag
* will be examined.
*
* The assertion fails if one of the expectedMatches fails to appear.
* will be examined. The assertion fails if one of the expectedMatches fails to appear.
*
* Note:   characters are stripped from the content; make sure that your assertions take this into account.
*
* @param string $selector A basic CSS selector, e.g. 'li.jobs h3'
* @param array|string $expectedMatches The content of *all* matching tags as an array
* @throws PHPUnit_Framework_AssertionFailedError
* @return boolean
*/
function assertExactMatchBySelector($selector, $expectedMatches) {
if(is_string($expectedMatches)) $expectedMatches = array($expectedMatches);
$items = $this->cssParser()->getBySelector($selector);
$actuals = array();
@ -179,20 +188,27 @@ class FunctionalTest extends SapphireTest {
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n"
. "Instead the following elements were found:\n'" . implode("'\n'", $actuals) . "'"
);
return false;
}
return true;
}
/**
* Assert that the most recently queried page contains a number of content tags specified by a CSS selector.
*
* The given CSS selector will be applied to the HTML of the most recent page. The content of every matching tag
* will be examined.
*
* The assertion fails if one of the expectedMatches fails to appear.
* will be examined. The assertion fails if one of the expectedMatches fails to appear.
*
* Note:   characters are stripped from the content; make sure that your assertions take this into account.
*
* @param string $selector A basic CSS selector, e.g. 'li.jobs h3'
* @param array|string $expectedMatches The content of at least one of the matched tags
* @throws PHPUnit_Framework_AssertionFailedError
* @return boolean
*/
function assertPartialHTMLMatchBySelector($selector, $expectedMatches) {
if(is_string($expectedMatches)) $expectedMatches = array($expectedMatches);
$items = $this->cssParser()->getBySelector($selector);
$actuals = array();
@ -204,21 +220,24 @@ class FunctionalTest extends SapphireTest {
"Failed asserting the CSS selector '$selector' has an exact match to the expected elements:\n'" . implode("'\n'", $expectedMatches) . "'\n\n"
. "Instead the following elements were found:\n'" . implode("'\n'", array_keys($actuals)) . "'"
);
return;
return false;
}
}
return true;
}
/**
* Assert that the most recently queried page contains a number of content tags specified by a CSS selector.
*
* The given CSS selector will be applied to the HTML of the most recent page. The full HTML of every matching tag
* will be examined.
*
* The assertion fails if one of the expectedMatches fails to appear.
* will be examined. The assertion fails if one of the expectedMatches fails to appear.
*
* Note:   characters are stripped from the content; make sure that your assertions take this into account.
*
* @param string $selector A basic CSS selector, e.g. 'li.jobs h3'
* @param array|string $expectedMatches The content of *all* matched tags as an array
* @throws PHPUnit_Framework_AssertionFailedError
* @return boolean
*/
function assertExactHTMLMatchBySelector($selector, $expectedMatches) {
$items = $this->cssParser()->getBySelector($selector);