Commit 3d4b1549 authored by webchick's avatar webchick
Browse files

#949872 by alex_b, jhodgdon, sun: Fixed filter format assertion randomly failing.

parent 7f9a866c
......@@ -497,9 +497,18 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase {
// the disallowed format does not.
$this->drupalLogin($this->web_user);
$this->drupalGet('node/add/page');
$this->assertRaw($this->formatSelectorHTML($this->allowed_format), t('The allowed text format appears as an option when adding a new node.'));
$this->assertNoRaw($this->formatSelectorHTML($this->disallowed_format), t('The disallowed text format does not appear as an option when adding a new node.'));
$this->assertRaw($this->formatSelectorHTML(filter_format_load(filter_fallback_format())), t('The fallback format appears as an option when adding a new node.'));
$langcode = LANGUAGE_NONE;
$elements = $this->xpath('//select[@name=:name]/option', array(
':name' => "body[$langcode][0][format]",
':option' => $this->allowed_format->format,
));
$options = array();
foreach ($elements as $element) {
$options[(string) $element['value']] = $element;
}
$this->assertTrue(isset($options[$this->allowed_format->format]), t('The allowed text format appears as an option when adding a new node.'));
$this->assertFalse(isset($options[$this->disallowed_format->format]), t('The disallowed text format does not appear as an option when adding a new node.'));
$this->assertTrue(isset($options[filter_fallback_format()]), t('The fallback format appears as an option when adding a new node.'));
}
function testFormatRoles() {
......@@ -644,18 +653,6 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase {
$this->assertNoText($old_title, t('Old title not found.'));
}
/**
* Returns the expected HTML for a particular text format selector.
*
* @param $format
* An object representing the text format for which to return HTML.
* @return
* The expected HTML for that text format's selector.
*/
function formatSelectorHTML($format) {
return '<option value="' . $format->format . '">' . $format->name . '</option>';
}
/**
* Rebuild text format and permission caches in the thread running the tests.
*/
......
......@@ -3020,6 +3020,8 @@ protected function assertNoFieldChecked($id, $message = '') {
* Message to display.
* @return
* TRUE on pass, FALSE on fail.
*
* @todo $id is unusable. Replace with $name.
*/
protected function assertOptionSelected($id, $option, $message = '') {
$elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment