working on selenium tests
This commit is contained in:
parent
e1a010d536
commit
7037dd6ac8
@ -12,8 +12,6 @@ class WhatDidTheySayAdmin {
|
||||
'it',
|
||||
'de'
|
||||
),
|
||||
'only_allowed_users' => false,
|
||||
'users' => array(),
|
||||
'capabilities' => array(
|
||||
'submit_transcriptions' => 'administrator',
|
||||
'approve_transcriptions' => 'administrator',
|
||||
@ -124,7 +122,7 @@ class WhatDidTheySayAdmin {
|
||||
*/
|
||||
function user_has_cap($capabilities, $requested_capabilities, $capability_name) {
|
||||
$options = get_option('what-did-they-say-options');
|
||||
|
||||
if (is_array($options)) {
|
||||
$role_cascade = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
|
||||
$allowed_roles = array();
|
||||
$capture_roles = false;
|
||||
@ -139,6 +137,7 @@ class WhatDidTheySayAdmin {
|
||||
$capabilities[$requested_capability] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $capabilities;
|
||||
}
|
||||
@ -227,7 +226,7 @@ class WhatDidTheySayAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
$updated = __('Transcripts updated', 'what-did-they-say');
|
||||
$updated = __('Transcripts updated.', 'what-did-they-say');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -301,7 +300,7 @@ class WhatDidTheySayAdmin {
|
||||
$options['capabilities'][$capability] = $info['capabilities'][$capability];
|
||||
}
|
||||
}
|
||||
$updated = __('User capabilities updated', 'what-did-they-say');
|
||||
$updated = __('User capabilities updated.', 'what-did-they-say');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -312,6 +311,25 @@ class WhatDidTheySayAdmin {
|
||||
return $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle resettings what-did-they-say-options.
|
||||
* @param array $info The part of the $_POST array for What Did They Say?!?
|
||||
* @return string|false A string if a message is to be displayed, or false if no message.
|
||||
*/
|
||||
function handle_update_reset_options($info) {
|
||||
$updated = false;
|
||||
if (current_user_can('manage_options')) {
|
||||
switch ($info['action']) {
|
||||
case "reset_options":
|
||||
delete_option('what-did-they-say-options');
|
||||
$this->install();
|
||||
$updated = __('<strong>What Did They Say?!?</strong> options reset.', 'what-did-they-say');
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a data file containing all the known languages on Earth.
|
||||
* The data originally came from http://www.langtag.net/, specifically http://www.langtag.net/registries/lsr-language.txt.
|
||||
@ -337,6 +355,7 @@ class WhatDidTheySayAdmin {
|
||||
$options = get_option('what-did-they-say-options');
|
||||
if (empty($options)) {
|
||||
$this->default_options['languages'] = $this->build_default_languages();
|
||||
ksort($this->default_options['languages']);
|
||||
update_option('what-did-they-say-options', $this->default_options);
|
||||
}
|
||||
}
|
||||
@ -397,6 +416,7 @@ class WhatDidTheySayAdmin {
|
||||
*/
|
||||
function manage_admin() {
|
||||
$options = get_option('what-did-they-say-options');
|
||||
|
||||
$nonce = wp_create_nonce('what-did-they-say');
|
||||
include(dirname(__FILE__) . '/admin.inc');
|
||||
}
|
||||
@ -408,6 +428,7 @@ class WhatDidTheySayAdmin {
|
||||
global $post;
|
||||
|
||||
$options = get_option('what-did-they-say-options');
|
||||
|
||||
$transcripts = $this->what_did_they_say->get_transcripts($post->ID);
|
||||
$queued_transcriptions = $this->what_did_they_say->get_queued_transcriptions_for_post($post->ID);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="wrap">
|
||||
<h2><?php _e('What Did They Say?!? Settings', 'what-did-they-sahy') ?></h2>
|
||||
|
||||
<?php if (current_user_can('edit_users')) { ?>
|
||||
<?php if (current_user_can('edit_users') && is_array($options)) { ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
|
||||
<input type="hidden" name="wdts[action]" value="capabilities" />
|
||||
@ -32,6 +32,7 @@
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (is_array($options)) { ?>
|
||||
<h3><?php _e('Languages', 'what-did-they-say') ?></h3>
|
||||
|
||||
<table class="widefat fixed">
|
||||
@ -98,7 +99,18 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
<?php if (current_user_can('manage_options')) { ?>
|
||||
<h3><?php _e('Reset Settings to Default', 'what-did-they-say') ?></h3>
|
||||
<p><?php _e('Click the button below to reset capabilities and languages to their defaults. This will not affect any transcriptions you have already created, but some transcriptions may become inaccessible if you don\'t redefine the original language.', 'what-did-they-say') ?></p>
|
||||
<form method="post" id="reset-wdts">
|
||||
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
|
||||
<input type="hidden" name="wdts[action]" value="reset_options" />
|
||||
<input type="submit" class="button" value="<?php _e('Reset What Did They Say?!?', 'what-did-they-say') ?>" />
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$$('form.verify').each(function(f) {
|
||||
Event.observe(f, 'submit', function(e) {
|
||||
@ -118,5 +130,13 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if ($('reset-wdts')) {
|
||||
Event.observe($('reset-wdts'), 'submit', function(e) {
|
||||
if (!confirm('<?php _e('Are you sure? You could leave transcriptions inaccessible.', 'what-did-they-say') ?>')) {
|
||||
Event.stop(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
146
test/TestWhatDidTheySay.html
Normal file
146
test/TestWhatDidTheySay.html
Normal file
@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link rel="selenium.base" href="" />
|
||||
<title>TestWhatDidTheySay</title>
|
||||
</head>
|
||||
<body>
|
||||
<table cellpadding="1" cellspacing="1" border="1">
|
||||
<thead>
|
||||
<tr><td rowspan="1" colspan="3">TestWhatDidTheySay</td></tr>
|
||||
</thead><tbody>
|
||||
<tr>
|
||||
<td>open</td>
|
||||
<td>/wp-admin/</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>link=Installed</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertTextPresent</td>
|
||||
<td>What Did They Say?!?</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>click</td>
|
||||
<td>//table[@id='all-plugins-table']/tbody/tr[15]/td[2]/div/span[1]/a</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>//a[contains(@href,'what-did-they-say') and contains(@href,'activate')]</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertTextPresent</td>
|
||||
<td>Plugin activated.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertElementPresent</td>
|
||||
<td>//a[contains(text(), "What Did They Say?!?")]</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>click</td>
|
||||
<td>link=exact:What Did They Say?!?</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<!--Reset-->
|
||||
<tr>
|
||||
<td>assertTextPresent</td>
|
||||
<td>Reset Settings to Default</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>click</td>
|
||||
<td>//input[@value='Reset What Did They Say?!?']</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertConfirmation</td>
|
||||
<td>Are you sure? You could leave transcriptions inaccessible.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertTextPresent</td>
|
||||
<td>What Did They Say?!? options reset</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<!--Capabilities-->
|
||||
<tr>
|
||||
<td>select</td>
|
||||
<td>wdts[capabilities][submit_transcriptions]</td>
|
||||
<td>label=Editor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>select</td>
|
||||
<td>wdts[capabilities][approve_transcriptions]</td>
|
||||
<td>label=Editor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>select</td>
|
||||
<td>wdts[capabilities][change_languages]</td>
|
||||
<td>label=Editor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>//input[@value='Change capabilities']</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertTextPresent</td>
|
||||
<td>User capabilities updated.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertSelectedLabel</td>
|
||||
<td>wdts[capabilities][submit_transcriptions]</td>
|
||||
<td>Editor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertSelectedLabel</td>
|
||||
<td>wdts[capabilities][approve_transcriptions]</td>
|
||||
<td>Editor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertSelectedLabel</td>
|
||||
<td>wdts[capabilities][change_languages]</td>
|
||||
<td>Editor</td>
|
||||
</tr>
|
||||
<!--Make new language default-->
|
||||
<tr>
|
||||
<td>assertText</td>
|
||||
<td>//th/span[contains(text(), "English")]/../../td[1]</td>
|
||||
<td>(yes)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>clickAndWait</td>
|
||||
<td>//th/span[contains(text(), "German")]/../..//input[@value="Default"]</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertTextPresent</td>
|
||||
<td>German set as default.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertNotText</td>
|
||||
<td>//th/span[contains(text(), "English")]/../../td[1]</td>
|
||||
<td>(yes)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>assertText</td>
|
||||
<td>//th/span[contains(text(), "German")]/../../td[1]</td>
|
||||
<td>(yes)</td>
|
||||
</tr>
|
||||
<!--Add a new language-->
|
||||
|
||||
</tbody></table>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user