Extracted text and test files from source code
This commit is contained in:
parent
676a7ea81c
commit
e7e66a9245
134 changed files with 0 additions and 14081 deletions
|
@ -1,71 +0,0 @@
|
|||
==================================================================================
|
||||
Date API Installation instructions:
|
||||
==================================================================================
|
||||
1) If you have an earlier version of the Date module on your system, empty the
|
||||
date folder out completely. The files in version 2 have different names and are
|
||||
located in different places.
|
||||
|
||||
2) Download the whole package of files from http://drupal.org/project/date.
|
||||
|
||||
3) Upload the date files to the modules directory. The package includes files
|
||||
needed by the Date API, and optional modules to to create CCK date fields.
|
||||
|
||||
4) Go to admin/build/modules and enable the needed modules from the Date/Time group.
|
||||
|
||||
You should end up with a structure like:
|
||||
|
||||
/drupal/modules/date/date_api.info
|
||||
/drupal/modules/date/date_api.install
|
||||
/drupal/modules/date/date_api.module
|
||||
...
|
||||
|
||||
/drupal/modules/date/date/date.info
|
||||
/drupal/modules/date/date/date.install
|
||||
/drupal/modules/date/date/date.module
|
||||
...
|
||||
|
||||
/drupal/modules/date/date_copy/date_copy.info
|
||||
/drupal/modules/date/date_copy/date_copy.module
|
||||
...
|
||||
|
||||
/drupal/modules/date/date_php4/date_php4.inc
|
||||
/drupal/modules/date/date_php4/date_php4_lib.inc
|
||||
...
|
||||
|
||||
==================================================================================
|
||||
Older PHP versions
|
||||
==================================================================================
|
||||
If you are using PHP 4 or PHP 5.0 or 5.1, native date handling won't work right.
|
||||
Install the Date_PHP4 module to enable wrapper functions so this code will work
|
||||
in old PHP versions.
|
||||
|
||||
==================================================================================
|
||||
Enable Date Timezone
|
||||
==================================================================================
|
||||
In most cases, you should enable the Date Timezone module any time you use the
|
||||
Date API to be able to set the site and user timezone names. It is not enabled by
|
||||
default in case another module is setting timezone names in the database.
|
||||
|
||||
Once you have enabled it, go to admin/settings/date-time and set the default
|
||||
site timezone name. If you are using user timezones, go to your account settings
|
||||
and set up your own timezone name.
|
||||
|
||||
==================================================================================
|
||||
Install CCK Date Fields:
|
||||
==================================================================================
|
||||
|
||||
1) The CCK date field is included in the Date files at http://drupal.org/project/date.
|
||||
|
||||
2) Go to admin/build/modules and enable the Date module. Be sure that the Date API module,
|
||||
the Date Timezone module, and the Content module are also installed.
|
||||
|
||||
3) Go to admin/content/types to view cck content types and edit a content type.
|
||||
|
||||
4) Make sure the default timezone name has been set at admin/settings/date-time.
|
||||
|
||||
5) While viewing a content type, select the option to add a new field from the tabs at
|
||||
the top of the page. Several options for date fields should be visible.
|
||||
|
||||
==================================================================================
|
||||
More documentation is available at http://drupal.org/node/92460.
|
||||
==================================================================================
|
|
@ -1,282 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Theme functions.
|
||||
*/
|
||||
/**
|
||||
* @addtogroup themeable
|
||||
* @{
|
||||
*
|
||||
* Formatter themes
|
||||
*/
|
||||
/**
|
||||
* Theme from/to date combination in the view.
|
||||
*
|
||||
* Useful values:
|
||||
*
|
||||
* $node->date_id
|
||||
* If set, this will show only an individual date on a field with
|
||||
* multiple dates. The value should be a string that contains
|
||||
* the following values, separated with periods:
|
||||
* - module name of the module adding the item
|
||||
* - node nid
|
||||
* - field name
|
||||
* - delta value of the field to be displayed
|
||||
* - other information the module's custom theme might need
|
||||
*
|
||||
* Used by the calendar module and available for other uses.
|
||||
* example: 'date.217.field_date.3.test'
|
||||
*
|
||||
* $node->date_repeat_show
|
||||
* If true, tells the theme to show all the computed values
|
||||
* of a repeating date. If not true or not set, only the
|
||||
* start date and the repeat rule will be displayed.
|
||||
*
|
||||
* $dates['format'] - the format string used on these dates
|
||||
* $dates['value']['local']['object'] - the local date object for the From date
|
||||
* $dates['value2']['local']['object'] - the local date object for the To date
|
||||
* $dates['value']['local']['datetime'] - the datetime value of the From date database (GMT) value
|
||||
* $dates['value2']['local']['datetime'] - the datetime value of the To date database (GMT) value
|
||||
* $dates['value']['formatted'] = formatted From date, i.e. 'February 15, 2007 2:00 pm';
|
||||
* $dates['value']['formatted_date'] - only the date part of the formatted From date
|
||||
* $dates['value']['formatted_time'] - only the time part of the formatted From date
|
||||
* $dates['value2']['formatted'] = formatted To date, i.e. 'February 15, 2007 6:00 pm';
|
||||
* $dates['value2']['formatted_date'] - only the date part of the formatted To date
|
||||
* $dates['value2']['formatted_time'] - only the time part of the formatted To date
|
||||
*/
|
||||
function theme_date_display_combination($element) {
|
||||
static $repeating_ids = array();
|
||||
|
||||
$node = $element['#node'];
|
||||
$field_name = $element['#field_name'];
|
||||
$context = !empty($node->content) && !empty($node->content[$field_name]) ? $node->content[$field_name]['#context'] : 'full';
|
||||
$type_name = $element['#type_name'];
|
||||
$fields = content_fields();
|
||||
$field = $fields[$field_name];
|
||||
$item = $element['#item'];
|
||||
|
||||
// Get the formatter settings, either the default settings for this node
|
||||
// type or the View settings stored in $node->date_info.
|
||||
$options = date_formatter_get_settings($field_name, $type_name, $context);
|
||||
if (!empty($node->date_info) && !empty($node->date_info->formatter_settings)) {
|
||||
$options = $node->date_info->formatter_settings;
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
// If date_id is set for this field and the delta doesn't match, don't display it.
|
||||
if (!empty($node->date_id)) {
|
||||
foreach ((array) $node->date_id as $key => $id) {
|
||||
list($module, $nid, $field_name, $delta, $other) = explode('.', $id);
|
||||
if ($field_name == $field['field_name'] && isset($item['#delta']) && $delta != $item['#delta']) {
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check the formatter settings to see if the repeat rule should be
|
||||
// displayed. Show it only with the first multiple value date.
|
||||
if (!in_array($node->nid, $repeating_ids) && module_exists('date_repeat')
|
||||
&& !empty($item['rrule']) && $options['repeat']['show_repeat_rule'] == 'show') {
|
||||
require_once('./'. drupal_get_path('module', 'date') .'/date_repeat.inc');
|
||||
$output .= theme('date_repeat_display', $field, $item, $node);
|
||||
$repeating_ids[] = $node->nid;
|
||||
}
|
||||
|
||||
// If this is a full node or a pseudo node created by grouping
|
||||
// multiple values, see exactly which values are supposed to be visible.
|
||||
if (isset($node->$field_name)) {
|
||||
$node = date_prepare_node($node, $field, $type_name, $context, $options);
|
||||
// Did the current value get removed by formatter settings?
|
||||
if (empty($node->{$field_name}[$item['#delta']])) {
|
||||
return $output;
|
||||
}
|
||||
// Adjust the $element values to match the changes.
|
||||
$element['#node'] = $node;
|
||||
}
|
||||
|
||||
// Call the right theme for this formatter.
|
||||
// Update the element with values that might have been altered by
|
||||
// date_prepare_node() and figure out which values to display.
|
||||
$dates = date_formatter_process($element);
|
||||
switch ($options['fromto']['fromto']) {
|
||||
case 'value':
|
||||
$date1 = $dates['value']['formatted'];
|
||||
$date2 = $date1;
|
||||
break;
|
||||
case 'value2':
|
||||
$date2 = $dates['value2']['formatted'];
|
||||
$date1 = $date2;
|
||||
break;
|
||||
default:
|
||||
$date1 = $dates['value']['formatted'];
|
||||
$date2 = $dates['value2']['formatted'];
|
||||
break;
|
||||
}
|
||||
|
||||
// Pull the timezone, if any, out of the formatted result and tack it
|
||||
// back on at the end, if it is in the current formatted date.
|
||||
$timezone = $dates['value']['formatted_timezone'];
|
||||
if ($timezone) {
|
||||
$timezone = ' ' . $timezone;
|
||||
}
|
||||
$date1 = str_replace($timezone, '', $date1);
|
||||
$date2 = str_replace($timezone, '', $date2);
|
||||
|
||||
// No date values, display nothing.
|
||||
if (empty($date1) && empty($date2)) {
|
||||
$output .= '';
|
||||
}
|
||||
// From and To dates match or there is no To date, display a complete single date.
|
||||
elseif ($date1 == $date2 || empty($date2)) {
|
||||
$output .= theme('date_display_single', $date1, $timezone);
|
||||
}
|
||||
// Same day, different times, don't repeat the date but show both From and To times.
|
||||
elseif (date_has_time($field['granularity']) && $dates['value']['formatted_date'] == $dates['value2']['formatted_date']) {
|
||||
// Replace the original time with the from/to time in the formatted start date.
|
||||
// Make sure that parentheses or brackets wrapping the time will be retained in the
|
||||
// final result.
|
||||
$time1 = preg_replace('`^([\(\[])`', '', $dates['value']['formatted_time']);
|
||||
$time1 = preg_replace('([\)\]]$)', '', $time1);
|
||||
$time2 = preg_replace('`^([\(\[])`', '', $dates['value2']['formatted_time']);
|
||||
$time2 = preg_replace('([\)\]]$)', '', $time2);
|
||||
$time = theme('date_display_range', $time1, $time2);
|
||||
$replaced = str_replace($time1, $time, $date1);
|
||||
$output .= theme('date_display_single', $replaced, $timezone);
|
||||
}
|
||||
// Different days, display both in their entirety.
|
||||
else {
|
||||
$output .= theme('date_display_range', $date1, $date2, $timezone);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function theme_date_display_single($date, $timezone = NULL) {
|
||||
return '<span class="date-display-single">'. $date . $timezone .'</span>';
|
||||
}
|
||||
|
||||
function theme_date_display_range($date1, $date2, $timezone = NULL) {
|
||||
return '<span class="date-display-start">'. $date1 .'</span>'.
|
||||
'<span class="date-display-separator"> - </span>' .
|
||||
'<span class="date-display-end">'. $date2 . $timezone. '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme a format interval for a date element
|
||||
*
|
||||
* @param $field = the field settings
|
||||
* @param $node = node information, this is not always available and not
|
||||
* always the full node, it depends on what value was provided to the formatter.
|
||||
* Only the nid is always guaranteed to be available.
|
||||
* @param $dates - an array of date information, see explanation for date_field_object for details.
|
||||
* @return a formatted display
|
||||
*
|
||||
*/
|
||||
function theme_date_format_interval($element) {
|
||||
$node = $element['#node'];
|
||||
$field_name = $element['#field_name'];
|
||||
$context = !empty($node->content) ? $node->content[$field_name]['#context'] : 'full';
|
||||
$type_name = $element['#type_name'];
|
||||
$fields = content_fields();
|
||||
$field = $fields[$field_name];
|
||||
$item = $element['#item'];
|
||||
|
||||
// Get the formatter settings, either the default settings for this node
|
||||
// type or the View settings stored in $node->date_info.
|
||||
$options = date_formatter_get_settings($field_name, $type_name, $context);
|
||||
if (!empty($node->date_info) && !empty($node->date_info->formatter_settings)) {
|
||||
$options = $node->date_info->formatter_settings;
|
||||
}
|
||||
|
||||
// If date_id is set for this field and the delta doesn't match, don't display it.
|
||||
if (!empty($node->date_id)) {
|
||||
foreach ((array) $node->date_id as $key => $id) {
|
||||
list($module, $nid, $field_name, $delta, $other) = explode('.', $id);
|
||||
if ($field_name == $field['field_name'] && isset($item['#delta']) && $delta != $item['#delta']) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this is not coming from Views, it is the full node.
|
||||
// If we aren't retrieving a specific value, adjust the node values
|
||||
// to match the formatter settings, removing values we should not see.
|
||||
if (!empty($node->content) && empty($node->date_id)) {
|
||||
$node = date_prepare_node($node, $field, $type_name, $context, $options);
|
||||
|
||||
// Did the current value get removed by formatter settings?
|
||||
if (empty($node->{$field_name}[$item['#delta']])) {
|
||||
return;
|
||||
}
|
||||
// Adjust the $element values to match the changes.
|
||||
$element['#node'] = $node;
|
||||
}
|
||||
$dates = date_formatter_process($element);
|
||||
return theme('date_time_ago', $dates['value']['local']['object'], $dates['value2']['local']['object']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the human-readable description for a Date Repeat rule.
|
||||
*
|
||||
* TODO -
|
||||
* add in ways to store the description in the date so it isn't regenerated
|
||||
* over and over and find a way to allow description to be shown or hidden.
|
||||
*/
|
||||
function theme_date_repeat_display($field, $item, $node = NULL) {
|
||||
$output = '';
|
||||
if (!empty($item['rrule'])) {
|
||||
$output = date_repeat_rrule_description($item['rrule']);
|
||||
$output = '<div>'. $output .'</div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust from/to date format to account for 'all day'.
|
||||
*
|
||||
* @param array $field, the field definition for this date field.
|
||||
* @param string $which, which value to return, 'date1' or 'date2'.
|
||||
* @param object $date1, a date/time object for the 'from' date.
|
||||
* @param object $date2, a date/time object for the 'to' date.
|
||||
* @param string $format
|
||||
* @param object $node, the node this date comes from (may be incomplete, always contains nid).
|
||||
* @param object $view, the view this node comes from, if applicable.
|
||||
* @return formatted date.
|
||||
*/
|
||||
function theme_date_all_day($field, $which, $date1, $date2, $format, $node, $view = NULL) {
|
||||
|
||||
if (empty($date1) || !is_object($date1) || $format == 'format_interval') {
|
||||
return;
|
||||
}
|
||||
if (empty($date2)) {
|
||||
$date2 = $date1;
|
||||
}
|
||||
|
||||
$suffix = '';
|
||||
if (!date_has_time($field['granularity'])) {
|
||||
$format = date_limit_format($format, array('year', 'month', 'day'));
|
||||
}
|
||||
else {
|
||||
$format_granularity = date_format_order($format);
|
||||
$format_has_time = FALSE;
|
||||
if (in_array('hour', $format_granularity)) {
|
||||
$format_has_time = TRUE;
|
||||
}
|
||||
$all_day = date_field_all_day($field, $date1, $date2);
|
||||
if ($all_day && $format_has_time) {
|
||||
$format = date_limit_format($format, array('year', 'month', 'day'));
|
||||
$suffix = ' ' . theme('date_all_day_label');
|
||||
}
|
||||
}
|
||||
|
||||
return trim(date_format_date($$which, 'custom', $format) . $suffix);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the way an 'all day' label will look.
|
||||
*/
|
||||
function theme_date_all_day_label() {
|
||||
return '('. date_t('All day', 'datetime') .')';
|
||||
}
|
||||
/** @} End of addtogroup themeable */
|
|
@ -1,281 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test FAQ functionality Base test class. All tests inherits this one.
|
||||
* Hugely based on code from the test file block.test by boombatower
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class that is extended by test cases.
|
||||
*/
|
||||
class FaqTestCase extends DrupalWebTestCase {
|
||||
|
||||
|
||||
protected $admin_user, $faq_user;
|
||||
protected $taxonomy;
|
||||
protected $term, $faq1, $faq2;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('FAQ functionality'),
|
||||
'description' => t('Base class. No tests here.'),
|
||||
'group' => t('Frequently Asked Questions'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
|
||||
// Install FAQ Module.
|
||||
parent::setUp('taxonomy', 'faq');
|
||||
|
||||
// Create and log in user with administer taxonomy permissions.
|
||||
$this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'administer faq', 'administer faq order', 'administer blocks'));
|
||||
$this->faq_user = $this->drupalCreateUser(array('create faq', 'edit faq', 'delete faq content', 'view faq page', 'access content'));
|
||||
$this->view_faq_user = $this->drupalCreateUser(array('view faq page', 'access content'));
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
||||
// Set up the vocab and terms.
|
||||
$this->setupTaxonomy();
|
||||
|
||||
// Categorize questions.
|
||||
$this->drupalPost('admin/settings/faq/categories', array('faq_use_categories' => '1'), t('Save configuration'));
|
||||
|
||||
// Set answer_user as default expert.
|
||||
$roles = $this->faq_user->roles;
|
||||
end($roles); // Set to last role (the unique one)
|
||||
|
||||
// Start all tests logged out.
|
||||
$this->drupalLogout();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear the whole thing down again
|
||||
*/
|
||||
function tearDown() {
|
||||
|
||||
// Things to tidy up like vars and stuff
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random string of ASCII numeric characters (values 48 to 57).
|
||||
*
|
||||
* @param $length
|
||||
* Length of random string to generate .
|
||||
* @return
|
||||
* Randomly generated string.
|
||||
*/
|
||||
protected static function randomNumber($length = 8) {
|
||||
$str = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$str .= chr(mt_rand(48, 57));
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that current user has no access to page.
|
||||
*
|
||||
* @param $url
|
||||
* URL to verify.
|
||||
*/
|
||||
function faqVerifyNoAccess($url) {
|
||||
// Test that page returns 403 Access Denied
|
||||
$this->drupalGet($url);
|
||||
$this->assertResponse(403);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the taxonomy - all vocabularies and stuff
|
||||
* Values also stored in protected variable $tax
|
||||
*/
|
||||
function setupTaxonomy() {
|
||||
|
||||
// Create vocabulary.
|
||||
$this->taxonomy = array();
|
||||
$this->taxonomy['name'] = $this->randomName(8); // Create taxonomy vocabulary name
|
||||
$this->taxonomy['description'] = $this->randomName(64);
|
||||
$this->taxonomy['nodes[faq]'] = '1'; // Assign vocab to FAQ node types
|
||||
$this->taxonomy['tags'] = '1'; // Users may create tags
|
||||
$this->taxonomy['multiple'] = '1'; // may have more than one tag
|
||||
$this->taxonomy['required'] = '1'; // but minimum 1 tag
|
||||
$this->drupalPost('admin/content/taxonomy/add/vocabulary', $this->taxonomy, t('Save'));
|
||||
$this->assertText(t('Created new vocabulary @name', array('@name' => $this->taxonomy['name'])));
|
||||
|
||||
$this->assertText(t('FAQ'));
|
||||
|
||||
// Add term
|
||||
// Click the last occurrence of the link.
|
||||
$this->clickLink(t('add terms'), substr_count($this->drupalGetContent(), 'add terms') - 1);
|
||||
$this->assertText(t('Add term to @name', array('@name' => $this->taxonomy['name']) ));
|
||||
|
||||
$url = parse_url($this->getUrl());
|
||||
if ($url['query'] == '') {
|
||||
$array = split('/', $url['path']);
|
||||
$this->taxonomy['id'] = $array[4];
|
||||
}
|
||||
else {
|
||||
$array = split('/', $url['query']);
|
||||
$this->taxonomy['id'] = $array[3];
|
||||
}
|
||||
$this->pass(var_export($array, TRUE));
|
||||
|
||||
$url = $this->getUrl();
|
||||
$this->term = array();
|
||||
$this->term['name'] = $this->randomName(8); // Create taxonomy vocabulary name
|
||||
$this->term['description'] = $this->randomName(64);
|
||||
$this->drupalPost($url, $this->term, t('Save'));
|
||||
$this->assertText(t('Created new term @name', array('@name' => $this->term['name'])));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FaqAccessTestClass extends FaqTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Access to FAQ pages'),
|
||||
'description' => t('Access to pages by anonymous user and logged in user with rights.'),
|
||||
'group' => t('Frequently Asked Questions'),
|
||||
);
|
||||
}
|
||||
|
||||
function testFaqAccess() {
|
||||
|
||||
// Verify that anonymous user has no access to the faq page
|
||||
$this->faqVerifyNoAccess('faq');
|
||||
|
||||
// Create and login user
|
||||
$normal_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($normal_user);
|
||||
|
||||
// Verify that logged in user has no access to the faq page
|
||||
$this->faqVerifyNoAccess('faq');
|
||||
$this->drupalLogout();
|
||||
|
||||
$this->drupalLogin($this->view_faq_user);
|
||||
|
||||
// Verify that the faq page is visible and available but empty
|
||||
$this->drupalGet('faq');
|
||||
$this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CRUDFaqTestCase extends FaqTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('CRUD FAQ node'),
|
||||
'description' => t('Create, Read, Update and Delete a FAQ node.'),
|
||||
'group' => t('Frequently Asked Questions'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creating a FAQ node
|
||||
*/
|
||||
function testFaqCreate() {
|
||||
|
||||
// Log in user with create FAQ permissions
|
||||
$this->drupalLogin($this->faq_user);
|
||||
|
||||
// Fill in the Create FAQ node 1 form and post it
|
||||
$this->faq1 = array();
|
||||
$this->faq1['title'] = $this->randomName(8);
|
||||
$this->faq1['taxonomy[tags][1]'] = $this->term['name']; // Add existing term
|
||||
$this->faq1['detailed_question'] = $this->randomName(16);
|
||||
$this->faq1['body'] = $this->randomName(16);
|
||||
$this->drupalPost('node/add/faq', $this->faq1, t('Save'));
|
||||
|
||||
// Check that new FAQ node has actually been created
|
||||
$this->assertText(t('FAQ @title has been created.', array('@title' => $this->faq1['title'])));
|
||||
|
||||
// Fill in the Create FAQ node 2 form and post it
|
||||
$this->faq2 = array();
|
||||
$this->faq2['title'] = $this->randomName(8);
|
||||
$this->faq2['taxonomy[tags][1]'] = $this->randomName(8); // Add new term
|
||||
$this->faq2['detailed_question'] = $this->randomName(16);
|
||||
$this->faq2['body'] = $this->randomName(16);
|
||||
$this->drupalPost('node/add/faq', $this->faq2, t('Save'));
|
||||
|
||||
// Check that new FAQ node has actually been created
|
||||
$this->assertText(t('FAQ @title has been created.', array('@title' => $this->faq2['title'])));
|
||||
|
||||
$this->drupalLogout();
|
||||
|
||||
// Check that the FAQ page is available and that the correct term is listed as grouping for the new FAQ node
|
||||
$this->drupalLogin($this->view_faq_user);
|
||||
$this->drupalGet('faq');
|
||||
$this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
|
||||
$this->assertText($this->faq1['title'], t('Created FAQ node 1 available on FAQ page.'));
|
||||
$this->assertText($this->faq1['taxonomy[tags][1]'], t('Term for node 1 available on FAQ page.'));
|
||||
$this->assertText($this->faq2['title'], t('Created FAQ node 2 available on FAQ page.'));
|
||||
$this->assertText($this->faq2['taxonomy[tags][1]'], t('Term for node 2 available on FAQ page.'));
|
||||
|
||||
// Navigate to FAQ node created on FAQ page
|
||||
$this->clickLink(t($this->faq1['title']));
|
||||
$this->assertText(t($this->faq1['body']));
|
||||
|
||||
// Log in user with administer FAQ settings.
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
||||
// Enable categorisation of FAQ nodes
|
||||
// faq_use_categories
|
||||
$conf = array();
|
||||
$conf['faq_use_categories'] = '1'; // Enable categorised FAQs
|
||||
$this->drupalPost('admin/settings/faq/categories', $conf, t('Save configuration'));
|
||||
$this->drupalLogout();
|
||||
|
||||
$this->drupalLogin($this->view_faq_user);
|
||||
$this->drupalGet('faq');
|
||||
$this->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
|
||||
$this->assertText($this->faq1['title'], t('Created FAQ node 1 available on FAQ page.'));
|
||||
$this->assertText($this->faq1['taxonomy[tags][1]'], t('Term for node 1 not available on FAQ page.'));
|
||||
$this->assertText($this->faq2['title'], t('Created FAQ node 2 available on FAQ page.'));
|
||||
$this->assertText($this->faq2['taxonomy[tags][1]'], t('Term for node 2 not available on FAQ page.'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test editing and deleting of an FAQ node.
|
||||
*/
|
||||
public function testFaqEditDelete() {
|
||||
|
||||
// Log in user with create FAQ permissions
|
||||
$this->drupalLogin($this->faq_user);
|
||||
|
||||
// Create a FAQ node.
|
||||
$edit = array();
|
||||
$edit['title'] = $this->randomName(8);
|
||||
$edit['taxonomy[tags][' . $this->taxonomy['id'] . ']'] = $this->randomName(8);
|
||||
$edit['detailed_question'] = $this->randomName(64);
|
||||
$edit['body'] = $this->randomString(264);
|
||||
$this->drupalPost('node/add/faq', $edit, t('Save'));
|
||||
$this->assertText(t('FAQ @title has been created.', array('@title' => $edit['title'])));
|
||||
|
||||
// Check status for FAQ node - should be published
|
||||
$node = $this->drupalGetNodeByTitle($edit['title']);
|
||||
$this->assertTrue($node->status);
|
||||
|
||||
// Update FAQ
|
||||
$this->drupalGet('node/' . $node->nid . '/edit'); // Open edit page with node
|
||||
$edit2['title'] = 'title-' . $this->randomName(8);
|
||||
$edit2['body'] = 'body-' . $this->randomName(64);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', array('title' => $edit2['title'], 'body' => $edit2['body']), t('Save'));
|
||||
$this->assertText(t('FAQ @title has been updated.', array('@title' => $edit2['title'])));
|
||||
$this->assertText($edit2['title'], 'Title has changed');
|
||||
$this->assertText($edit2['body'], 'Body has changed');
|
||||
|
||||
// Delete FAQ
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', array(), t('Delete'));
|
||||
$this->assertText(t('Are you sure you want to delete @title?', array('@title' => $edit2['title'])));
|
||||
$this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
|
||||
$this->assertText(t('FAQ @title has been deleted.', array('@title' => $edit2['title'])));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,553 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the GeSHi filter module.
|
||||
*/
|
||||
|
||||
|
||||
// @todo: test the tag style widget, both on general settings form and format specific form: at least one tag style should be selected.
|
||||
|
||||
/**
|
||||
* Funcional tests for the GeSHi filter administration.
|
||||
*/
|
||||
class GeshiFilterAdministrationTest extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* A global filter adminstrator
|
||||
*/
|
||||
protected $filter_admin_user;
|
||||
|
||||
/**
|
||||
* The id of the input format with only GeSHi filter in it
|
||||
*/
|
||||
protected $input_format_id;
|
||||
|
||||
/**
|
||||
* Drupal SimpleTest method: return metadata about the test.
|
||||
*/
|
||||
function getInfo() {
|
||||
return array(
|
||||
'name' => t('GeSHi filter administration'),
|
||||
'description' => t('Test the GeSHi filter administration.'),
|
||||
'group' => t('GeSHi filter module'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SimpleTest core method: code run before each and every test method.
|
||||
*
|
||||
* Optional. You only need this if you have setup tasks.
|
||||
*/
|
||||
function setUp() {
|
||||
// Make sure the GeSHi filter module is enabled.
|
||||
parent::setUp('geshifilter');
|
||||
// And set the path to the geshi library.
|
||||
variable_set('geshifilter_geshi_dir','libraries/geshi');
|
||||
|
||||
// Create a filter admin user
|
||||
$permissions = array('administer filters', 'administer site configuration');
|
||||
$this->filter_admin_user = $this->drupalCreateUser($permissions);
|
||||
|
||||
// log in with filter admin user
|
||||
$this->drupalLogin($this->filter_admin_user);
|
||||
|
||||
// add an input format with only geshi filter
|
||||
$edit = array(
|
||||
'name' => $this->randomName(10, 'inputformat_'),
|
||||
'filters[geshifilter/0]' => TRUE,
|
||||
'roles[2]' => TRUE,
|
||||
);
|
||||
$this->drupalPost('admin/settings/filters/add', $edit, t('Save configuration'));
|
||||
// store the format id of the created input format
|
||||
$this->input_format_id = db_result(db_query("SELECT format FROM {filter_formats} WHERE name = '%s'", $edit['name']));
|
||||
$this->assertTrue($this->input_format_id, t('Input format id (%s)'));
|
||||
|
||||
// set some default GeSHi filter admin settings
|
||||
variable_set('geshifilter_format_specific_options', FALSE);
|
||||
variable_set('geshifilter_tag_styles', array(
|
||||
GESHIFILTER_BRACKETS_ANGLE => GESHIFILTER_BRACKETS_ANGLE,
|
||||
GESHIFILTER_BRACKETS_SQUARE => GESHIFILTER_BRACKETS_SQUARE,
|
||||
));
|
||||
variable_set('geshifilter_default_line_numbering', GESHIFILTER_LINE_NUMBERS_DEFAULT_NONE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* SimpleTest core method: code run after each and every test method.
|
||||
*
|
||||
* Optional. You only need this if you have setup tasks.
|
||||
*/
|
||||
function tearDown() {
|
||||
// Remove input format.
|
||||
$this->drupalPost('admin/settings/filters/delete/'. $this->input_format_id, array(), t('Delete'));
|
||||
|
||||
// Always call the tearDown() function from the parent class.
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check tag unicity: tags should differ between languages and from generic tags
|
||||
*/
|
||||
function test_tag_unicity() {
|
||||
// enable some languages first
|
||||
variable_set('geshifilter_language_enabled_php', TRUE);
|
||||
variable_set('geshifilter_language_enabled_python', TRUE);
|
||||
|
||||
// first round: without format specific tag options
|
||||
variable_set('geshifilter_format_specific_options', FALSE);
|
||||
variable_set('geshifilter_tags', 'code blockcode generictag');
|
||||
|
||||
// a language tag should differ from the generic tags
|
||||
$form_values = array(
|
||||
'geshifilter_language_tags_php' => 'php generictag',
|
||||
);
|
||||
$this->drupalPost('admin/settings/geshifilter/languages', $form_values, t('Save configuration'));
|
||||
$this->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ from generic tags (with generic tag options)'));
|
||||
|
||||
// language tags should differ between languages
|
||||
$form_values = array(
|
||||
'geshifilter_language_tags_php' => 'php languagetag',
|
||||
'geshifilter_language_tags_python' => 'languagetag python',
|
||||
);
|
||||
$this->drupalPost('admin/settings/geshifilter/languages/all', $form_values, t('Save configuration'));
|
||||
$this->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ between languages (with generic tag options)'));
|
||||
|
||||
// second round: with format specific tag options
|
||||
variable_set('geshifilter_format_specific_options', TRUE);
|
||||
variable_set('geshifilter_tags_' . $this->input_format_id, 'code blockcode generictag');
|
||||
|
||||
// a language tag should differ from the generic tags
|
||||
$form_values = array(
|
||||
'geshifilter_language_tags_php_' . $this->input_format_id => 'php generictag',
|
||||
);
|
||||
$this->drupalPost('admin/settings/filters/' . $this->input_format_id . '/configure', $form_values, t('Save configuration'));
|
||||
$this->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ from generic tags (with format specific tag options)'));
|
||||
|
||||
// language tags should differ between languages
|
||||
$form_values = array(
|
||||
'geshifilter_language_tags_php_' . $this->input_format_id => 'php languagetag',
|
||||
'geshifilter_language_tags_python_' . $this->input_format_id => 'languagetag python',
|
||||
);
|
||||
$this->drupalPost('admin/settings/filters/' . $this->input_format_id . '/configure', $form_values, t('Save configuration'));
|
||||
$this->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ between languages (with format specific tag options)'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class GeshiFilterTest extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* A global filter adminstrator
|
||||
*/
|
||||
protected $filter_admin_user;
|
||||
|
||||
/**
|
||||
* A global user for adding pages
|
||||
*/
|
||||
protected $normal_user;
|
||||
|
||||
/**
|
||||
* The id of the input format with only GeSHi filter in it
|
||||
*/
|
||||
protected $input_format_id;
|
||||
|
||||
/**
|
||||
* Drupal SimpleTest method: return metadata about the test.
|
||||
*/
|
||||
function getInfo() {
|
||||
return array(
|
||||
'name' => t('GeSHi input filter'),
|
||||
'description' => t('Test the input filter capabilities of the GeSHi filter.'),
|
||||
'group' => t('GeSHi filter module'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SimpleTest core method: code run before each and every test method.
|
||||
*
|
||||
* Optional. You only need this if you have setup tasks.
|
||||
*/
|
||||
function setUp() {
|
||||
// Make sure that Geshi filter module is enabled.
|
||||
parent::setUp('geshifilter');
|
||||
// And set the path to the geshi library.
|
||||
variable_set('geshifilter_geshi_dir','libraries/geshi');
|
||||
|
||||
// Create a filter admin user
|
||||
$permissions = array(
|
||||
'administer filters',
|
||||
);
|
||||
$this->filter_admin_user = $this->drupalCreateUser($permissions);
|
||||
// Create a normal user for page creation
|
||||
$permissions = array(
|
||||
'edit own page content',
|
||||
'create page content'
|
||||
);
|
||||
$this->normal_user = $this->drupalCreateUser($permissions);
|
||||
|
||||
// log in with filter admin user
|
||||
$this->drupalLogin($this->filter_admin_user);
|
||||
|
||||
// add an input format with only geshi filter
|
||||
$edit = array(
|
||||
'name' => $this->randomName(10, 'inputformat_'),
|
||||
'filters[geshifilter/0]' => TRUE,
|
||||
'filters[filter/0]' => FALSE,
|
||||
'filters[filter/1]' => FALSE,
|
||||
'filters[filter/2]' => FALSE,
|
||||
'filters[filter/3]' => FALSE,
|
||||
'roles[2]' => TRUE,
|
||||
);
|
||||
$this->drupalPost('admin/settings/filters/add', $edit, t('Save configuration'));
|
||||
// store the format id of the created input format
|
||||
$this->input_format_id = db_result(db_query("SELECT format FROM {filter_formats} WHERE name = '%s'", $edit['name']));
|
||||
$this->assertTrue($this->input_format_id, t('Valid input format id'));
|
||||
|
||||
// set some default GeSHi filter admin settings
|
||||
// Set default highlighting mode to "do nothing".
|
||||
variable_set('geshifilter_default_highlighting', GESHIFILTER_DEFAULT_PLAINTEXT);
|
||||
variable_set('geshifilter_format_specific_options', FALSE);
|
||||
variable_set('geshifilter_tag_styles', array(
|
||||
GESHIFILTER_BRACKETS_ANGLE => GESHIFILTER_BRACKETS_ANGLE,
|
||||
GESHIFILTER_BRACKETS_SQUARE => GESHIFILTER_BRACKETS_SQUARE,
|
||||
));
|
||||
variable_set('geshifilter_default_line_numbering', GESHIFILTER_LINE_NUMBERS_DEFAULT_NONE);
|
||||
|
||||
// log out as filter admin
|
||||
$this->drupalGet('logout');
|
||||
|
||||
// log in as the normal user for adding pages
|
||||
$this->drupalLogin($this->normal_user);
|
||||
|
||||
// include GeSHi filtering functions
|
||||
require_once(drupal_get_path('module', 'geshifilter') .'/geshifilter.pages.inc');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* SimpleTest core method: code run after each and every test method.
|
||||
*
|
||||
* Optional. You only need this if you have setup tasks.
|
||||
*/
|
||||
function tearDown() {
|
||||
// log in as filter admin
|
||||
$this->drupalGet('logout');
|
||||
$this->drupalLogin($this->filter_admin_user);
|
||||
|
||||
// remove input format
|
||||
$this->drupalPost('admin/settings/filters/delete/'. $this->input_format_id, array(), t('Delete'));
|
||||
|
||||
// Always call the tearDown() function from the parent class.
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert function for testing if GeSHi highlighting works
|
||||
* @param string $body the body text of the node
|
||||
* @param array $check_list list of items that should be in rendered output (assertRaw)
|
||||
* an item is something like array($source_code, $lang, $line_numbering, $linenumbers_start, $inline_mode)
|
||||
* if $lang is set, GeSHifilter syntax highlighting is applied to $sourcecode
|
||||
* if $lang is false, $sourcecode is directly looked for
|
||||
* @param string $description description of the assertion
|
||||
* @param boolean $invert if assertNoRaw should be used instead of assertRaw
|
||||
*/
|
||||
function assertGeshiFilterHighlighting($body, $check_list, $description, $invert=false) {
|
||||
// Create content.
|
||||
$edit = array(
|
||||
'title' => $this->randomName(32, 'simpletest_pagetitle_'),
|
||||
'body' => $body ."\n". $this->randomName(100),
|
||||
'format' => $this->input_format_id,
|
||||
);
|
||||
// Post node
|
||||
$this->drupalPost('node/add/page', $edit, t('Save'));
|
||||
// check posted node
|
||||
$node = node_load(array('title' => $edit['title']));
|
||||
$this->assertTrue($node, 'Node found in database. %s');
|
||||
// check if highlighting succeeded
|
||||
foreach ($check_list as $fragment) {
|
||||
list($source_code, $lang, $line_numbering, $linenumbers_start, $inline_mode) = $fragment;
|
||||
if ($lang) {
|
||||
// apply syntax highlighting
|
||||
$source_code = geshifilter_geshi_process($source_code, $lang, $line_numbering, $linenumbers_start, $inline_mode);
|
||||
}
|
||||
if ($invert) {
|
||||
$this->assertNoRaw($source_code, $description);
|
||||
}
|
||||
else {
|
||||
$this->assertRaw($source_code, $description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the standard functionality of the generic tags
|
||||
*/
|
||||
function testGenericTags() {
|
||||
variable_set('geshifilter_tags', 'code');
|
||||
variable_set('geshifilter_language_enabled_c', TRUE);
|
||||
variable_set('geshifilter_language_enabled_cpp', TRUE);
|
||||
variable_set('geshifilter_language_enabled_csharp', TRUE);
|
||||
variable_set('geshifilter_language_enabled_java', TRUE);
|
||||
|
||||
// body material
|
||||
$source_code = "//C++-ish source code\nfor (int i=0; i<10; ++i) {\n fun(i);\n bar.foo(x, y);\n server->start(&pool); \n}";
|
||||
|
||||
// check language argument
|
||||
$this->assertGeshiFilterHighlighting('<code type="cpp">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Checking type="..." argument'));
|
||||
$this->assertGeshiFilterHighlighting('<code lang="cpp">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Checking lang="..." argument'));
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Checking language="..." argument'));
|
||||
|
||||
// check some languages
|
||||
$languages = array('c', 'cpp', 'java');
|
||||
foreach ($languages as $lang) {
|
||||
$this->assertGeshiFilterHighlighting('<code language="'. $lang .'">'. $source_code .'</code>',
|
||||
array(array($source_code, $lang, 0, 1, FALSE)),
|
||||
t('Checking language="@lang"', array('@lang' => $lang)));
|
||||
}
|
||||
|
||||
// check line_numbering argument
|
||||
$this->assertGeshiFilterHighlighting('<code type="cpp" linenumbers="off">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Checking linenumbers="off" argument'));
|
||||
$this->assertGeshiFilterHighlighting('<code type="cpp" linenumbers="normal">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 1, 1, FALSE)),
|
||||
t('Checking linenumbers="normal" argument'));
|
||||
$this->assertGeshiFilterHighlighting('<code type="cpp" start="27">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 1, 27, FALSE)),
|
||||
t('Checking start="27" argument'));
|
||||
$this->assertGeshiFilterHighlighting('<code type="cpp" linenumbers="fancy">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 5, 1, FALSE)),
|
||||
t('Checking linenumbers="fancy" argument'));
|
||||
$this->assertGeshiFilterHighlighting('<code type="cpp" fancy="3">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 3, 1, FALSE)),
|
||||
t('Checking fancy="3" argument'));
|
||||
}
|
||||
|
||||
|
||||
function testBracketsOnlyAngle() {
|
||||
variable_set('geshifilter_tags', 'code');
|
||||
variable_set('geshifilter_language_enabled_cpp', TRUE);
|
||||
$source_code = "//C++ source code\nfor (int i=0; i<10; ++i) {\n fun(i);\n bar.foo(x, y);\n server->start(&pool); \n}";
|
||||
// Enable only angle brackets
|
||||
variable_set('geshifilter_tag_styles', array(
|
||||
GESHIFILTER_BRACKETS_ANGLE => GESHIFILTER_BRACKETS_ANGLE,
|
||||
));
|
||||
// This should be filtered.
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Checking angle brackets style in GESHIFILTER_BRACKETS_ANGLE mode'));
|
||||
// This should not be filtered.
|
||||
$this->assertGeshiFilterHighlighting('[code language="cpp"]'. $source_code .'[/code]',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking [foo] brackets style in GESHIFILTER_BRACKETS_ANGLE mode'));
|
||||
$this->assertGeshiFilterHighlighting('[[code language="cpp"]]'. $source_code .'[[/code]]',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking [[foo]] brackets style in GESHIFILTER_BRACKETS_ANGLE mode'));
|
||||
$this->assertGeshiFilterHighlighting('<?php'. $source_code .'?>',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking php code blocks in GESHIFILTER_BRACKETS_ANGLE mode'));
|
||||
}
|
||||
|
||||
function testBracketsOnlySquare() {
|
||||
variable_set('geshifilter_tags', 'code');
|
||||
variable_set('geshifilter_language_enabled_cpp', TRUE);
|
||||
$source_code = "//C++ source code\nfor (int i=0; i<10; ++i) {\n fun(i);\n bar.foo(x, y);\n server->start(&pool); \n}";
|
||||
// Enable only square brackets
|
||||
variable_set('geshifilter_tag_styles', array(
|
||||
GESHIFILTER_BRACKETS_SQUARE => GESHIFILTER_BRACKETS_SQUARE,
|
||||
));
|
||||
// This should be filtered.
|
||||
$this->assertGeshiFilterHighlighting('[code language="cpp"]'. $source_code .'[/code]',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Checking [foo] brackets style in GESHIFILTER_BRACKETS_SQUARE mode'));
|
||||
// This should not be filtered.
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp">'. $source_code .'</code>',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking angle brackets style in GESHIFILTER_BRACKETS_SQUARE mode'));
|
||||
$this->assertGeshiFilterHighlighting('[[code language="cpp"]]'. $source_code .'[[/code]]',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking [[foo]] brackets style in GESHIFILTER_BRACKETS_SQUARE mode'));
|
||||
$this->assertGeshiFilterHighlighting('<?php'. $source_code .'?>',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking php code blocks in GESHIFILTER_BRACKETS_SQUARE mode'));
|
||||
}
|
||||
|
||||
function testBracketsOnlyDoubleSquare() {
|
||||
variable_set('geshifilter_tags', 'code');
|
||||
variable_set('geshifilter_language_enabled_cpp', TRUE);
|
||||
$source_code = "//C++ source code\nfor (int i=0; i<10; ++i) {\n fun(i);\n bar.foo(x, y);\n server->start(&pool); \n}";
|
||||
// Enable only double square brackets
|
||||
variable_set('geshifilter_tag_styles', array(
|
||||
GESHIFILTER_BRACKETS_DOUBLESQUARE => GESHIFILTER_BRACKETS_DOUBLESQUARE,
|
||||
));
|
||||
// This should be filtered.
|
||||
$this->assertGeshiFilterHighlighting('[[code language="cpp"]]'. $source_code .'[[/code]]',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Checking [[foo]] brackets style in GESHIFILTER_BRACKETS_DOUBLESQUARE mode'));
|
||||
// This should not be filtered.
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp">'. $source_code .'</code>',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking angle brackets style in GESHIFILTER_BRACKETS_DOUBLESQUARE mode'));
|
||||
$this->assertGeshiFilterHighlighting('[code language="cpp"]'. $source_code .'[/code]',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking [foo] brackets style in GESHIFILTER_BRACKETS_DOUBLESQUARE mode'));
|
||||
$this->assertGeshiFilterHighlighting('<?php'. $source_code .'?>',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking php code blocks in GESHIFILTER_BRACKETS_DOUBLESQUARE mode'));
|
||||
}
|
||||
|
||||
function testBracketsOnlyPhpCodeBlock() {
|
||||
variable_set('geshifilter_tags', 'code');
|
||||
variable_set('geshifilter_language_enabled_cpp', TRUE);
|
||||
$source_code = "//C++ source code\nfor (int i=0; i<10; ++i) {\n fun(i);\n bar.foo(x, y);\n server->start(&pool); \n}";
|
||||
// Enable only double square brackets
|
||||
variable_set('geshifilter_tag_styles', array(
|
||||
GESHIFILTER_BRACKETS_PHPBLOCK => GESHIFILTER_BRACKETS_PHPBLOCK,
|
||||
));
|
||||
// This should be filtered.
|
||||
$this->assertGeshiFilterHighlighting('<?php'. $source_code .'?>',
|
||||
array(array($source_code, 'php', 0, 1, FALSE)),
|
||||
t('Checking php code blocks in GESHIFILTER_BRACKETS_PHPBLOCK mode'));
|
||||
// This should not be filtered.
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp">'. $source_code .'</code>',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking angle brackets style in GESHIFILTER_BRACKETS_PHPBLOCK mode'));
|
||||
$this->assertGeshiFilterHighlighting('[code language="cpp"]'. $source_code .'[/code]',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking [foo] brackets style in GESHIFILTER_BRACKETS_PHPBLOCK mode'));
|
||||
$this->assertGeshiFilterHighlighting('[[code language="cpp"]]'. $source_code .'[[/code]]',
|
||||
array(array($source_code, NULL, 0, 1, FALSE)),
|
||||
t('Checking [[foo]] brackets style in GESHIFILTER_BRACKETS_PHPBLOCK mode'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if tags like [c++] and [c#] work
|
||||
* Problem described in http://drupal.org/node/208720
|
||||
*/
|
||||
function testSpecialTags() {
|
||||
// Enabled the tags
|
||||
variable_set('geshifilter_language_enabled_cpp', TRUE);
|
||||
variable_set('geshifilter_language_tags_cpp', 'c++');
|
||||
variable_set('geshifilter_language_enabled_csharp', TRUE);
|
||||
variable_set('geshifilter_language_tags_csharp', 'c#');
|
||||
// body material
|
||||
$source_code = "//C++-ish source code\nfor (int i=0; i<10; ++i) {\n fun(i);\n bar.foo(x, y);\n server->start(&pool); \n}";
|
||||
// Test the tags
|
||||
$this->assertGeshiFilterHighlighting('<c++>'. $source_code .'</c++>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Checking <c++>..</c++>'));
|
||||
$this->assertGeshiFilterHighlighting('<c#>'. $source_code .'</c#>',
|
||||
array(array($source_code, 'csharp', 0, 1, FALSE)),
|
||||
t('Checking <c#>..</c#>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if tags like [cpp], [css], [csharp] aren't highjacked by [c]
|
||||
*/
|
||||
function testPrefixTags() {
|
||||
// enabled the tags
|
||||
variable_set('geshifilter_language_enabled_c', TRUE);
|
||||
variable_set('geshifilter_language_tags_c', 'c');
|
||||
variable_set('geshifilter_language_enabled_cpp', TRUE);
|
||||
variable_set('geshifilter_language_tags_cpp', 'cpp');
|
||||
variable_set('geshifilter_language_enabled_csharp', TRUE);
|
||||
variable_set('geshifilter_language_tags_csharp', 'csharp');
|
||||
// body material
|
||||
$source_code = "//C++-ish source code\nfor (int i=0; i<10; ++i) {\n fun(i);\n bar.foo(x, y);\n server->start(&pool); \n}";
|
||||
// Test the tags
|
||||
$this->assertGeshiFilterHighlighting('<cpp>'. $source_code .'</cpp>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Source code in <cpp>...</cpp> should work when <c>...</c> is also enabled'));
|
||||
$this->assertGeshiFilterHighlighting('<csharp>'. $source_code .'</csharp>',
|
||||
array(array($source_code, 'csharp', 0, 1, FALSE)),
|
||||
t('Source code in <csharp>...</csharp> should work when <c>...</c> is also enabled'));
|
||||
}
|
||||
|
||||
function testDoNothingMode() {
|
||||
// Enable C++.
|
||||
variable_set('geshifilter_language_enabled_cpp', TRUE);
|
||||
variable_set('geshifilter_language_tags_cpp', 'cpp');
|
||||
// Set default highlighting mode to "do nothing".
|
||||
variable_set('geshifilter_default_highlighting', GESHIFILTER_DEFAULT_DONOTHING);
|
||||
// Body material with some characters ('<' and '&') that would be escaped
|
||||
// except in "do nothing" mode
|
||||
$source_code = "//C++-ish source code\nfor (int i=0; i!=10; ++i) {\n fun(i);\n bar.foo(x, y);\n}";
|
||||
// Tests
|
||||
$this->assertGeshiFilterHighlighting('<code>'. $source_code .'</code>',
|
||||
array(array('<code>'. $source_code .'</code>', FALSE, 0, 1, FALSE)),
|
||||
t('Do nothing mode should not touch given source code')
|
||||
);
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp">'. $source_code .'</code>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Highlighting with language="cpp" should work when default is "do nothing"')
|
||||
);
|
||||
$this->assertGeshiFilterHighlighting('<cpp>'. $source_code .'</cpp>',
|
||||
array(array($source_code, 'cpp', 0, 1, FALSE)),
|
||||
t('Highlighting with <cpp>...</cpp> should work when default is "do nothing"')
|
||||
);
|
||||
}
|
||||
|
||||
function testTitleAttributeOnCodeBlock(){
|
||||
$source_code = "for (int i=0; i!=10; ++i) {\n fun(i);\n bar.foo(x, y);\n}";
|
||||
// No title set
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp">'. $source_code .'</code>',
|
||||
array(array('geshifilter-title', False, 0, 0, 0)),
|
||||
t('Setting the title attritbute on code block.'),
|
||||
true
|
||||
);
|
||||
// Title set.
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp" title="Foo the bar!">'. $source_code .'</code>',
|
||||
array(array('<div class="geshifilter-title">Foo the bar!</div>', False, 0, 0, 0)),
|
||||
t('Setting the title attritbute on code block.')
|
||||
);
|
||||
}
|
||||
|
||||
function testTitleAttributeOnInlineCode(){
|
||||
$source_code = "for (int i=0; i!=10; ++i) { fun(i); }";
|
||||
// No title set.
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp">'. $source_code .'</code>',
|
||||
array(array('<span class="geshifilter">', False, 0, 0, 0)),
|
||||
t('Setting the title attritbute on inline code.')
|
||||
);
|
||||
// Title set.
|
||||
$this->assertGeshiFilterHighlighting('<code language="cpp" title="Foo the bar!">'. $source_code .'</code>',
|
||||
array(array('<span class="geshifilter" title="Foo the bar!">', False, 0, 0, 0)),
|
||||
t('Setting the title attritbute on inline code.')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Issue http://drupal.org/node/1010216
|
||||
*/
|
||||
function testSquareBracketConfusion() {
|
||||
variable_set('geshifilter_tags', 'code');
|
||||
variable_set('geshifilter_language_enabled_ini', TRUE);
|
||||
$source_code = "[section]\nserver=192.0.2.62 ; IP address\nport=12345";
|
||||
// Enable square brackets
|
||||
variable_set('geshifilter_tag_styles', array(
|
||||
GESHIFILTER_BRACKETS_SQUARE => GESHIFILTER_BRACKETS_SQUARE,
|
||||
));
|
||||
// This should be filtered.
|
||||
$this->assertGeshiFilterHighlighting('[code]'. $source_code .'[/code]',
|
||||
array(array($source_code, 'text', 0, 1, FALSE)),
|
||||
t('Checking if [code][section]...[/code] works'));
|
||||
$this->assertGeshiFilterHighlighting('[code language="ini"]'. $source_code .'[/code]',
|
||||
array(array($source_code, 'ini', 0, 1, FALSE)),
|
||||
t('Checking if [code language="ini"][section]...[/code] works'));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
PREREQUISITES: Make sure you check HTML Purifier and make sure that you
|
||||
have fulfilled all of its requirements before running this. Specifically,
|
||||
you'll need the PHP extension ctype (in almost all PHP distributions),
|
||||
and it's nice to have dom and iconv.
|
||||
|
||||
* Place the htmlpurifier folder in your drupal modules directory.
|
||||
|
||||
* Download HTML Purifier from http://htmlpurifier.org/ You will need
|
||||
4.0.0 or later.
|
||||
|
||||
* There are two possible ways to install the HTML Purifier library.
|
||||
|
||||
1. Module directory installation. This means installing the library
|
||||
folder under the module directory. This way has the advantage of
|
||||
not depending on other modules. The issue is that when you
|
||||
upgrade the htmlpurifier module the HTML Purifier library gets
|
||||
removed and you have to re-extract the archive in the newly
|
||||
installed module directory.
|
||||
|
||||
2. The preferred way is making use of the libraries API,
|
||||
http://drupal.org/project/libraries. This makes the library
|
||||
available to all sites or to a specific site in a multisite
|
||||
Drupal setup. You'll need to download the libraries API module
|
||||
and enable it before enabling the htmlpurifier module so that in
|
||||
the install phase it can find the library.
|
||||
|
||||
Extract the library folder to libraries directory.
|
||||
|
||||
The final setup should be, when making the library and module
|
||||
available to all sites:
|
||||
|
||||
libraries/htmlpurifier/
|
||||
HTMLPurifier
|
||||
HTMLPurifier.autoload.php
|
||||
HTMLPurifier.auto.php
|
||||
HTMLPurifier.func.php
|
||||
HTMLPurifier.includes.php
|
||||
HTMLPurifier.kses.php
|
||||
HTMLPurifier.path.php
|
||||
HTMLPurifier.php
|
||||
HTMLPurifier.safe-includes.php
|
||||
|
||||
Now you can safely upgrade your htmlpurifier module without
|
||||
having to re-deploy the HTML Purifier library.
|
||||
|
||||
* Go to Administer > Site building > Modules and enable this module
|
||||
|
||||
* You can now create a new input format or add the HTML Purifier to an
|
||||
existing input format. It is recommended that you place HTML Purifier as
|
||||
the last filter in the input format. Reorder the filters if necessary.
|
||||
|
||||
WARNING: Due to HTML Purifier's caching mechanism, dynamic filters MUST NOT
|
||||
be placed before HTML Purifier.
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
TODO List
|
||||
|
||||
Non-code
|
||||
- Add better documentation about what's different about configuring
|
||||
the PHP and what's configuring the web interface
|
||||
- Make distinction between module and library clearer
|
||||
- Link to WYSIWYG editors, research integration prospects, and how
|
||||
they're handling security
|
||||
- http://drupal.org/project/htmlarea
|
||||
- http://drupal.org/project/fckeditor
|
||||
- http://drupal.org/project/tinymce
|
||||
- Competitors
|
||||
- http://drupal.org/project/safehtml
|
||||
|
||||
1.3
|
||||
- Improve help text (this might be a good addition to the HTML Purifier
|
||||
core). This would be for filter tips as well as for the form.
|
||||
- Compatibility
|
||||
- Paging comments
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file is a sample advanced PHP configuration file for the HTML Purifier
|
||||
* filter module. In reality, this file would be named N.php, where N is the
|
||||
* integer identifying the filter this is configuring. The configure page
|
||||
* for HTML Purifier (advanced) will tell you what file to copy this to.
|
||||
*
|
||||
* See this URI:
|
||||
*
|
||||
* http://htmlpurifier.org/live/configdoc/plain.html
|
||||
*
|
||||
* For full information about permitted directives. The most interesting ones
|
||||
* for custom configuration are ones with the 'mixed' type, as they cannot
|
||||
* be configured using the webform.
|
||||
*
|
||||
* @note
|
||||
* A number of directives have been predefined for you in order to better
|
||||
* work with Drupal. You can see what these defaults in the
|
||||
* _htmlpurifier_get_config() function in htmlpurifier.module.php.
|
||||
*
|
||||
* @warning
|
||||
* Please be mindful of the version of HTML Purifier you have installed!
|
||||
* All of the docs linked to are for the latest version of HTML Purifier;
|
||||
* your installation may or may not be up-to-date.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Accepts an HTMLPurifier_Config configuration object and configures it.
|
||||
*
|
||||
* @param $config
|
||||
* Instance of HTMLPurifier_Config to modify. See
|
||||
* http://htmlpurifier.org/doxygen/html/classHTMLPurifier__Config.html
|
||||
* for a full API.
|
||||
*
|
||||
* @note
|
||||
* No return value is needed, as PHP objects are passed by reference.
|
||||
*/
|
||||
function htmlpurifier_config_N($config) {
|
||||
// Set your configuration here:
|
||||
$config->set('Core', 'Lexer', 'DirectLex');
|
||||
// $config->set('Namespace', 'Directive', $value);
|
||||
|
||||
// Advanced users:
|
||||
// $def = $config->getDefinition('HTML');
|
||||
// For more information about this, see:
|
||||
// http://htmlpurifier.org/docs/enduser-customize.html
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
********************************************************************
|
||||
D R U P A L M O D U L E
|
||||
********************************************************************
|
||||
Name: i18n module and translation module
|
||||
Author: Jose A. Reyero
|
||||
|
||||
********************************************************************
|
||||
This is the 6.x version of i18n module, and works with Drupal 6.x
|
||||
********************************************************************
|
||||
|
||||
********************************************************************
|
||||
Updated documentation will be kept on-line at http://drupal.org/node/133977
|
||||
********************************************************************
|
||||
|
||||
INSTALLATION:
|
||||
============
|
||||
|
||||
1. Create folder 'modules/i18n' and copy all the modules files, keeping directory structure, to this folder.
|
||||
2. If updating, run the update.php script following the standard procedure for Drupal updates.
|
||||
|
||||
POST-INSTALLATION/CONFIGURATION:
|
||||
============
|
||||
- First of all review Drupal language settings and make sure you have chosen the right default language.
|
||||
- Enable the needed modules grouped under "Internationalization" package
|
||||
- Read the on-line handbook on
|
||||
|
||||
IMPORTANT:
|
||||
==========
|
||||
- This module requires a complex set up, make sure you read the handbook and understand the different options
|
||||
- Before creating a support request, do read the handbook: http://drupal.org/node/133977
|
||||
|
||||
Additional Support
|
||||
==================
|
||||
For support, please create a support request for this module's project: http://drupal.org/project/i18n
|
||||
|
||||
Support questions by email to the module maintainer will be simply ignored. Use the issue tracker.
|
||||
|
||||
====================================================================
|
||||
Jose A. Reyero, freelance at reyero dot net, http://www.reyero.net
|
|
@ -1,25 +0,0 @@
|
|||
For ImageCache to work properly it needs to be able to make use fou clean URLs.
|
||||
This requires some webserver specific setup.
|
||||
|
||||
Apache2 + mod_rewrite
|
||||
Works out of the box.
|
||||
|
||||
LightHTTPD pre-1.4.24:
|
||||
http://nordisch.org/2007/2/6/drupal-on-lighttpd-with-clean-urls
|
||||
|
||||
LightHTTPD 1.4.24 and later:
|
||||
https://veracium.com/content/imagecache-lighttpd-witho
|
||||
|
||||
IIS 6:
|
||||
add an error404.asp that passed everything to drupal.
|
||||
|
||||
<%
|
||||
Response.Expires=0
|
||||
strQString=Request.ServerVariables("QUERY_STRING")
|
||||
If (InStr(strQString,"/d5/")) Then
|
||||
pos=Instr(strQString,"/d5/")+3
|
||||
Id=Right(strQString,Len(strQString)-pos)
|
||||
Response.Redirect("/d5/index.php?q=" & Id)
|
||||
End If
|
||||
Response.Redirect("index.htm")
|
||||
%>
|
|
@ -1,156 +0,0 @@
|
|||
This document explains how to provide "Pathauto integration" in a
|
||||
module. You need this if you would like to provide additional tokens
|
||||
or if your module has paths and you wish to have them automatically
|
||||
aliased. The simplest integration is just to provide tokens so we
|
||||
cover that first. More advanced integration requires an
|
||||
implementation of hook_pathauto to provide a settings form.
|
||||
|
||||
It may be helpful to review some examples of integration from the
|
||||
pathauto_node.inc, pathauto_taxonomy.inc, and pathauto_user.inc files.
|
||||
|
||||
|
||||
==================
|
||||
1 - Providing additional tokens
|
||||
==================
|
||||
|
||||
If all you want is to enable tokens for your module you will simply
|
||||
need to implement two functions:
|
||||
|
||||
hook_token_values
|
||||
hook_token_list
|
||||
|
||||
See the token.module and it's API.txt for more information about this
|
||||
process.
|
||||
|
||||
If the token is intended to generate a path expected to contain slashes,
|
||||
the token name must end in 'path', 'path-raw' or 'alias'. This indicates to
|
||||
Pathauto that the slashes should not be removed from the replacement value.
|
||||
|
||||
When an object is created (whether it is a node or a user or a
|
||||
taxonomy term) the data that Pathauto hands to the token_values in the
|
||||
$object is in a specific format. This is the format that most people
|
||||
write code to handle. However, during edits and bulk updates the data
|
||||
may be in a totally different format. So, if you are writing a
|
||||
hook_token_values implementation to add special tokens, be sure to
|
||||
test creation, edit, and bulk update cases to make sure your code will
|
||||
handle it.
|
||||
|
||||
==================
|
||||
2 - Settings hook - To create aliases for your module
|
||||
==================
|
||||
You must implement hook_pathauto($op), where $op is always (at this
|
||||
time) 'settings'. Return an object (NOT an array) containing the
|
||||
following members, which will be used by pathauto to build a group
|
||||
of settings for your module and define the variables for saving your
|
||||
settings:
|
||||
|
||||
module - The name of your module (e.g., 'node')
|
||||
groupheader - The translated label for the settings group (e.g.,
|
||||
t('Node path settings')
|
||||
patterndescr - The translated label for the default pattern (e.g.,
|
||||
t('Default path pattern (applies to all node types with blank patterns below)')
|
||||
patterndefault - A translated default pattern (e.g., t('[cat]/[title].html'))
|
||||
placeholders - An array whose keys consist of the translated placeholders
|
||||
which will appear in patterns (e.g., t('[title]')) and values are
|
||||
the translated description of the placeholders (e.g.,
|
||||
t('The title of the node, with spaces and punctuation.')
|
||||
patternitems - For modules which need to express multiple patterns
|
||||
(for example, the node module supports a separate pattern for each
|
||||
node type), an array whose keys consist of identifiers for each
|
||||
pattern (e.g., the node type name) and values consist of the
|
||||
translated label for the pattern
|
||||
supportsfeeds - Modules which support RSS feeds should set this to the
|
||||
string that's appended to a path for its feed (usually 'feed') , so
|
||||
when administrators enable "Create feed aliases" an alias for this
|
||||
content type's feed will be generated in addition to the base alias.
|
||||
bulkname - For modules which support a bulk update operation, the
|
||||
translated label for the action (e.g., t('Bulk update node paths'))
|
||||
bulkdescr - For modules which support a bulk update operation, a
|
||||
translated, more thorough description of what the operation will do
|
||||
(e.g., t('Generate aliases for all existing nodes which do not already have aliases.'))
|
||||
|
||||
|
||||
==================
|
||||
2 - $alias = pathauto_create_alias($module, $op, $placeholders, $src, $type=NULL)
|
||||
==================
|
||||
|
||||
At the appropriate time (usually when a new item is being created for
|
||||
which a generated alias is desired), call pathauto_create_alias() to
|
||||
generate and create the alias. See the user, taxonomy, and nodeapi hook
|
||||
implementations in pathauto.module for examples.
|
||||
|
||||
$module - The name of your module (e.g., 'node')
|
||||
$op - Operation being performed on the item ('insert', 'update', or
|
||||
'bulkupdate')
|
||||
$placeholders - An array whose keys consist of the translated placeholders
|
||||
which appear in patterns and values are the "clean" values to be
|
||||
substituted into the pattern. Call pathauto_cleanstring() on any
|
||||
values which you do not know to be purely alphanumeric, to substitute
|
||||
any non-alphanumerics with the user's designated separator. Note that
|
||||
if the pattern has multiple slash-separated components (e.g., [catpath]),
|
||||
pathauto_cleanstring() should be called for each component, not the
|
||||
complete string.
|
||||
Example: $placeholders[t('[title]')] = pathauto_cleanstring($node->title);
|
||||
$src - The "real" URI of the content to be aliased (e.g., "node/$node->nid")
|
||||
$type - For modules which provided patternitems in hook_autopath(),
|
||||
the relevant identifier for the specific item to be aliased (e.g.,
|
||||
$node->type)
|
||||
|
||||
pathauto_create_alias() returns the alias that was created.
|
||||
|
||||
|
||||
==================
|
||||
3 - Bulk update function
|
||||
==================
|
||||
|
||||
If a module supports bulk updating of aliases, it must provide a
|
||||
function of this form, to be called by pathauto when the corresponding
|
||||
checkbox is selected and the settings page submitted:
|
||||
|
||||
function <module>_pathauto_bulkupdate()
|
||||
|
||||
The function should iterate over the content items controlled by the
|
||||
module, calling pathauto_create_alias() for each one. It is
|
||||
recommended that the function report on its success (e.g., with a
|
||||
count of created aliases) via drupal_set_message().
|
||||
|
||||
|
||||
==================
|
||||
4 - Bulk delete hook_path_alias_types()
|
||||
==================
|
||||
|
||||
For modules that create new types of pages that can be aliased with pathauto, a
|
||||
hook implementation is needed to allow the user to delete them all at once.
|
||||
|
||||
function hook_path_alias_types()
|
||||
|
||||
This hook returns an array whose keys match the beginning of the source paths
|
||||
(e.g.: "node/", "user/", etc.) and whose values describe the type of page (e.g.:
|
||||
"content", "users"). Like all displayed strings, these descriptionsshould be
|
||||
localized with t(). Use % to match interior pieces of a path; "user/%/track". This
|
||||
is a database wildcard, so be careful.
|
||||
|
||||
|
||||
==================
|
||||
Modules that extend node and/or taxonomy
|
||||
==================
|
||||
|
||||
NOTE: this is basically not true any more. If you feel you need this file an issue.
|
||||
|
||||
Many contributed Drupal modules extend the core node and taxonomy
|
||||
modules. To extend pathauto patterns to support their extensions, they
|
||||
may implement the pathauto_node and pathauto_taxonomy hooks.
|
||||
|
||||
To do so, implement the function <modulename>_pathauto_node (or _taxonomy),
|
||||
accepting the arguments $op and $node (or $term). Two operations are
|
||||
supported:
|
||||
|
||||
$op = 'placeholders' - return an array keyed on placeholder strings
|
||||
(e.g., t('[eventyyyy]')) valued with descriptions (e.g. t('The year the
|
||||
event starts.')).
|
||||
$op = 'values' - return an array keyed on placeholder strings, valued
|
||||
with the "clean" actual value for the passed node or category (e.g.,
|
||||
pathauto_cleanstring(date('M', $eventstart)));
|
||||
|
||||
See contrib/pathauto_node_event.inc for an example of extending node
|
||||
patterns.
|
|
@ -1,48 +0,0 @@
|
|||
**Installation:
|
||||
|
||||
Pathauto is an extension to the path module, which must be enabled.
|
||||
|
||||
Pathauto also relies on the Token module, which must be downloaded and
|
||||
enabled separately.
|
||||
|
||||
1. Unpack the Pathauto folder and contents in the appropriate modules
|
||||
directory of your Drupal installation.
|
||||
2. Enable the Pathauto module in the administration tools.
|
||||
3. If you're not using Drupal's default administrative account, make
|
||||
sure "administer pathauto" is enabled through access control administration.
|
||||
4. Visit the Pathauto settings page and make appropriate configurations
|
||||
For 5.x: Administer > Site configuration > Pathauto
|
||||
For 6.x: Administer > Site building > URL alias > Automated alias settings
|
||||
|
||||
**Transliteration support:
|
||||
If you desire transliteration support in the creation of URLs (e.g. the
|
||||
replacement of À with A) then you will need to rename the file
|
||||
i18n-ascii.example.txt to i18n-ascii.txt
|
||||
|
||||
You can then freely edit the i18n-ascii.txt without worrying that your changes
|
||||
will be over-written by upgrades of Pathauto.
|
||||
|
||||
For details on how to transliterate any UTF8 character, please see the full
|
||||
i18n-ascii-fill.txt file information at http://drupal.org/node/185664
|
||||
|
||||
**Upgrading from previous versions:
|
||||
If you are upgrading from Pathauto 5.x-1.x to 5.x-2.x (or 6.x-2.x) then you
|
||||
will probably need to change your patterns.
|
||||
|
||||
For content patterns:
|
||||
[user] is now [author-name]
|
||||
[cat] is now [term]
|
||||
|
||||
There may be other changes as well. Please review the pattern examples on
|
||||
Administration > Site Configuration > Pathauto
|
||||
|
||||
If you upgraded from Pathauto 5.x-1.x directly without enabling Token
|
||||
first then you will need to
|
||||
1) download/install the Token module
|
||||
2) disable the Pathauto module
|
||||
3) re-enable the Pathauto module
|
||||
|
||||
Upgrade to 6.x:
|
||||
Note that the settings page has moved so that it is more logically grouped with
|
||||
other URL alias related items under
|
||||
Administer > Site building > URL alias > Automated alias settings
|
|
@ -1,564 +0,0 @@
|
|||
; global transliteration
|
||||
[default]
|
||||
À = "A"
|
||||
Á = "A"
|
||||
 = "A"
|
||||
à = "A"
|
||||
Ä = "Ae"
|
||||
Å = "A"
|
||||
Æ = "A"
|
||||
Ā = "A"
|
||||
Ą = "A"
|
||||
Ă = "A"
|
||||
Ç = "C"
|
||||
Ć = "C"
|
||||
Č = "C"
|
||||
Ĉ = "C"
|
||||
Ċ = "C"
|
||||
Ď = "D"
|
||||
Đ = "D"
|
||||
È = "E"
|
||||
É = "E"
|
||||
Ê = "E"
|
||||
Ë = "E"
|
||||
Ē = "E"
|
||||
Ę = "E"
|
||||
Ě = "E"
|
||||
Ĕ = "E"
|
||||
Ė = "E"
|
||||
Ĝ = "G"
|
||||
Ğ = "G"
|
||||
Ġ = "G"
|
||||
Ģ = "G"
|
||||
Ĥ = "H"
|
||||
Ħ = "H"
|
||||
Ì = "I"
|
||||
Í = "I"
|
||||
Î = "I"
|
||||
Ï = "I"
|
||||
Ī = "I"
|
||||
Ĩ = "I"
|
||||
Ĭ = "I"
|
||||
Į = "I"
|
||||
İ = "I"
|
||||
IJ = "IJ"
|
||||
Ĵ = "J"
|
||||
Ķ = "K"
|
||||
Ľ = "L"
|
||||
Ĺ = "L"
|
||||
Ļ = "L"
|
||||
Ŀ = "L"
|
||||
Ł = "L"
|
||||
Ñ = "N"
|
||||
Ń = "N"
|
||||
Ň = "N"
|
||||
Ņ = "N"
|
||||
Ŋ = "N"
|
||||
Ò = "O"
|
||||
Ó = "O"
|
||||
Ô = "O"
|
||||
Õ = "O"
|
||||
Ö = "Oe"
|
||||
Ø = "O"
|
||||
Ō = "O"
|
||||
Ő = "O"
|
||||
Ŏ = "O"
|
||||
Œ = "OE"
|
||||
Ŕ = "R"
|
||||
Ř = "R"
|
||||
Ŗ = "R"
|
||||
Ś = "S"
|
||||
Ş = "S"
|
||||
Ŝ = "S"
|
||||
Ș = "S"
|
||||
Š = "S"
|
||||
Ť = "T"
|
||||
Ţ = "T"
|
||||
Ŧ = "T"
|
||||
Ț = "T"
|
||||
Ù = "U"
|
||||
Ú = "U"
|
||||
Û = "U"
|
||||
Ü = "Ue"
|
||||
Ū = "U"
|
||||
Ů = "U"
|
||||
Ű = "U"
|
||||
Ŭ = "U"
|
||||
Ũ = "U"
|
||||
Ų = "U"
|
||||
Ŵ = "W"
|
||||
Ŷ = "Y"
|
||||
Ÿ = "Y"
|
||||
Ý = "Y"
|
||||
Ź = "Z"
|
||||
Ż = "Z"
|
||||
Ž = "Z"
|
||||
à = "a"
|
||||
á = "a"
|
||||
â = "a"
|
||||
ã = "a"
|
||||
ä = "ae"
|
||||
ā = "a"
|
||||
ą = "a"
|
||||
ă = "a"
|
||||
å = "a"
|
||||
æ = "ae"
|
||||
ç = "c"
|
||||
ć = "c"
|
||||
č = "c"
|
||||
ĉ = "c"
|
||||
ċ = "c"
|
||||
ď = "d"
|
||||
đ = "d"
|
||||
è = "e"
|
||||
é = "e"
|
||||
ê = "e"
|
||||
ë = "e"
|
||||
ē = "e"
|
||||
ę = "e"
|
||||
ě = "e"
|
||||
ĕ = "e"
|
||||
ė = "e"
|
||||
ƒ = "f"
|
||||
ĝ = "g"
|
||||
ğ = "g"
|
||||
ġ = "g"
|
||||
ģ = "g"
|
||||
ĥ = "h"
|
||||
ħ = "h"
|
||||
ì = "i"
|
||||
í = "i"
|
||||
î = "i"
|
||||
ï = "i"
|
||||
ī = "i"
|
||||
ĩ = "i"
|
||||
ĭ = "i"
|
||||
į = "i"
|
||||
ı = "i"
|
||||
ij = "ij"
|
||||
ĵ = "j"
|
||||
ķ = "k"
|
||||
ĸ = "k"
|
||||
ł = "l"
|
||||
ľ = "l"
|
||||
ĺ = "l"
|
||||
ļ = "l"
|
||||
ŀ = "l"
|
||||
ñ = "n"
|
||||
ń = "n"
|
||||
ň = "n"
|
||||
ņ = "n"
|
||||
ʼn = "n"
|
||||
ŋ = "n"
|
||||
ò = "o"
|
||||
ó = "o"
|
||||
ô = "o"
|
||||
õ = "o"
|
||||
ö = "oe"
|
||||
ø = "o"
|
||||
ō = "o"
|
||||
ő = "o"
|
||||
ŏ = "o"
|
||||
œ = "oe"
|
||||
ŕ = "r"
|
||||
ř = "r"
|
||||
ŗ = "r"
|
||||
ś = "s"
|
||||
š = "s"
|
||||
ş = "s"
|
||||
ť = "t"
|
||||
ţ = "t"
|
||||
ù = "u"
|
||||
ú = "u"
|
||||
û = "u"
|
||||
ü = "ue"
|
||||
ū = "u"
|
||||
ů = "u"
|
||||
ű = "u"
|
||||
ŭ = "u"
|
||||
ũ = "u"
|
||||
ų = "u"
|
||||
ŵ = "w"
|
||||
ÿ = "y"
|
||||
ý = "y"
|
||||
ŷ = "y"
|
||||
ż = "z"
|
||||
ź = "z"
|
||||
ž = "z"
|
||||
ß = "ss"
|
||||
ſ = "ss"
|
||||
Α = "A"
|
||||
Ά = "A"
|
||||
Ἀ = "A"
|
||||
Ἁ = "A"
|
||||
Ἂ = "A"
|
||||
Ἃ = "A"
|
||||
Ἄ = "A"
|
||||
Ἅ = "A"
|
||||
Ἆ = "A"
|
||||
Ἇ = "A"
|
||||
ᾈ = "A"
|
||||
ᾉ = "A"
|
||||
ᾊ = "A"
|
||||
ᾋ = "A"
|
||||
ᾌ = "A"
|
||||
ᾍ = "A"
|
||||
ᾎ = "A"
|
||||
ᾏ = "A"
|
||||
Ᾰ = "A"
|
||||
Ᾱ = "A"
|
||||
Ὰ = "A"
|
||||
Ά = "A"
|
||||
ᾼ = "A"
|
||||
Β = "B"
|
||||
Γ = "G"
|
||||
Δ = "D"
|
||||
Ε = "E"
|
||||
Έ = "E"
|
||||
Ἐ = "E"
|
||||
Ἑ = "E"
|
||||
Ἒ = "E"
|
||||
Ἓ = "E"
|
||||
Ἔ = "E"
|
||||
Ἕ = "E"
|
||||
Έ = "E"
|
||||
Ὲ = "E"
|
||||
Ζ = "Z"
|
||||
Η = "I"
|
||||
Ή = "I"
|
||||
Ἠ = "I"
|
||||
Ἡ = "I"
|
||||
Ἢ = "I"
|
||||
Ἣ = "I"
|
||||
Ἤ = "I"
|
||||
Ἥ = "I"
|
||||
Ἦ = "I"
|
||||
Ἧ = "I"
|
||||
ᾘ = "I"
|
||||
ᾙ = "I"
|
||||
ᾚ = "I"
|
||||
ᾛ = "I"
|
||||
ᾜ = "I"
|
||||
ᾝ = "I"
|
||||
ᾞ = "I"
|
||||
ᾟ = "I"
|
||||
Ὴ = "I"
|
||||
Ή = "I"
|
||||
ῌ = "I"
|
||||
Θ = "TH"
|
||||
Ι = "I"
|
||||
Ί = "I"
|
||||
Ϊ = "I"
|
||||
Ἰ = "I"
|
||||
Ἱ = "I"
|
||||
Ἲ = "I"
|
||||
Ἳ = "I"
|
||||
Ἴ = "I"
|
||||
Ἵ = "I"
|
||||
Ἶ = "I"
|
||||
Ἷ = "I"
|
||||
Ῐ = "I"
|
||||
Ῑ = "I"
|
||||
Ὶ = "I"
|
||||
Ί = "I"
|
||||
Κ = "K"
|
||||
Λ = "L"
|
||||
Μ = "M"
|
||||
Ν = "N"
|
||||
Ξ = "KS"
|
||||
Ο = "O"
|
||||
Ό = "O"
|
||||
Ὀ = "O"
|
||||
Ὁ = "O"
|
||||
Ὂ = "O"
|
||||
Ὃ = "O"
|
||||
Ὄ = "O"
|
||||
Ὅ = "O"
|
||||
Ὸ = "O"
|
||||
Ό = "O"
|
||||
Π = "P"
|
||||
Ρ = "R"
|
||||
Ῥ = "R"
|
||||
Σ = "S"
|
||||
Τ = "T"
|
||||
Υ = "Y"
|
||||
Ύ = "Y"
|
||||
Ϋ = "Y"
|
||||
Ὑ = "Y"
|
||||
Ὓ = "Y"
|
||||
Ὕ = "Y"
|
||||
Ὗ = "Y"
|
||||
Ῠ = "Y"
|
||||
Ῡ = "Y"
|
||||
Ὺ = "Y"
|
||||
Ύ = "Y"
|
||||
Φ = "F"
|
||||
Χ = "X"
|
||||
Ψ = "PS"
|
||||
Ω = "O"
|
||||
Ώ = "O"
|
||||
Ὠ = "O"
|
||||
Ὡ = "O"
|
||||
Ὢ = "O"
|
||||
Ὣ = "O"
|
||||
Ὤ = "O"
|
||||
Ὥ = "O"
|
||||
Ὦ = "O"
|
||||
Ὧ = "O"
|
||||
ᾨ = "O"
|
||||
ᾩ = "O"
|
||||
ᾪ = "O"
|
||||
ᾫ = "O"
|
||||
ᾬ = "O"
|
||||
ᾭ = "O"
|
||||
ᾮ = "O"
|
||||
ᾯ = "O"
|
||||
Ὼ = "O"
|
||||
Ώ = "O"
|
||||
ῼ = "O"
|
||||
α = "a"
|
||||
ά = "a"
|
||||
ἀ = "a"
|
||||
ἁ = "a"
|
||||
ἂ = "a"
|
||||
ἃ = "a"
|
||||
ἄ = "a"
|
||||
ἅ = "a"
|
||||
ἆ = "a"
|
||||
ἇ = "a"
|
||||
ᾀ = "a"
|
||||
ᾁ = "a"
|
||||
ᾂ = "a"
|
||||
ᾃ = "a"
|
||||
ᾄ = "a"
|
||||
ᾅ = "a"
|
||||
ᾆ = "a"
|
||||
ᾇ = "a"
|
||||
ὰ = "a"
|
||||
ά = "a"
|
||||
ᾰ = "a"
|
||||
ᾱ = "a"
|
||||
ᾲ = "a"
|
||||
ᾳ = "a"
|
||||
ᾴ = "a"
|
||||
ᾶ = "a"
|
||||
ᾷ = "a"
|
||||
β = "b"
|
||||
γ = "g"
|
||||
δ = "d"
|
||||
ε = "e"
|
||||
έ = "e"
|
||||
ἐ = "e"
|
||||
ἑ = "e"
|
||||
ἒ = "e"
|
||||
ἓ = "e"
|
||||
ἔ = "e"
|
||||
ἕ = "e"
|
||||
ὲ = "e"
|
||||
έ = "e"
|
||||
ζ = "z"
|
||||
η = "i"
|
||||
ή = "i"
|
||||
ἠ = "i"
|
||||
ἡ = "i"
|
||||
ἢ = "i"
|
||||
ἣ = "i"
|
||||
ἤ = "i"
|
||||
ἥ = "i"
|
||||
ἦ = "i"
|
||||
ἧ = "i"
|
||||
ᾐ = "i"
|
||||
ᾑ = "i"
|
||||
ᾒ = "i"
|
||||
ᾓ = "i"
|
||||
ᾔ = "i"
|
||||
ᾕ = "i"
|
||||
ᾖ = "i"
|
||||
ᾗ = "i"
|
||||
ὴ = "i"
|
||||
ή = "i"
|
||||
ῂ = "i"
|
||||
ῃ = "i"
|
||||
ῄ = "i"
|
||||
ῆ = "i"
|
||||
ῇ = "i"
|
||||
θ = "th"
|
||||
ι = "i"
|
||||
ί = "i"
|
||||
ϊ = "i"
|
||||
ΐ = "i"
|
||||
ἰ = "i"
|
||||
ἱ = "i"
|
||||
ἲ = "i"
|
||||
ἳ = "i"
|
||||
ἴ = "i"
|
||||
ἵ = "i"
|
||||
ἶ = "i"
|
||||
ἷ = "i"
|
||||
ὶ = "i"
|
||||
ί = "i"
|
||||
ῐ = "i"
|
||||
ῑ = "i"
|
||||
ῒ = "i"
|
||||
ΐ = "i"
|
||||
ῖ = "i"
|
||||
ῗ = "i"
|
||||
κ = "k"
|
||||
λ = "l"
|
||||
μ = "m"
|
||||
ν = "n"
|
||||
ξ = "ks"
|
||||
ο = "o"
|
||||
ό = "o"
|
||||
ὀ = "o"
|
||||
ὁ = "o"
|
||||
ὂ = "o"
|
||||
ὃ = "o"
|
||||
ὄ = "o"
|
||||
ὅ = "o"
|
||||
ὸ = "o"
|
||||
ό = "o"
|
||||
π = "p"
|
||||
ρ = "r"
|
||||
ῤ = "r"
|
||||
ῥ = "r"
|
||||
σ = "s"
|
||||
ς = "s"
|
||||
τ = "t"
|
||||
υ = "y"
|
||||
ύ = "y"
|
||||
ϋ = "y"
|
||||
ΰ = "y"
|
||||
ὐ = "y"
|
||||
ὑ = "y"
|
||||
ὒ = "y"
|
||||
ὓ = "y"
|
||||
ὔ = "y"
|
||||
ὕ = "y"
|
||||
ὖ = "y"
|
||||
ὗ = "y"
|
||||
ὺ = "y"
|
||||
ύ = "y"
|
||||
ῠ = "y"
|
||||
ῡ = "y"
|
||||
ῢ = "y"
|
||||
ΰ = "y"
|
||||
ῦ = "y"
|
||||
ῧ = "y"
|
||||
φ = "f"
|
||||
χ = "x"
|
||||
ψ = "ps"
|
||||
ω = "o"
|
||||
ώ = "o"
|
||||
ὠ = "o"
|
||||
ὡ = "o"
|
||||
ὢ = "o"
|
||||
ὣ = "o"
|
||||
ὤ = "o"
|
||||
ὥ = "o"
|
||||
ὦ = "o"
|
||||
ὧ = "o"
|
||||
ᾠ = "o"
|
||||
ᾡ = "o"
|
||||
ᾢ = "o"
|
||||
ᾣ = "o"
|
||||
ᾤ = "o"
|
||||
ᾥ = "o"
|
||||
ᾦ = "o"
|
||||
ᾧ = "o"
|
||||
ὼ = "o"
|
||||
ώ = "o"
|
||||
ῲ = "o"
|
||||
ῳ = "o"
|
||||
ῴ = "o"
|
||||
ῶ = "o"
|
||||
ῷ = "o"
|
||||
¨ = ""
|
||||
΅ = ""
|
||||
᾿ = ""
|
||||
῾ = ""
|
||||
῍ = ""
|
||||
῝ = ""
|
||||
῎ = ""
|
||||
῞ = ""
|
||||
῏ = ""
|
||||
῟ = ""
|
||||
῀ = ""
|
||||
῁ = ""
|
||||
΄ = ""
|
||||
΅ = ""
|
||||
` = ""
|
||||
῭ = ""
|
||||
ͺ = ""
|
||||
᾽ = ""
|
||||
А = "A"
|
||||
Б = "B"
|
||||
В = "V"
|
||||
Г = "G"
|
||||
Д = "D"
|
||||
Е = "E"
|
||||
Ё = "E"
|
||||
Ж = "ZH"
|
||||
З = "Z"
|
||||
И = "I"
|
||||
Й = "I"
|
||||
К = "K"
|
||||
Л = "L"
|
||||
М = "M"
|
||||
Н = "N"
|
||||
О = "O"
|
||||
П = "P"
|
||||
Р = "R"
|
||||
С = "S"
|
||||
Т = "T"
|
||||
У = "U"
|
||||
Ф = "F"
|
||||
Х = "KH"
|
||||
Ц = "TS"
|
||||
Ч = "CH"
|
||||
Ш = "SH"
|
||||
Щ = "SHCH"
|
||||
Ы = "Y"
|
||||
Э = "E"
|
||||
Ю = "YU"
|
||||
Я = "YA"
|
||||
а = "A"
|
||||
б = "B"
|
||||
в = "V"
|
||||
г = "G"
|
||||
д = "D"
|
||||
е = "E"
|
||||
ё = "E"
|
||||
ж = "ZH"
|
||||
з = "Z"
|
||||
и = "I"
|
||||
й = "I"
|
||||
к = "K"
|
||||
л = "L"
|
||||
м = "M"
|
||||
н = "N"
|
||||
о = "O"
|
||||
п = "P"
|
||||
р = "R"
|
||||
с = "S"
|
||||
т = "T"
|
||||
у = "U"
|
||||
ф = "F"
|
||||
х = "KH"
|
||||
ц = "TS"
|
||||
ч = "CH"
|
||||
ш = "SH"
|
||||
щ = "SHCH"
|
||||
ы = "Y"
|
||||
э = "E"
|
||||
ю = "YU"
|
||||
я = "YA"
|
||||
Ъ = ""
|
||||
ъ = ""
|
||||
Ь = ""
|
||||
ь = ""
|
||||
|
||||
ð = "d"
|
||||
Ð = "D"
|
||||
þ = "th"
|
||||
Þ = "TH"
|
|
@ -1,830 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functionality tests for Pathauto.
|
||||
*
|
||||
* @ingroup pathauto
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper test class with some added functions for testing.
|
||||
*/
|
||||
class PathautoTestHelper extends DrupalWebTestCase {
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'path';
|
||||
$modules[] = 'token';
|
||||
$modules[] = 'pathauto';
|
||||
$modules[] = 'taxonomy';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
function assertToken($type, $object, $token, $expected) {
|
||||
$this->assertTokens($type, $object, array($token => $expected));
|
||||
}
|
||||
|
||||
function assertTokens($type, $object, array $tokens) {
|
||||
$values = pathauto_get_placeholders($type, $object);
|
||||
$values = $values['values'];
|
||||
foreach ($tokens as $token => $expected) {
|
||||
$this->assertIdentical($values[$token], $expected, t("Token value for [@token] was '@actual', expected value '@expected'.", array('@token' => $token, '@actual' => $values[$token], '@expected' => $expected)));
|
||||
}
|
||||
}
|
||||
|
||||
function saveAlias($source, $alias, $language = '') {
|
||||
path_set_alias($source, $alias, NULL, $language);
|
||||
return db_fetch_array(db_query_range("SELECT * FROM {url_alias} WHERE src = '%s' AND dst = '%s' AND language = '%s' ORDER BY pid DESC", $source, $alias, $language, 0, 1));
|
||||
}
|
||||
|
||||
function saveEntityAlias($entity_type, $entity, $alias, $language = '') {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
return $this->saveAlias($uri['path'], $alias, $language);
|
||||
}
|
||||
|
||||
function assertEntityAlias($entity_type, $entity, $expected_alias, $language = '') {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
$this->assertAlias($uri['path'], $expected_alias, $language);
|
||||
}
|
||||
|
||||
function assertEntityAliasExists($entity_type, $entity) {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
return $this->assertAliasExists(array('source' => $uri['path']));
|
||||
}
|
||||
|
||||
function assertNoEntityAlias($entity_type, $entity, $language = '') {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
$this->assertEntityAlias($entity_type, $entity, $uri['path'], $language);
|
||||
}
|
||||
|
||||
function assertNoEntityAliasExists($entity_type, $entity) {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
$this->assertNoAliasExists(array('source' => $uri['path']));
|
||||
}
|
||||
|
||||
function assertAlias($source, $expected_alias, $language = '') {
|
||||
drupal_clear_path_cache();
|
||||
$alias = drupal_get_path_alias($source, $language);
|
||||
$this->assertIdentical($alias, $expected_alias, t("Alias for %source with language '@language' was %actual, expected %expected.", array('%source' => $source, '%actual' => $alias, '%expected' => $expected_alias, '@language' => $language)));
|
||||
}
|
||||
|
||||
function assertAliasExists($conditions) {
|
||||
$path = $this->path_load($conditions);
|
||||
$this->assertTrue($path, t('Alias with conditions @conditions found.', array('@conditions' => var_export($conditions, TRUE))));
|
||||
return $path;
|
||||
}
|
||||
|
||||
function assertNoAliasExists($conditions) {
|
||||
$alias = $this->path_load($conditions);
|
||||
$this->assertFalse($alias, t('Alias with conditions @conditions not found.', array('@conditions' => var_export($conditions, TRUE))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Backport of Drupal 7's entity_uri() function.
|
||||
*/
|
||||
protected function entity_uri($entity_type, $entity) {
|
||||
$uri = array();
|
||||
|
||||
switch ($entity_type) {
|
||||
case 'node':
|
||||
$uri['path'] = 'node/' . $entity->nid;
|
||||
break;
|
||||
case 'taxonomy_term':
|
||||
$uri['path'] = taxonomy_term_path($entity);
|
||||
break;
|
||||
case 'user':
|
||||
$uri['path'] = 'user/' . $entity->uid;
|
||||
break;
|
||||
default:
|
||||
return $this->fail(t('Unknown entity @type.', array('@type' => $entity_type)));
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backport of Drupal 7's path_load() function.
|
||||
*/
|
||||
protected function path_load($conditions) {
|
||||
if (is_numeric($conditions)) {
|
||||
$conditions = array('pid' => $conditions);
|
||||
}
|
||||
elseif (is_string($conditions)) {
|
||||
$conditions = array('src' => $conditions);
|
||||
}
|
||||
|
||||
// Adjust for some D7 {url_alias} column name changes so we can keep
|
||||
// the test files in sync.
|
||||
if (isset($conditions['source'])) {
|
||||
$conditions['src'] = $conditions['source'];
|
||||
unset($conditions['source']);
|
||||
}
|
||||
if (isset($conditions['alias'])) {
|
||||
$conditions['dst'] = $conditions['alias'];
|
||||
unset($conditions['alias']);
|
||||
}
|
||||
|
||||
$args = array();
|
||||
$schema = drupal_get_schema_unprocessed('system', 'url_alias');
|
||||
foreach ($conditions as $field => $value) {
|
||||
$field_type = $schema['fields'][$field]['type'];
|
||||
if (is_array($value)) {
|
||||
$conditions[$field] = "$field = " . db_placeholders($value, $field_type);
|
||||
$args = array_merge($args, $value);
|
||||
}
|
||||
else {
|
||||
$placeholder = db_type_placeholder($field_type);
|
||||
$conditions[$field] = "$field = $placeholder";
|
||||
$args[] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM {url_alias} WHERE " . implode(' AND ', $conditions);
|
||||
return db_fetch_array(db_query_range($sql, $args, 0, 1));
|
||||
}
|
||||
|
||||
function deleteAllAliases() {
|
||||
db_query("DELETE FROM {url_alias}");
|
||||
drupal_clear_path_cache();
|
||||
}
|
||||
|
||||
function addVocabulary(array $vocabulary = array()) {
|
||||
$vocabulary += array(
|
||||
'name' => drupal_strtolower($this->randomName(5)),
|
||||
'nodes' => array('story' => 'story'),
|
||||
);
|
||||
taxonomy_save_vocabulary($vocabulary);
|
||||
return (object) $vocabulary;
|
||||
}
|
||||
|
||||
function addTerm(stdClass $vocabulary, array $term = array()) {
|
||||
$term += array(
|
||||
'name' => drupal_strtolower($this->randomName(5)),
|
||||
'vid' => $vocabulary->vid,
|
||||
);
|
||||
taxonomy_save_term($term);
|
||||
return (object) $term;
|
||||
}
|
||||
|
||||
function addNodeType(array $type) {
|
||||
if (!isset($type['name'])) {
|
||||
$type['name'] = $this->randomName(8);
|
||||
}
|
||||
|
||||
$type += array(
|
||||
'type' => drupal_strtolower($type['name']),
|
||||
'module' => 'node',
|
||||
'description' => $this->randomName(40),
|
||||
'custom' => TRUE,
|
||||
'modified' => TRUE,
|
||||
'locked' => FALSE,
|
||||
'help' => '',
|
||||
'min_word_count' => '',
|
||||
);
|
||||
|
||||
$type = (object) _node_type_set_defaults($type);
|
||||
node_type_save($type);
|
||||
node_types_rebuild();
|
||||
return $type;
|
||||
}
|
||||
|
||||
function assertEntityPattern($entity_type, $bundle, $language = '', $expected) {
|
||||
$this->refreshVariables();
|
||||
$variables = array(
|
||||
"pathauto_{$entity_type}_{$bundle}_{$language}_pattern",
|
||||
"pathauto_{$entity_type}_{$bundle}_pattern",
|
||||
"pathauto_{$entity_type}_pattern",
|
||||
);
|
||||
$pattern = '';
|
||||
foreach ($variables as $variable) {
|
||||
if ($pattern = variable_get($variable, '')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->assertIdentical($expected, $pattern);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for Pathauto functions.
|
||||
*/
|
||||
class PathautoUnitTestCase extends PathautoTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto unit tests',
|
||||
'description' => 'Unit tests for Pathauto functions.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
parent::setUp($modules);
|
||||
module_load_include('inc', 'pathauto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test _pathauto_get_schema_alias_maxlength().
|
||||
*/
|
||||
function testGetSchemaAliasMaxLength() {
|
||||
$this->assertIdentical(_pathauto_get_schema_alias_maxlength(), 128);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test pathauto_cleanstring().
|
||||
*/
|
||||
function testCleanString() {
|
||||
$tests = array();
|
||||
variable_set('pathauto_ignore_words', ', in, is,that, the , this, with, ');
|
||||
variable_set('pathauto_max_component_length', 35);
|
||||
|
||||
// Test the 'ignored words' removal.
|
||||
$tests['this'] = 'this';
|
||||
$tests['this with that'] = 'this-with-that';
|
||||
$tests['this thing with that thing'] = 'thing-thing';
|
||||
|
||||
// Test length truncation and duplicate separator removal.
|
||||
$tests[' - Pathauto is the greatest - module ever in Drupal history - '] = 'pathauto-greatest-module-ever-drupa';
|
||||
|
||||
// Test that HTML tags are removed.
|
||||
$tests['This <span class="text">text</span> has <br /><a href="http://example.com"><strong>HTML tags</strong></a>.'] = 'text-has-html-tags';
|
||||
$tests[check_plain('This <span class="text">text</span> has <br /><a href="http://example.com"><strong>HTML tags</strong></a>.')] = 'text-has-html-tags';
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = pathauto_cleanstring($input);
|
||||
$this->assertEqual($output, $expected, t("pathauto_cleanstring('@input') expected '@expected', actual '@output'", array('@input' => $input, '@expected' => $expected, '@output' => $output)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the feed alias functionality of pathauto_create_alias().
|
||||
*/
|
||||
function testFeedAliases() {
|
||||
variable_set('pathauto_node_pattern', '[title-raw]');
|
||||
variable_set('pathauto_node_applytofeeds', '');
|
||||
|
||||
// Create a node with an empty title, which should not create an alias.
|
||||
$node = $this->drupalCreateNode(array('title' => ''));
|
||||
$this->assertNoAliasExists(array('source' => "node/{$node->nid}"));
|
||||
$this->assertNoAliasExists(array('source' => "node/{$node->nid}/feed"));
|
||||
|
||||
// Add a title to the node. This should still not generate a feed alias.
|
||||
$node->title = 'Node title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertAliasExists(array('source' => "node/{$node->nid}", 'alias' => 'node-title'));
|
||||
$this->assertNoAliasExists(array('source' => "node/{$node->nid}/feed"));
|
||||
|
||||
// Enable feeds for nodes. A feed alias should now be generated.
|
||||
variable_set('pathauto_node_applytofeeds', ' feed ');
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertAliasExists(array('source' => "node/{$node->nid}/feed", 'alias' => 'node-title/feed'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test _pathauto_get_raw_tokens().
|
||||
*/
|
||||
function testGetRawTokens() {
|
||||
$raw_tokens = _pathauto_get_raw_tokens();
|
||||
$this->assertFalse(in_array('node-path', $raw_tokens), 'Non-raw tokens not included.');
|
||||
$this->assertTrue(in_array('node-path-raw', $raw_tokens), 'Token [catpath] has a matching raw token.');
|
||||
$this->assertFalse(in_array('node-url-raw', $raw_tokens), 'Token [catalias] does not have a matching raw token.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the different update actions in pathauto_create_alias().
|
||||
*/
|
||||
function testUpdateActions() {
|
||||
// Test PATHAUTO_UPDATE_ACTION_NO_NEW with unaliased node and 'insert'.
|
||||
variable_set('pathauto_update_action', 0);
|
||||
$node = $this->drupalCreateNode(array('title' => 'First title'));
|
||||
$this->assertEntityAlias('node', $node, 'content/first-title');
|
||||
|
||||
// Default action is PATHAUTO_UPDATE_ACTION_DELETE.
|
||||
variable_set('pathauto_update_action', 2);
|
||||
$node->title = 'Second title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/second-title');
|
||||
$this->assertNoAliasExists(array('alias' => 'content/first-title'));
|
||||
|
||||
// Test PATHAUTO_UPDATE_ACTION_LEAVE.
|
||||
variable_set('pathauto_update_action', 1);
|
||||
$node->title = 'Third title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/third-title');
|
||||
$this->assertAliasExists(array('source' => "node/{$node->nid}", 'alias' => 'content/second-title'));
|
||||
|
||||
variable_set('pathauto_update_action', 2);
|
||||
$node->title = 'Fourth title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/fourth-title');
|
||||
$this->assertNoAliasExists(array('alias' => 'content/third-title'));
|
||||
// The older second alias is not deleted yet.
|
||||
$older_path = $this->assertAliasExists(array('source' => "node/{$node->nid}", 'alias' => 'content/second-title'));
|
||||
path_set_alias(NULL, NULL, $older_path['pid']);
|
||||
|
||||
variable_set('pathauto_update_action', 0);
|
||||
$node->title = 'Fifth title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/fourth-title');
|
||||
$this->assertNoAliasExists(array('alias' => 'content/fith-title'));
|
||||
|
||||
// Test PATHAUTO_UPDATE_ACTION_NO_NEW with unaliased node and 'update'.
|
||||
$this->deleteAllAliases();
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/fifth-title');
|
||||
|
||||
// Test PATHAUTO_UPDATE_ACTION_NO_NEW with unaliased node and 'bulkupdate'.
|
||||
$this->deleteAllAliases();
|
||||
$node->title = 'Sixth title';
|
||||
pathauto_node_update_alias($node, 'bulkupdate');
|
||||
$this->assertEntityAlias('node', $node, 'content/sixth-title');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that pathauto_create_alias() will not create an alias for a pattern
|
||||
* that does not get any tokens replaced.
|
||||
*/
|
||||
function testNoTokensNoAlias() {
|
||||
$node = $this->drupalCreateNode(array('title' => ''));
|
||||
$this->assertNoEntityAlias('node', $node);
|
||||
|
||||
$node->title = 'hello';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/hello');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the handling of path vs non-path tokens in pathauto_clean_token_values().
|
||||
*
|
||||
* @see PathautoBookTokenTestCase::testBookPathAlias()
|
||||
*/
|
||||
//function testPathTokens() {
|
||||
//}
|
||||
|
||||
function testEntityBundleRenamingDeleting() {
|
||||
// Create a vocabulary type.
|
||||
$vocabulary = $this->addVocabulary();
|
||||
variable_set('pathauto_taxonomy_pattern', 'base');
|
||||
variable_set('pathauto_taxonomy_' . $vocabulary->vid . '_pattern', 'bundle');
|
||||
$this->assertEntityPattern('taxonomy', $vocabulary->vid, '', 'bundle');
|
||||
|
||||
// Delete the vocabulary, which should cause its pattern variable to also
|
||||
// be deleted.
|
||||
taxonomy_del_vocabulary($vocabulary->vid);
|
||||
$this->assertEntityPattern('taxonomy', $vocabulary->vid, '', 'base');
|
||||
|
||||
// Create a node type and test that it's pattern variable works.
|
||||
$type = $this->addNodeType(array('type' => 'old_name'));
|
||||
variable_set('pathauto_node_pattern', 'base');
|
||||
variable_set("pathauto_node_old_name_pattern", 'bundle');
|
||||
$this->assertEntityPattern('node', 'old_name', '', 'bundle');
|
||||
|
||||
// Rename the node type's machine name, which should cause its pattern
|
||||
// variable to also be renamed.
|
||||
$type->type = 'new_name';
|
||||
$type->old_type = 'old_name';
|
||||
node_type_save($type);
|
||||
node_types_rebuild();
|
||||
$this->assertEntityPattern('node', 'new_name', '', 'bundle');
|
||||
$this->assertEntityPattern('node', 'old_name', '', 'base');
|
||||
|
||||
// Delete the node type, which should cause its pattern variable to also
|
||||
// be deleted.
|
||||
node_type_delete($type->type);
|
||||
$this->assertEntityPattern('node', 'new_name', '', 'base');
|
||||
}
|
||||
|
||||
function testNoExistingPathAliases() {
|
||||
variable_set('pathauto_node_page_pattern', '[title-raw]');
|
||||
variable_set('pathauto_punctuation_period', 2); // Do not replace periods.
|
||||
|
||||
// Check that Pathauto does not create an alias of '/admin'.
|
||||
$node = $this->drupalCreateNode(array('title' => 'Admin', 'type' => 'page'));
|
||||
$this->assertNoEntityAlias('node', $node);
|
||||
|
||||
// Check that Pathauto does not create an alias of '/modules'.
|
||||
$node->title = 'Modules';
|
||||
node_save($node);
|
||||
$this->assertNoEntityAlias('node', $node);
|
||||
|
||||
// Check that Pathauto does not create an alias of '/index.php'.
|
||||
$node->title = 'index.php';
|
||||
node_save($node);
|
||||
$this->assertNoEntityAlias('node', $node);
|
||||
|
||||
// Check that a safe value gets an automatic alias. This is also a control
|
||||
// to ensure the above tests work properly.
|
||||
$node->title = 'Safe value';
|
||||
node_save($node);
|
||||
$this->assertEntityAlias('node', $node, 'safe-value');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper test class with some added functions for testing.
|
||||
*/
|
||||
class PathautoFunctionalTestHelper extends PathautoTestHelper {
|
||||
protected $admin_user;
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
parent::setUp($modules);
|
||||
|
||||
// Set pathauto settings we assume to be as-is in this test.
|
||||
variable_set('pathauto_node_page_pattern', 'content/[title-raw]');
|
||||
|
||||
// Allow other modules to add additional permissions for the admin user.
|
||||
$permissions = array(
|
||||
'administer pathauto',
|
||||
'administer url aliases',
|
||||
'create url aliases',
|
||||
'administer nodes',
|
||||
'administer users',
|
||||
);
|
||||
$args = func_get_args();
|
||||
if (isset($args[1]) && is_array($args[1])) {
|
||||
$permissions = array_merge($permissions, $args[1]);
|
||||
}
|
||||
$this->admin_user = $this->drupalCreateUser($permissions);
|
||||
|
||||
$this->drupalLogin($this->admin_user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic pathauto functionality.
|
||||
*/
|
||||
class PathautoFunctionalTestCase extends PathautoFunctionalTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto basic tests',
|
||||
'description' => 'Test basic pathauto functionality.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic functional testing of Pathauto.
|
||||
*/
|
||||
function testNodeEditing() {
|
||||
// Create node for testing.
|
||||
$random_title = $this->randomName(10);
|
||||
$title = ' Simpletest title ' . $random_title . ' [';
|
||||
$automatic_alias = 'content/simpletest-title-' . strtolower($random_title);
|
||||
$node = $this->drupalCreateNode(array('title' => $title, 'type' => 'page'));
|
||||
|
||||
// Look for alias generated in the form.
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
$this->assertFieldChecked('edit-pathauto-perform-alias');
|
||||
$this->assertFieldByName('path', $automatic_alias, 'Proper automated alias generated.');
|
||||
|
||||
// Check whether the alias actually works.
|
||||
$this->drupalGet($automatic_alias);
|
||||
$this->assertText($title, 'Node accessible through automatic alias.');
|
||||
|
||||
// Manually set the node's alias.
|
||||
$manual_alias = 'content/' . $node->nid;
|
||||
$edit = array(
|
||||
'pathauto_perform_alias' => FALSE,
|
||||
'path' => $manual_alias,
|
||||
);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertText(t('@type @title has been updated', array('@type' => 'Page', '@title' => $title)));
|
||||
|
||||
// Check that the automatic alias checkbox is now unchecked by default.
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
$this->assertNoFieldChecked('edit-pathauto-perform-alias');
|
||||
$this->assertFieldByName('path', $manual_alias);
|
||||
|
||||
// Submit the node form with the default values.
|
||||
$this->drupalPost(NULL, array(), t('Save'));
|
||||
$this->assertText(t('@type @title has been updated', array('@type' => 'Page', '@title' => $title)));
|
||||
|
||||
// Test that the old (automatic) alias has been deleted and only accessible
|
||||
// through the new (manual) alias.
|
||||
$this->drupalGet($automatic_alias);
|
||||
$this->assertResponse(404, 'Node not accessible through automatic alias.');
|
||||
$this->drupalGet($manual_alias);
|
||||
$this->assertText($title, 'Node accessible through manual alias.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test node operations.
|
||||
*/
|
||||
function testNodeOperations() {
|
||||
$node1 = $this->drupalCreateNode(array('title' => 'node1'));
|
||||
$node2 = $this->drupalCreateNode(array('title' => 'node2'));
|
||||
|
||||
// Delete all current URL aliases.
|
||||
$this->deleteAllAliases();
|
||||
|
||||
$edit = array(
|
||||
'operation' => 'pathauto_update_alias',
|
||||
"nodes[{$node1->nid}]" => TRUE,
|
||||
);
|
||||
$this->drupalPost('admin/content/node', $edit, t('Update'));
|
||||
$this->assertText('Updated URL alias for 1 node.');
|
||||
|
||||
$this->assertEntityAlias('node', $node1, 'content/' . $node1->title);
|
||||
$this->assertEntityAlias('node', $node2, 'node/' . $node2->nid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test user operations.
|
||||
*/
|
||||
function testUserOperations() {
|
||||
$account = $this->drupalCreateUser();
|
||||
|
||||
// Delete all current URL aliases.
|
||||
$this->deleteAllAliases();
|
||||
|
||||
$edit = array(
|
||||
'operation' => 'pathauto_update_alias',
|
||||
"accounts[{$account->uid}]" => TRUE,
|
||||
);
|
||||
$this->drupalPost('admin/user/user', $edit, t('Update'));
|
||||
$this->assertText('Updated URL alias for 1 user account.');
|
||||
|
||||
$this->assertEntityAlias('user', $account, 'users/' . drupal_strtolower($account->name));
|
||||
$this->assertEntityAlias('user', $this->admin_user, 'user/' . $this->admin_user->uid);
|
||||
}
|
||||
|
||||
function testSettingsValidation() {
|
||||
$edit = array();
|
||||
$edit['pathauto_max_length'] = 'abc';
|
||||
$edit['pathauto_max_component_length'] = 'abc';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The field Maximum alias length is not a valid number.');
|
||||
$this->assertText('The field Maximum component length is not a valid number.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$edit['pathauto_max_length'] = '0';
|
||||
$edit['pathauto_max_component_length'] = '0';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The field Maximum alias length cannot be less than 1.');
|
||||
$this->assertText('The field Maximum component length cannot be less than 1.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$edit['pathauto_max_length'] = '999';
|
||||
$edit['pathauto_max_component_length'] = '999';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The field Maximum alias length cannot be greater than 128.');
|
||||
$this->assertText('The field Maximum component length cannot be greater than 128.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$edit['pathauto_max_length'] = '50';
|
||||
$edit['pathauto_max_component_length'] = '50';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The configuration options have been saved.');
|
||||
}
|
||||
|
||||
function testPatternsValidation() {
|
||||
$edit = array();
|
||||
$edit['pathauto_node_pattern'] = '[title-raw]/[user-created-small]/[cat]/[term]';
|
||||
$edit['pathauto_node_page_pattern'] = 'page';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The Default path pattern (applies to all node types with blank patterns below) is using the following invalid tokens: [user-created-small], [cat].');
|
||||
$this->assertText('The Pattern for all Page paths should contain at least one token to ensure unique URL aliases are created.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$edit['pathauto_node_pattern'] = '[title-raw]';
|
||||
$edit['pathauto_node_page_pattern'] = 'page/[title-raw]';
|
||||
$edit['pathauto_node_story_pattern'] = '';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The configuration options have been saved.');
|
||||
}
|
||||
}
|
||||
|
||||
class PathautoLocaleTestCase extends PathautoFunctionalTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto localization tests',
|
||||
'description' => 'Test pathauto functionality with localization and translation.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'locale';
|
||||
$modules[] = 'translation';
|
||||
parent::setUp($modules, array('administer languages'));
|
||||
|
||||
// Add predefined French language and reset the locale cache.
|
||||
require_once './includes/locale.inc';
|
||||
locale_add_language('fr', NULL, NULL, LANGUAGE_LTR, '', 'fr');
|
||||
language_list('language', TRUE);
|
||||
drupal_init_language();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when an English node is updated, its old English alias is
|
||||
* updated and its newer French alias is left intact.
|
||||
*/
|
||||
function testLanguageAliases() {
|
||||
$node = array(
|
||||
'title' => 'English node',
|
||||
'language' => 'en',
|
||||
'path' => 'english-node',
|
||||
'pathauto_perform_alias' => FALSE,
|
||||
);
|
||||
$node = $this->drupalCreateNode($node);
|
||||
$english_alias = $this->path_load(array('alias' => 'english-node'));
|
||||
$this->assertTrue($english_alias, 'Alias created with proper language.');
|
||||
|
||||
// Also save a French alias that should not be left alone, even though
|
||||
// it is the newer alias.
|
||||
$this->saveEntityAlias('node', $node, 'french-node', 'fr');
|
||||
|
||||
// Add an alias with the soon-to-be generated alias, causing the upcoming
|
||||
// alias update to generate a unique alias with the '-0' suffix.
|
||||
$this->saveAlias('node/invalid', 'content/english-node', '');
|
||||
|
||||
// Update the node, triggering a change in the English alias.
|
||||
$node->pathauto_perform_alias = TRUE;
|
||||
pathauto_nodeapi($node, 'update');
|
||||
|
||||
// Check that the new English alias replaced the old one.
|
||||
$this->assertEntityAlias('node', $node, 'content/english-node-0', 'en');
|
||||
$this->assertEntityAlias('node', $node, 'french-node', 'fr');
|
||||
$this->assertAliasExists(array('pid' => $english_alias['pid'], 'alias' => 'content/english-node-0'));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unit tests for the book tokens provided by Pathauto.
|
||||
*/
|
||||
class PathautoBookTokenTestCase extends PathautoTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto book tokens',
|
||||
'description' => 'Unit tests for the book tokens provided by Pathauto.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'book';
|
||||
parent::setUp($modules);
|
||||
|
||||
variable_set('book_allowed_types', array('book', 'page'));
|
||||
variable_set('pathauto_node_book_pattern', '[bookpathalias]/[title-raw]');
|
||||
}
|
||||
|
||||
function testBookPathAlias() {
|
||||
// Add a non-book node.
|
||||
$non_book_node = $this->drupalCreateNode(array('type' => 'book'));
|
||||
$this->assertToken('node', $non_book_node, 'bookpathalias', '');
|
||||
|
||||
// Add a root book page.
|
||||
$parent_node = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Root',
|
||||
'book' => array('bid' => 'new') + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'bookpathalias' => '',
|
||||
);
|
||||
$this->assertTokens('node', $parent_node, $tokens);
|
||||
|
||||
// Add a first child page.
|
||||
$child_node1 = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Sub page1',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $parent_node->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'bookpathalias' => 'root',
|
||||
);
|
||||
$this->assertTokens('node', $child_node1, $tokens);
|
||||
|
||||
// Add a second child page.
|
||||
$child_node2 = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Sub page2',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $parent_node->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'bookpathalias' => 'root',
|
||||
);
|
||||
$this->assertTokens('node', $child_node2, $tokens);
|
||||
|
||||
// Add a child page on an existing child page.
|
||||
$sub_child_node1 = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Sub-sub Page1',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $child_node1->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'bookpathalias' => 'root/sub-page1',
|
||||
);
|
||||
$this->assertTokens('node', $sub_child_node1, $tokens);
|
||||
|
||||
// Test that path tokens should not be altered.
|
||||
$this->saveEntityAlias('node', $child_node1, 'My Crazy/Alias/');
|
||||
pathauto_nodeapi($sub_child_node1, 'update');
|
||||
$this->assertEntityAlias('node', $sub_child_node1, 'My Crazy/Alias/sub-sub-page1');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unit tests for the taxonomy tokens provided by Pathauto.
|
||||
*/
|
||||
class PathautoTaxonomyTokenTestCase extends PathautoFunctionalTestHelper {
|
||||
protected $vocab;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto taxonomy tokens',
|
||||
'description' => 'Unit tests for the taxonomy tokens provided by Pathauto.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'taxonomy';
|
||||
parent::setUp($modules);
|
||||
|
||||
variable_set('pathauto_taxonomy_pattern', 'category/[vocab-raw]/[cat-raw]');
|
||||
// Reset the static taxonomy.module caches.
|
||||
taxonomy_vocabulary_load(0, TRUE);
|
||||
taxonomy_get_term(0, TRUE);
|
||||
$this->vocab = $this->addVocabulary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the [catpath] and [catalias] tokens.
|
||||
*/
|
||||
function testCatTokens() {
|
||||
$term1 = $this->addTerm($this->vocab);
|
||||
$tokens = array(
|
||||
'catpath' => $term1->name,
|
||||
'catalias' => "category/{$this->vocab->name}/{$term1->name}",
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term1, $tokens);
|
||||
|
||||
// Change the term name to check that the alias is also changed.
|
||||
// Regression test for http://drupal.org/node/822174.
|
||||
$term1->oldname = $term1->name;
|
||||
$term1->name = drupal_strtolower($this->randomName());
|
||||
$form_values = (array) $term1;
|
||||
taxonomy_save_term($form_values);
|
||||
$tokens = array(
|
||||
'catpath' => $term1->name,
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term1, $tokens);
|
||||
|
||||
$term2 = $this->addTerm($this->vocab, array('parent' => $term1->tid));
|
||||
$tokens = array(
|
||||
'catpath' => "{$term1->name}/{$term2->name}",
|
||||
'catalias' => "category/{$this->vocab->name}/{$term2->name}",
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term2, $tokens);
|
||||
|
||||
$term3 = $this->addTerm($this->vocab, array('parent' => $term2->tid, 'name' => ' foo/bar fer|zle '));
|
||||
$tokens = array(
|
||||
'catpath' => "{$term1->name}/{$term2->name}/foobar-ferzle",
|
||||
'catalias' => "category/{$this->vocab->name}/foobar-ferzle",
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term3, $tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the [termpath] token.
|
||||
*/
|
||||
function testTermTokens() {
|
||||
$term1 = $this->addTerm($this->vocab, array('weight' => 5));
|
||||
$term2 = $this->addTerm($this->vocab, array('weight' => -5));
|
||||
$term3 = $this->addTerm($this->vocab, array('weight' => 0));
|
||||
|
||||
$node = $this->drupalCreateNode(array(
|
||||
'type' => 'story',
|
||||
'taxonomy' => array($term1->tid, $term2->tid, $term3->tid),
|
||||
));
|
||||
$tokens = array(
|
||||
'termpath' => $term2->name,
|
||||
'termalias' => "category/{$this->vocab->name}/{$term2->name}",
|
||||
);
|
||||
$this->assertTokens('node', $node, $tokens);
|
||||
$this->assertToken('node', $node, 'termpath', $term2->name);
|
||||
$this->assertToken('node', $node, 'termalias', "category/{$this->vocab->name}/{$term2->name}");
|
||||
|
||||
$non_term_node = $this->drupalCreateNode(array('type' => 'story'));
|
||||
$tokens = array(
|
||||
'termpath' => '',
|
||||
'termalias' => '',
|
||||
);
|
||||
$this->assertTokens('node', $non_term_node, $tokens);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
All necessary code is included with the module. The hashing functionality is
|
||||
backported as the include file from Drupal 7 with minor changes.
|
||||
|
||||
This module requires PHP 5.2.4 as a minimum version (the same as Drupal 7).
|
||||
|
||||
During installation all existing user passwords will be converted to the
|
||||
more secure form. This is a lengthy process. Using drush expect a
|
||||
conversion time on the order of 3-5 minutes per 10,000 users. Using
|
||||
the modules page, a batch process will run and will take at least as long.
|
||||
|
||||
Once you have installed this module, all password hashes will be converted.
|
||||
You will not be able to disable or uninstall it except via upgrading to
|
||||
Drupal 7. Test this on your developent copy of your site first. You have
|
||||
been warned.
|
||||
|
||||
Note the enable hook tries to convert all existing user passwords. If you have more
|
||||
than a thousand users a batch job will start when the module is enabled if enabled
|
||||
via the modules page. If enabled via drush or with <= 1000 users, no batching
|
||||
wiil be performed. You may need to increase the allowed PHP memory if enabling
|
||||
via drush for very large numbers of users.
|
||||
|
||||
Please test everything on your development copy of the site first!
|
||||
|
||||
A core patch is also included with the module as user_load.D6.patch
|
||||
This patch is not needed for typical sites, but may be required for
|
||||
certain contrib modules that perform user registration with an external
|
||||
service or manipulate the user registration flow.
|
|
@ -1,5 +0,0 @@
|
|||
This module was created by Matt Westgate <drupal at asitis dot org>
|
||||
Maintained up to version 4.6 by Karsten Mueller <kmue at mac dot com>
|
||||
Maintained up to version 4.7 by Peter John Hartman <peterjohnhartman at gmail.com>
|
||||
Some bug fixes by David Kent Norman on Dec 20, 2005 <deekayen at: deekayen {dot} net>
|
||||
and is currently maintained by Joao Ventura <joao at venturas dot org>.
|
|
@ -1,94 +0,0 @@
|
|||
INSTALLATION
|
||||
------------
|
||||
|
||||
Decompress the print-n.x-n.n.tar.gz file into your Drupal modules
|
||||
directory.
|
||||
|
||||
Enable the print module: Administer > Site building > Modules
|
||||
(admin/build/modules)
|
||||
|
||||
PDF TOOL
|
||||
--------
|
||||
|
||||
The print_pdf module requires the use of an external PDF generation tool.
|
||||
The currently supported tools are dompdf, TCPDF and wkhtmltopdf. Please
|
||||
note that any errors/bugs in those tools need to be reported and fixed by
|
||||
their maintainers. DO NOT report bugs in those tools in the print module's
|
||||
issue queue at Drupal.org.
|
||||
|
||||
supported paths:
|
||||
* print module lib directory (usually modules/print/lib)
|
||||
* libraries directory (libraries)
|
||||
|
||||
dompdf support:
|
||||
The dompdf tool produces results that are more faithful to the HTML
|
||||
printer-friendly page. Unicode is not supported (only ISO-8859-1).
|
||||
This tool is not supported and there are several known bugs that result
|
||||
from its incomplete implementation.
|
||||
|
||||
1. Download dompdf from http://code.google.com/p/dompdf/downloads/list
|
||||
2. Extract the contents of the downloaded package into one of the
|
||||
supported paths.
|
||||
3. Check if dompdf_config.inc.php fits your installation. In 99% of cases,
|
||||
no changes are necessary, so just try to use it and only edit anything if
|
||||
the PDF generation fails.
|
||||
4. Grant write access to the lib/fonts directory to your webserver user.
|
||||
5. If you're using dompdf-0.5.1, delete the dompdf.php file as it contains
|
||||
a security vulnerability
|
||||
6. If you're using dompdf-0.6 or later, you can try to enable the Unicode
|
||||
support, but you'll need to add some Unicode fonts. See
|
||||
http://groups.google.com/group/dompdf/browse_thread/thread/9f7bc0162b04d5cf
|
||||
for further info on this.
|
||||
7. Check http://code.google.com/p/dompdf/ for further information.
|
||||
|
||||
TCPDF support:
|
||||
TCPDF seems to be more actively developed than dompdf, but it's support
|
||||
for CSS is considerably worse. Unicode is supported (use of Unicode fonts
|
||||
result in HUGE files). Page header and footer are supported. This module
|
||||
requires TCPDF >= 4.0.000.
|
||||
|
||||
1. Download TCPDF from http://sourceforge.net/projects/tcpdf/
|
||||
2. Extract the contents of the downloaded package into one of the
|
||||
supported paths. There is no need to modify the config/tcpdf_config.php
|
||||
file, as the module self-configures TCPDF.
|
||||
3. Grant write access to the cache and images directories to your
|
||||
webserver user.
|
||||
4. Check http://tcpdf.sourceforge.net/ for further information.
|
||||
|
||||
wkhtmltopdf support:
|
||||
|
||||
1. Download wkhtmltopdf from
|
||||
http://code.google.com/p/wkhtmltopdf/downloads/list. You can choose to
|
||||
download the source and compile it or simply download the static binary,
|
||||
which doesn't require you to compile anything. Note that the compiled
|
||||
version may require a running X server (static uses patched libs that can
|
||||
work without one).
|
||||
2. Place the wkhtmltopdf executable into one of the supported paths.
|
||||
(usually libraries). You can also place a symbolic link to the executable.
|
||||
3. Check http://code.google.com/p/wkhtmltopdf/ for further information.
|
||||
|
||||
UPDATE
|
||||
------
|
||||
|
||||
When updating from a previous version, just remove the print directory and
|
||||
follow the instructions above. Make sure that you backup any costumization
|
||||
to the print.tpl.php and print.css files.
|
||||
|
||||
ROBOTS
|
||||
------
|
||||
|
||||
Even though it is possible to set per-page robots settings, the following
|
||||
can be placed in your robots.txt file after the User-agent line to prevent
|
||||
search engines from even asking for the page:
|
||||
|
||||
Disallow: /print/
|
||||
|
||||
Also, for updates from older versions (<=4.7.x-1.0 and <=5.x-1.2) which used
|
||||
node/nnn/print instead of print/nnn, the following lines can prevent
|
||||
requests from Google for the obsolete print URLs:
|
||||
|
||||
Disallow: /*/print$
|
||||
|
||||
Note that pattern matching in robots.txt is a Google extension (see
|
||||
http://www.google.com/support/webmasters/bin/answer.py?answer=40367 for more
|
||||
information).
|
|
@ -1,3 +0,0 @@
|
|||
PRINT MODULE
|
||||
M: Joao Ventura <joao at venturas dot org>
|
||||
S: maintained
|
|
@ -1,5 +0,0 @@
|
|||
Instead of placing the downloaded external libs (such as TCPDF, dompdf,
|
||||
etc.) used by the print module here, you should place them in libraries.
|
||||
|
||||
This directory is still a valid location for them, however. The Libraries
|
||||
API module library path is also valid.
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
1. Running secure pages on the Nginx web server. See http://drupal.org/node/390450#comment-1420518
|
||||
|
||||
The text from this reference below.
|
||||
|
||||
----8<----
|
||||
If you are on Nginx, Then add the little code in your Nginx conf file.
|
||||
|
||||
fastcgi_param HTTPS on;
|
||||
|
||||
Here is all the code in my host conf at the php section.
|
||||
location ~ .*\.(php|php5)?$
|
||||
{
|
||||
#fastcgi_pass unix:/tmp/php-cgi.sock;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
include fcgi.conf;
|
||||
fastcgi_param HTTPS on;
|
||||
}
|
||||
|
||||
Reload your nginx server, then you may get the enable box active.
|
||||
----8<----
|
|
@ -1,386 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides SimpleTests for Secure Pages module.
|
||||
*/
|
||||
|
||||
class SecurePagesTestCase extends DrupalWebTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Secure Pages',
|
||||
'description' => 'Test Secure Pages redirects.',
|
||||
'group' => 'Secure Pages',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('securepages', 'comment', 'path', 'locale');
|
||||
variable_set('https', TRUE);
|
||||
variable_set('securepages_enable', TRUE);
|
||||
variable_set('comment_form_location_story', COMMENT_FORM_BELOW);
|
||||
variable_set('comment_preview_story', COMMENT_PREVIEW_OPTIONAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all the test functions. These are run from a single outer function to avoid
|
||||
* multiple re-installs by simpletest.
|
||||
*/
|
||||
function testSecurePages() {
|
||||
$this->_testSettingsForm();
|
||||
$this->_testMatch();
|
||||
$this->_testLocale();
|
||||
$this->_testAnonymous();
|
||||
$this->_testFormAlter();
|
||||
$this->_testCachedResponse();
|
||||
$this->_testPathAlias();
|
||||
$this->_testOpenRedirect();
|
||||
$this->_testXHR();
|
||||
$this->_testRoles();
|
||||
$this->_testPathNorms();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test submitting the settings form
|
||||
*/
|
||||
function _testSettingsForm() {
|
||||
// Undo the setUp() function.
|
||||
variable_del('securepages_enable');
|
||||
|
||||
// Enable securepages.
|
||||
$this->web_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages'));
|
||||
$this->loginHTTPS($this->web_user);
|
||||
$edit = array('securepages_enable' => 1);
|
||||
$this->drupalPost($this->_toHTTPS(url('admin/build/securepages', array('absolute' => TRUE))), $edit, t('Save configuration'));
|
||||
$this->assertRaw(t('The configuration options have been saved.'));
|
||||
$this->drupalLogout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the securepages_match() function.
|
||||
*/
|
||||
function _testMatch() {
|
||||
variable_set('securepages_ignore', '*/autocomplete/*');
|
||||
$this->assertTrue(securepages_match('user'), 'path user matches.');
|
||||
$this->assertTrue(securepages_match('user/login'), 'path user/login matches.');
|
||||
$this->assertTrue(securepages_match('admin/modules'), 'path admin/modules matches.');
|
||||
$this->assertFalse(securepages_match('node'), 'path node does not match.');
|
||||
$this->assertTrue(securepages_match('user/autocomplete/alice') == securepages_is_secure() ? 1 : 0, 'autocomplete path is ignored.');
|
||||
|
||||
// Clean up
|
||||
variable_del('securepages_ignore');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests correct operation with locale module.
|
||||
*/
|
||||
function _testLocale() {
|
||||
// Enable "Switch back to http pages when there are no matches".
|
||||
variable_set('securepages_switch', TRUE);
|
||||
|
||||
// User to add and remove language.
|
||||
$admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Add predefined language.
|
||||
$edit = array(
|
||||
'langcode' => 'fr',
|
||||
);
|
||||
$this->drupalPost('admin/settings/language/add', $edit, t('Add language'));
|
||||
$this->assertText('fr', t('has been created and can now be used'));
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language_negotiation' => '1');
|
||||
$this->drupalPost('admin/settings/language/configure', $edit, t('Save settings'));
|
||||
|
||||
$languages = language_list('language');
|
||||
$lang = $languages['fr'];
|
||||
$this->drupalGet('user', array('language' => $lang));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTPS(url('user', array('absolute' => TRUE, 'language' => $lang))));
|
||||
$this->assertTrue(strstr($this->url, '/fr/'), t('URL contains language prefix.'));
|
||||
|
||||
$this->drupalGet($this->_toHTTPS(url('', array('absolute' => TRUE, 'language' => $lang))));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTP(url('', array('absolute' => TRUE, 'language' => $lang))));
|
||||
|
||||
// Clean up
|
||||
variable_del('securepages_switch');
|
||||
$this->drupalLogout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for anonymous browsing with securepages.
|
||||
*/
|
||||
function _testAnonymous() {
|
||||
// Visit the home page and /node with plain HTTP.
|
||||
$this->drupalGet('');
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl(url('', array('absolute' => TRUE)));
|
||||
$this->drupalGet('node');
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl(url('node', array('absolute' => TRUE)));
|
||||
|
||||
// Visit the login page and confirm that browser is redirected to HTTPS.
|
||||
$this->drupalGet('user');
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTPS(url('user', array('absolute' => TRUE))));
|
||||
|
||||
// Visit the home page and /node with HTTPS and confirm that no redirection happens.
|
||||
$this->drupalGet($this->_toHTTPS(url('', array('absolute' => TRUE))));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTPS(url('', array('absolute' => TRUE))));
|
||||
$this->drupalGet($this->_toHTTPS(url('node', array('absolute' => TRUE))));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTPS(url('node', array('absolute' => TRUE))));
|
||||
|
||||
// Enable "Switch back to http pages when there are no matches".
|
||||
variable_set('securepages_switch', TRUE);
|
||||
|
||||
// Visit the home page and /node with HTTPS and confirm that switch-back happens.
|
||||
$this->drupalGet($this->_toHTTPS(url('', array('absolute' => TRUE))));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl(url('', array('absolute' => TRUE)));
|
||||
$this->drupalGet($this->_toHTTPS(url('node', array('absolute' => TRUE))));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTP(url('', array('absolute' => TRUE))));
|
||||
|
||||
// Clean up
|
||||
variable_del('securepages_pages');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the ability to alter form actions.
|
||||
*
|
||||
* Uses the comment form, since it has an #action set.
|
||||
*/
|
||||
function _testFormAlter() {
|
||||
variable_set('securepages_switch', TRUE);
|
||||
|
||||
// Enable anonymous user comments.
|
||||
db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", 'access comments, access content, post comments, post comments without approval', DRUPAL_ANONYMOUS_RID);
|
||||
|
||||
$this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'post comments without approval'));
|
||||
$node = $this->drupalCreateNode(array('type' => 'story', 'promote' => 1));
|
||||
|
||||
foreach (array('anonymous', 'authenticated') as $mode) {
|
||||
if ($mode == 'authenticated') {
|
||||
$this->drupalLogin($this->web_user);
|
||||
}
|
||||
|
||||
// Test plain HTTP posting to HTTPS.
|
||||
variable_set('securepages_pages', "comment/reply/*\nuser*");
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertFieldByXPath('//form[@id="comment-form" and starts-with(@action, "https:")]', NULL, "The $mode comment form action is https.");
|
||||
$comment_body = $this->randomName(8);
|
||||
$this->drupalPost(NULL, array('comment' => $comment_body), t('Save'));
|
||||
$this->assertRaw($comment_body);
|
||||
|
||||
// Test HTTPS posting to plain HTTP.
|
||||
variable_set('securepages_pages', "node/*\nuser*");
|
||||
$this->drupalGet($this->_toHTTPS(url('node/' . $node->nid), array('absolute' => TRUE)));
|
||||
$this->assertUrl($this->_toHTTPS(url('node/' . $node->nid, array('absolute' => TRUE))));
|
||||
$this->assertFieldByXPath('//form[@id="comment-form" and starts-with(@action, "http:")]', NULL, "The $mode comment form action is http.");
|
||||
$comment_body = $this->randomName(8);
|
||||
$this->drupalPost(NULL, array('comment' => $comment_body), t('Save'));
|
||||
$this->assertRaw($comment_body);
|
||||
}
|
||||
$this->drupalLogout();
|
||||
|
||||
// Test the user login block.
|
||||
$this->drupalGet('');
|
||||
$edit = array(
|
||||
'name' => $this->web_user->name,
|
||||
'pass' => $this->web_user->pass_raw,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Log in'));
|
||||
$this->drupalGet('user/' . $this->web_user->uid . '/edit');
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Clean up
|
||||
$this->drupalLogout();
|
||||
variable_del('securepages_pages');
|
||||
variable_del('securepages_switch');
|
||||
}
|
||||
|
||||
function _testCachedResponse() {
|
||||
// Enable the page cache and fetch the login page.
|
||||
variable_set('cache', TRUE);
|
||||
$url = url('user/login', array('absolute' => TRUE));
|
||||
$this->drupalGet($url);
|
||||
|
||||
// Short-circuit redirects within the simpletest browser.
|
||||
variable_set('simpletest_maximum_redirects', 0);
|
||||
$this->drupalGet($url);
|
||||
$this->assertResponse(302);
|
||||
$this->assertEqual($this->drupalGetHeader('Location'), $this->_toHTTPS(url('user/login', array('absolute' => TRUE))));
|
||||
// $this->assertEqual($this->drupalGetHeader('X-Securepages-Cache'), 'HIT', 'Page was cached.'); @FIXME
|
||||
|
||||
// Clean up
|
||||
variable_del('cache');
|
||||
variable_del('simpletest_maximum_redirects');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test redirection on aliased paths.
|
||||
*/
|
||||
function _testPathAlias() {
|
||||
variable_set('securepages_pages', "node/*\nuser*");
|
||||
|
||||
// Create test user and login.
|
||||
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases'));
|
||||
$this->drupalLogin($web_user);
|
||||
|
||||
// Create test node.
|
||||
$node = $this->drupalCreateNode();
|
||||
|
||||
// Create alias.
|
||||
$edit = array();
|
||||
$edit['src'] = 'node/' . $node->nid;
|
||||
$edit['dst'] = $this->randomName(8);
|
||||
$this->drupalPost('admin/build/path/add', $edit, t('Create new alias'));
|
||||
|
||||
// Short-circuit redirects within the simpletest browser.
|
||||
variable_set('simpletest_maximum_redirects', 0);
|
||||
$this->drupalGet($edit['dst'], array('absolute' => TRUE));
|
||||
$this->assertResponse(302);
|
||||
$this->assertEqual($this->drupalGetHeader('Location'), $this->_toHTTPS(url($edit['dst'], array('absolute' => TRUE))));
|
||||
|
||||
// Clean up
|
||||
variable_del('simpletest_maximum_redirects');
|
||||
$this->drupalLogout();
|
||||
variable_del('securepages_pages');
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that securepages is not an open redirect.
|
||||
*/
|
||||
function _testOpenRedirect() {
|
||||
// Short-circuit redirects within the simpletest browser.
|
||||
variable_set('simpletest_maximum_redirects', 0);
|
||||
variable_set('securepages_switch', TRUE);
|
||||
|
||||
global $base_url, $base_path;
|
||||
$secure_base_url = str_replace('http', 'https', $base_url);
|
||||
$this->drupalGet($secure_base_url . $base_path . '?q=http://example.com/', array('external' => TRUE));
|
||||
$this->assertResponse(302);
|
||||
$this->assertTrue(strstr($this->drupalGetHeader('Location'), $base_url), t('Open redirect test passed.'));
|
||||
|
||||
variable_del('simpletest_maximum_redirects');
|
||||
$this->drupalGet($secure_base_url . $base_path . '?q=' . urlencode('http://example.com/'), array('external' => TRUE));
|
||||
$this->assertResponse(404);
|
||||
|
||||
// Clean up
|
||||
variable_del('securepages_switch');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test detection of XHR requests.
|
||||
*/
|
||||
function _testXHR() {
|
||||
$admin_user = $this->drupalCreateUser(array('access user profiles', 'administer users', 'access administration pages'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Without XHR header
|
||||
$this->drupalGet($this->_toHTTP(url('user/autocomplete/a', array('absolute' => TRUE))));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTPS(url('user/autocomplete/a', array('absolute' => TRUE))));
|
||||
|
||||
// With XHR header
|
||||
$this->drupalGet($this->_toHTTP(url('user/autocomplete/a', array('absolute' => TRUE))), array(), array('X-Requested-With: XMLHttpRequest'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTP(url('user/autocomplete/a', array('absolute' => TRUE))));
|
||||
|
||||
// Clean up
|
||||
$this->drupalLogout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test role-based switching.
|
||||
*/
|
||||
function _testRoles() {
|
||||
// Enable securepages.
|
||||
$this->web_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'access comments', 'post comments'));
|
||||
|
||||
// Extract the role that was just generated.
|
||||
$role = $this->web_user->roles;
|
||||
unset($role[DRUPAL_AUTHENTICATED_RID]);
|
||||
$role = current(array_keys($role));
|
||||
|
||||
$this->loginHTTPS($this->web_user);
|
||||
$edit = array('securepages_enable' => 1, 'securepages_switch' => 1, "securepages_roles[$role]" => 1);
|
||||
$this->drupalPost('admin/build/securepages', $edit, t('Save configuration'), array('https' => TRUE));
|
||||
$this->assertRaw(t('The configuration options have been saved.'));
|
||||
|
||||
// Visit the home page and /node with HTTPS and confirm that redirection happens.
|
||||
$this->drupalGet('', array('https' => FALSE));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTPS(url('', array('absolute' => TRUE))));
|
||||
$this->drupalGet($this->_toHTTP(url('node')));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl($this->_toHTTPS(url('', array('absolute' => TRUE))));
|
||||
|
||||
// Test that forms actions aren't switched back to http.
|
||||
$node = $this->drupalCreateNode(array('type' => 'story', 'promote' => 1));
|
||||
$this->drupalGet($this->_toHTTPS(url('node/' . $node->nid, array('absolute' => TRUE))));
|
||||
$this->assertFieldByXPath('//form[@id="comment-form" and starts-with(@action, "/")]', NULL, "The comment form action is https.");
|
||||
|
||||
// Clean up
|
||||
variable_del('securepages_switch');
|
||||
variable_del('securepages_roles');
|
||||
$this->drupalLogout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test path normalization checks.
|
||||
*/
|
||||
function _testPathNorms() {
|
||||
variable_set('securepages_switch', TRUE);
|
||||
variable_set('securepages_pages', 'user');
|
||||
|
||||
// Test mixed-case path.
|
||||
$this->drupalGet('UsEr');
|
||||
$this->assertUrl($this->_toHTTPS(url('UsEr', array('absolute' => TRUE))));
|
||||
$this->assertFieldByXPath('//form[@id="user-login" and starts-with(@action, "/")]', NULL, 'The user login form action is https.');
|
||||
|
||||
// Test that a trailing slash will not force a protected form's action to
|
||||
// http.
|
||||
$https_path = $this->_toHTTPS(url('user/', array('absolute' => TRUE)));
|
||||
// A http based 'user/' path will become 'user' when doing the redirect, so
|
||||
// best to ensure that the test gets the right conditions the path should be
|
||||
// https based.
|
||||
$this->drupalGet($https_path);
|
||||
$this->assertUrl($https_path);
|
||||
$this->assertFieldByXPath('//form[@id="user-login" and starts-with(@action, "/")]', NULL, 'The user login form action is https.');
|
||||
|
||||
// Clean up.
|
||||
variable_del('securepages_switch');
|
||||
variable_del('securepages_pages');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in a user using HTTPS.
|
||||
*/
|
||||
function loginHTTPS($user) {
|
||||
$edit = array(
|
||||
'name' => $user->name,
|
||||
'pass' => $user->pass_raw,
|
||||
);
|
||||
$this->drupalPost($this->_toHTTPS(url('user', array('absolute' => TRUE))), $edit, t('Log in'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function, because url() in D6 lacks 'https' => TRUE
|
||||
*/
|
||||
function _toHTTPS($url) {
|
||||
return str_replace('http://', 'https://', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function, because url() in D6 lacks 'https' => FALSE
|
||||
*/
|
||||
function _toHTTP($url) {
|
||||
return str_replace('https://', 'http://', $url);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Simpletests for securepages_prevent_hijack.
|
||||
*/
|
||||
|
||||
class SecurepagesPreventHijackTestCase extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* Implementation of getInfo().
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Securepages Hijack Prevention'),
|
||||
'description' => t('Functional tests for Securepages Hijack Prevention.'),
|
||||
'group' => t('Securepages Hijack Prevention'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of setUp().
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp('securepages', 'securepages_prevent_hijack');
|
||||
variable_set('securepages_enable', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the login forms are using an SSL action.
|
||||
*/
|
||||
function testSecurepagesPreventHijackLoginAction() {
|
||||
// Test that form_alter() is disabled when securepages is off.
|
||||
variable_set('securepages_enable', FALSE);
|
||||
$this->drupalGet('user/login');
|
||||
$this->assertNoPattern('/action="https.*id="user-login"/',
|
||||
t('Make sure login page action is secured.'));
|
||||
|
||||
$this->drupalGet('');
|
||||
$this->assertNoPattern('/action="https.*id="user-login-form"/',
|
||||
t('Make sure login page action is secured.'));
|
||||
|
||||
// Enable securepages and re-test.
|
||||
variable_set('securepages_enable', TRUE);
|
||||
$this->drupalGet('user/login');
|
||||
$this->assertPattern('/action="https.*id="user-login"/',
|
||||
t('Make sure login page action is secured.'));
|
||||
|
||||
$this->drupalGet('');
|
||||
$this->assertPattern('/action="https.*id="user-login-form"/',
|
||||
t('Make sure login page action is secured.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the ability to detect hijacked sessions.
|
||||
*/
|
||||
function testSecurepagesPreventHijackDetection() {
|
||||
$user = $this->drupalCreateUser(array('access content', 'administer nodes'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Check that SSL pages work normally. node/add/* is protected by default in securepages.
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertResponse(200);
|
||||
$this->assertIdentical(strpos($this->getUrl(), 'https'), 0, t('Verify node/add/page is secure.'));
|
||||
|
||||
// Force the private key to regenerate. This is a sneaky hack to invalidate the secure cookie.
|
||||
variable_set('drupal_private_key', 0);
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertResponse(403, t('Make sure hijacked requests are denied.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that secure cookie is re-sent after a password change
|
||||
*/
|
||||
function testSecurepagesPreventHijackPasswordReset() {
|
||||
$user = $this->drupalCreateUser(array('access content', 'administer nodes'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
$url = 'user/'. $user->uid . '/edit';
|
||||
$edit = array(
|
||||
'pass[pass1]' => 'secret',
|
||||
'pass[pass2]' => 'secret',
|
||||
);
|
||||
$this->drupalPost($url, $edit, t('Save'));
|
||||
$this->drupalGet('node/add/page');
|
||||
// @FIXME - this assertion fails because of this bug: http://drupal.org/node/471970
|
||||
// $this->assertResponse(200);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
|
||||
Storm module for Drupal 6.x
|
||||
|
||||
INSTALLATION:
|
||||
|
||||
1) Copy this 'storm' directory into the modules directory of your Drupal installation.
|
||||
(Multisite installations may wish to use a different directory - see http://drupal.org/node/53705)
|
||||
|
||||
2) Enable Storm (and whatever submodules of Storm that you wish), by visiting http://example.com/admin/build/modules. You will (almost) always need 'Storm', 'Storm Attribute' and 'Storm Organization'.
|
||||
|
||||
3) To enable the pdf invoice feature, you must separately install the tcpdf library (http://www.tcpdf.org). The install directory can be set at /admin/settings/storm/invoice. If you do not install the tcpdf library, Storm will still work, but you will not be able to view pdf versions of invoices.
|
||||
|
||||
|
||||
CONFIGURATION:
|
||||
|
||||
- Set up permissions: Initially, it is recommended that you allow full access for your administrative role, and allow more once you are familiar with the system.
|
||||
|
||||
- There are a number of settings forms linked from http://example.com/admin/settings/storm. After installation, you should visit these pages and
|
||||
|
||||
- Storm Attribute: This module gives additional settings for allowed field values, and values you can search for on the lists. In later versions of Storm, this may become part of the standard settings forms.
|
||||
|
||||
|
||||
DISABLING / UNINSTALL:
|
||||
|
||||
1) Visit http://example.com/admin/build/modules in your web-browser and deselect the modules that you wish to disable. To uninstall, select the uninstall tab and follow the on screen instructions.
|
||||
|
||||
2) Warnings may appear on disabling stating that nodes have not been deleted. This is because several of the Storm modules use the existing Drupal node system to store information. Therefore, on disabling the module, these nodes are not deleted. It is suggested that you may wish to delete these manually by visiting http://example.com/admin/content/node and filtering by the stated content type.
|
||||
|
||||
|
||||
HELP:
|
||||
|
||||
- It is understandable that Storm may appear intimidating at first glance due to the number of modules in the package. Do not be afraid!
|
||||
|
||||
- You may find this blog entry useful: http://cocoate.com/2009/06/29/project-management-drupal-and-storm
|
||||
|
||||
- For general support, you can ask questions on the issues queue on Drupal.org: http://drupal.org/project/issues/storm
|
||||
|
||||
|
||||
FEEDBACK:
|
||||
|
||||
- Please feedback on your experiences to make Storm better. This can be done by creating an issue at http://drupal.org/project/issues/storm.
|
||||
|
||||
- Were you just trying Storm?
|
||||
- Did you end up using Storm?
|
||||
- What did you find difficult?
|
||||
- What was the make or break factor for you?
|
||||
|
||||
- Another way to help others is to blog about how your installation went. This will allow you to post screenshots too.
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Tests for the SuiteDesk module
|
||||
*/
|
||||
class StormTestCase extends DrupalWebTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'SuiteDesk functionality',
|
||||
'description' => 'Test the functionality of the SuiteDesk base module',
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('dashboard');
|
||||
}
|
||||
|
||||
public function testStormAccess() {
|
||||
$this->drupalGet('dashboard');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk dashboard for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('dashboard');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk dashboard for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm: access dashboard'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('dashboard');
|
||||
$this->assertText(t('SuiteDesk dashboard'), t('Make sure the correct page has been displayed by checking that the title is "SuiteDesk dashboard".'));
|
||||
}
|
||||
|
||||
public function testStormAccessSettings() {
|
||||
$this->drupalGet('admin/settings/storm');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk settings page for anonymous user'));
|
||||
$this->drupalGet('admin/settings/suitedesk/suitedesk');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk settings page for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('admin/settings/storm');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk settings page for basic user'));
|
||||
$this->drupalGet('admin/settings/suitedesk/suitedesk');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk settings page for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm: access administration pages'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('admin/settings/storm');
|
||||
$this->assertText(t('SuiteDesk'), t('Make sure the correct page has been displayed by checking that the title of the settings page is "SuiteDesk".'));
|
||||
$this->drupalGet('admin/settings/suitedesk/suitedesk');
|
||||
$this->assertText(t('SuiteDesk'), t('Make sure the correct page has been displayed by checking that the title of the settings page is "SuiteDesk".'));
|
||||
}
|
||||
|
||||
public function testStormAttributesAccess() {
|
||||
$this->drupalGet('attributes');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Attributes list for anonymous user'));
|
||||
$this->drupalGet('attributes/add');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Attributes form for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('attributes');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Attributes list for basic user'));
|
||||
$this->drupalGet('attributes/add');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Attributes form for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm: access administration pages'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('attributes');
|
||||
$this->assertText(t('Attributes'), t('Make sure the correct page has been displayed by checking that the title is "Attributes".'));
|
||||
$this->drupalGet('attributes/add');
|
||||
$this->assertText(t('Add a new attribute'), t('Make sure the correct page has been displayed by checking that the title is "Add a new attribute".'));
|
||||
}
|
||||
}
|
|
@ -1,192 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk dok module
|
||||
*/
|
||||
class StormdokTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Dok Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Dok module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormdok', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStormdokAccess() {
|
||||
$this->drupalGet('doks');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Doks list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('doks');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Doks list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm dok: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('doks');
|
||||
$this->assertText(t('Doks'), t('Make sure the correct page has been displayed by checking that the title is "Doks".'));
|
||||
}
|
||||
|
||||
public function testStormdokCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm dok: add', 'Storm dok: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$dok = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
$this->drupalPost('node/add/stormdok', $dok, t('Save'));
|
||||
|
||||
$this->assertText(t('Dok @title has been created.', array('@title' => $dok['title'])));;
|
||||
}
|
||||
|
||||
public function testStormdokList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm dok: access', 'Storm dok: add', 'Storm dok: view all', 'Storm dok: edit all', 'Storm dok: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm dok: access', 'Storm dok: add', 'Storm dok: view of user organization', 'Storm dok: edit of user organization', 'Storm dok: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm dok: access', 'Storm dok: add', 'Storm dok: view own', 'Storm dok: edit own', 'Storm dok: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm dok: access', 'Storm dok: add', 'Storm dok: view all', 'Storm dok: edit own', 'Storm dok: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create doks
|
||||
$dok1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormdok', $dok1, t('Save'));
|
||||
$dok1 = node_load(array('title' => $dok1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$dok2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormdok', $dok2, t('Save'));
|
||||
$dok2 = node_load(array('title' => $dok2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$dok3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormdok', $dok3, t('Save'));
|
||||
$dok3 = node_load(array('title' => $dok3['title']));
|
||||
|
||||
// Test for 'Storm dok: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('doks');
|
||||
|
||||
$this->assertLink($dok1->title, 0, 'The Dok appears on the list');
|
||||
$this->assertRaw('node/'. $dok1->nid .'/edit', 'The Dok edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $dok1->nid .'/delete', 'The Dok delete icon appears on the list');
|
||||
|
||||
$this->assertLink($dok2->title, 0, 'The Dok appears on the list');
|
||||
$this->assertRaw('node/'. $dok2->nid .'/edit', 'The Dok edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $dok2->nid .'/delete', 'The Dok delete icon appears on the list');
|
||||
|
||||
$this->assertLink($dok3->title, 0, 'The Dok appears on the list');
|
||||
$this->assertRaw('node/'. $dok3->nid .'/edit', 'The Dok edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $dok3->nid .'/delete', 'The Dok delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm dok: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('doks');
|
||||
|
||||
$this->assertLink($dok1->title, 0, 'The Dok appears on the list');
|
||||
$this->assertRaw('node/'. $dok1->nid .'/edit', 'The Dok edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $dok1->nid .'/delete', 'The Dok delete icon appears on the list');
|
||||
|
||||
$this->assertLink($dok2->title, 0, 'The Dok appears on the list');
|
||||
$this->assertRaw('node/'. $dok2->nid .'/edit', 'The Dok edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $dok2->nid .'/delete', 'The Dok delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($dok3->title, 'The Dok does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $dok3->nid .'/edit', 'The Dok edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $dok3->nid .'/delete', 'The Dok delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm dok: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('doks');
|
||||
|
||||
$this->assertNoLink($dok1->title, 'The Dok does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $dok1->nid .'/edit', 'The Dok edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $dok1->nid .'/delete', 'The Dok delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($dok2->title, 0, 'The Dok appears on the list');
|
||||
$this->assertRaw('node/'. $dok2->nid .'/edit', 'The Dok edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $dok2->nid .'/delete', 'The Dok delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($dok3->title, 'The Dok does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $dok3->nid .'/edit', 'The Dok edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $dok3->nid .'/delete', 'The Dok delete icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm dok: view all', 'Storm dok: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('doks');
|
||||
|
||||
$this->assertLink($dok1->title, 0, 'The Dok appears on the list');
|
||||
$this->assertNoRaw('node/'. $dok1->nid .'/edit', 'The Dok edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $dok1->nid .'/delete', 'The Dok edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($dok2->title, 0, 'The Dok appears on the list');
|
||||
$this->assertNoRaw('node/'. $dok2->nid .'/edit', 'The Dok edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $dok2->nid .'/delete', 'The Dok delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($dok3->title, 0, 'The Dok appears on the list');
|
||||
$this->assertRaw('node/'. $dok3->nid .'/edit', 'The Dok edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $dok3->nid .'/delete', 'The Dok delete icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
|
@ -1,192 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk event module
|
||||
*/
|
||||
class StormeventTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk event Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk event module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormevent', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStormeventAccess() {
|
||||
$this->drupalGet('events');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk events list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('events');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk events list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm event: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('events');
|
||||
$this->assertText(t('events'), t('Make sure the correct page has been displayed by checking that the title is "events".'));
|
||||
}
|
||||
|
||||
public function testStormeventCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm event: add', 'Storm event: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$event = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
$this->drupalPost('node/add/stormevent', $event, t('Save'));
|
||||
|
||||
$this->assertText(t('event @title has been created.', array('@title' => $event['title'])));;
|
||||
}
|
||||
|
||||
public function testStormeventList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm event: access', 'Storm event: add', 'Storm event: view all', 'Storm event: edit all', 'Storm event: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm event: access', 'Storm event: add', 'Storm event: view of user organization', 'Storm event: edit of user organization', 'Storm event: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm event: access', 'Storm event: add', 'Storm event: view own', 'Storm event: edit own', 'Storm event: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm event: access', 'Storm event: add', 'Storm event: view all', 'Storm event: edit own', 'Storm event: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create events
|
||||
$event1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormevent', $event1, t('Save'));
|
||||
$event1 = node_load(array('title' => $event1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$event2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormevent', $event2, t('Save'));
|
||||
$event2 = node_load(array('title' => $event2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$event3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormevent', $event3, t('Save'));
|
||||
$event3 = node_load(array('title' => $event3['title']));
|
||||
|
||||
// Test for 'Storm event: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('events');
|
||||
|
||||
$this->assertLink($event1->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event1->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event1->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertLink($event2->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertLink($event3->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event3->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event3->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm event: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('events');
|
||||
|
||||
$this->assertLink($event1->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event1->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event1->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertLink($event2->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($event3->title, 'The event does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event3->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event3->nid .'/delete', 'The event delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm event: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('events');
|
||||
|
||||
$this->assertNoLink($event1->title, 'The event does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event1->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event1->nid .'/delete', 'The event delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($event2->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event2->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($event3->title, 'The event does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event3->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event3->nid .'/delete', 'The event delete icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm event: view all', 'Storm event: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('events');
|
||||
|
||||
$this->assertLink($event1->title, 0, 'The event appears on the list');
|
||||
$this->assertNoRaw('node/'. $event1->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event1->nid .'/delete', 'The event edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($event2->title, 0, 'The event appears on the list');
|
||||
$this->assertNoRaw('node/'. $event2->nid .'/edit', 'The event edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $event2->nid .'/delete', 'The event delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($event3->title, 0, 'The event appears on the list');
|
||||
$this->assertRaw('node/'. $event3->nid .'/edit', 'The event edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $event3->nid .'/delete', 'The event delete icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk expense module
|
||||
*/
|
||||
class StormexpenseTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Expense Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Expense module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormticket', 'stormexpense', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStormexpenseAccess() {
|
||||
$this->drupalGet('expenses');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Expense list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('expenses');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Expense list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm expense: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('expenses');
|
||||
$this->assertText(t('Expenses'), t('Make sure the correct page has been displayed by checking that the title is "Expenses".'));
|
||||
}
|
||||
|
||||
public function testStormexpenseCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm expense: add', 'Storm expense: view all', 'Storm project: view all', 'Storm task: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create a team
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
);
|
||||
|
||||
$expense = array(
|
||||
'organization_nid' => '1',
|
||||
'title' => $this->randomName(32),
|
||||
);
|
||||
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
|
||||
$this->drupalPost('node/add/stormexpense', $expense, t('Save'));
|
||||
|
||||
$this->assertText(t('Expense @title has been created.', array('@title' => $expense['title'])));
|
||||
}
|
||||
|
||||
public function testStormexpenseReports() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm expense: access'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create a team
|
||||
$this->drupalGet('expenses/report/std/en');
|
||||
}
|
||||
|
||||
public function testStormexpenseList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm expense: access', 'Storm expense: add', 'Storm expense: view all', 'Storm expense: edit all', 'Storm expense: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm expense: access', 'Storm expense: add', 'Storm expense: view of user organization', 'Storm expense: edit of user organization', 'Storm expense: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm expense: access', 'Storm expense: add', 'Storm expense: view own', 'Storm expense: edit own', 'Storm expense: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm expense: access', 'Storm expense: add', 'Storm expense: view all', 'Storm expense: edit own', 'Storm expense: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create expenses
|
||||
$exp1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
);
|
||||
$this->drupalPost('node/add/stormexpense', $exp1, t('Save'));
|
||||
$exp1 = node_load(array('title' => $exp1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$exp2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormexpense', $exp2, t('Save'));
|
||||
$exp2 = node_load(array('title' => $exp2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$exp3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormexpense', $exp3, t('Save'));
|
||||
$exp3 = node_load(array('title' => $exp3['title']));
|
||||
|
||||
// Test for 'Storm expense: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('expenses');
|
||||
|
||||
$this->assertLink($exp1->title, 0, 'The Expense appears on the list');
|
||||
$this->assertRaw('node/'. $exp1->nid .'/edit', 'The Expense edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $exp1->nid .'/delete', 'The Expense edit icon appears on the list');
|
||||
|
||||
$this->assertLink($exp2->title, 0, 'The Expense appears on the list');
|
||||
$this->assertRaw('node/'. $exp2->nid .'/edit', 'The Expense edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $exp2->nid .'/delete', 'The Expense edit icon appears on the list');
|
||||
|
||||
$this->assertLink($exp3->title, 0, 'The Expense appears on the list');
|
||||
$this->assertRaw('node/'. $exp3->nid .'/edit', 'The Expense edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $exp3->nid .'/delete', 'The Expense edit icon appears on the list');
|
||||
|
||||
// Test for 'Storm expense: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('expenses');
|
||||
|
||||
$this->assertLink($exp1->title, 0, 'The Expense appears on the list');
|
||||
$this->assertRaw('node/'. $exp1->nid .'/edit', 'The Expense edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $exp1->nid .'/delete', 'The Expense edit icon appears on the list');
|
||||
|
||||
$this->assertLink($exp2->title, 0, 'The Expense appears on the list');
|
||||
$this->assertRaw('node/'. $exp2->nid .'/edit', 'The Expense edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $exp2->nid .'/delete', 'The Expense edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($exp3->title, 'The Expense does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $exp3->nid .'/edit', 'The Expense edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $exp3->nid .'/delete', 'The Expense edit icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm expense: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('expenses');
|
||||
|
||||
$this->assertNoLink($exp1->title, 'The Expense does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $exp1->nid .'/edit', 'The Expense edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $exp1->nid .'/delete', 'The Expense edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($exp2->title, 0, 'The Expense appears on the list');
|
||||
$this->assertRaw('node/'. $exp2->nid .'/edit', 'The Expense edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $exp2->nid .'/delete', 'The Expense edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($exp3->title, 'The Expense does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $exp3->nid .'/edit', 'The Expense edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $exp3->nid .'/delete', 'The Expense edit icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm expense: view all', 'Storm expense: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('expenses');
|
||||
|
||||
$this->assertLink($exp1->title, 0, 'The Expense appears on the list');
|
||||
$this->assertNoRaw('node/'. $exp1->nid .'/edit', 'The Expense edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $exp1->nid .'/delete', 'The Expense edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($exp2->title, 0, 'The Expense appears on the list');
|
||||
$this->assertNoRaw('node/'. $exp2->nid .'/edit', 'The Expense edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $exp2->nid .'/delete', 'The Expense edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($exp3->title, 0, 'The Expense appears on the list');
|
||||
$this->assertRaw('node/'. $exp3->nid .'/edit', 'The Expense edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $exp3->nid .'/delete', 'The Expense edit icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,225 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Invoice module.
|
||||
*/
|
||||
class StorminvoiceTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Invoice Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Invoice module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'storminvoice', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStorminvoiceAccess() {
|
||||
$this->drupalGet('invoices');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Invoices list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('invoices');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Invoices list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm invoice: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('invoices');
|
||||
$this->assertText(t('Invoices'), t('Make sure the correct page has been displayed by checking that the title is "Invoices".'));
|
||||
}
|
||||
|
||||
public function testStorminvoiceCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm invoice: add', 'Storm invoice: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$inv = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
'items_0_description' => $this->randomName(32),
|
||||
'items_0_amount' => '.28',
|
||||
'items_0_tax1app' => '1',
|
||||
'items_0_tax1percent' => '5',
|
||||
'items_0_tax2app' => '2',
|
||||
'items_0_tax2percent' => '7.5',
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/storminvoice', $inv, t('Save'));
|
||||
|
||||
$this->assertText(t('Invoice @title has been created.', array('@title' => $inv['title'])));
|
||||
}
|
||||
|
||||
public function testStorminvoiceList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm invoice: access', 'Storm invoice: add', 'Storm invoice: view all', 'Storm invoice: edit all', 'Storm invoice: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm invoice: access', 'Storm invoice: add', 'Storm invoice: view of user organization', 'Storm invoice: edit of user organization', 'Storm invoice: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm invoice: access', 'Storm invoice: add', 'Storm invoice: view own', 'Storm invoice: edit own', 'Storm invoice: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm invoice: access', 'Storm invoice: add', 'Storm invoice: view all', 'Storm invoice: edit own', 'Storm invoice: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create invoices
|
||||
$inv1 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
'items_0_description' => $this->randomName(32),
|
||||
'items_0_amount' => '100.0',
|
||||
'items_0_tax1app' => '1',
|
||||
'items_0_tax1percent' => '20',
|
||||
'items_0_tax2app' => '2',
|
||||
'items_0_tax2percent' => '10',
|
||||
);
|
||||
// tax1: 20; tax2: 12; total: 132
|
||||
$this->drupalPost('node/add/storminvoice', $inv1, t('Save'));
|
||||
$inv1 = node_load(array('title' => $inv1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$inv2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
'items_0_description' => $this->randomName(32),
|
||||
'items_0_amount' => '200',
|
||||
'items_0_tax1app' => '1',
|
||||
'items_0_tax1percent' => '20',
|
||||
'items_0_tax2app' => '0',
|
||||
'items_0_tax2percent' => '10',
|
||||
);
|
||||
// tax1: 40; tax2: 0; total: 240
|
||||
$this->drupalPost('node/add/storminvoice', $inv2, t('Save'));
|
||||
$inv2 = node_load(array('title' => $inv2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$inv3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org2->nid,
|
||||
'items_0_description' => $this->randomName(32),
|
||||
'items_0_amount' => '42,42',
|
||||
'items_0_tax1app' => '0',
|
||||
'items_0_tax1percent' => '5',
|
||||
'items_0_tax2app' => '0',
|
||||
'items_0_tax2percent' => '7.5',
|
||||
);
|
||||
// tax1: 0, tax2: 0; total: 42.42
|
||||
$this->drupalPost('node/add/storminvoice', $inv3, t('Save'));
|
||||
$inv3 = node_load(array('title' => $inv3['title']));
|
||||
|
||||
// Test for 'Storm invoice: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('invoices');
|
||||
|
||||
$this->assertLink($inv1->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertRaw('node/'. $inv1->nid .'/edit', 'The Invoice edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $inv1->nid .'/delete', 'The Invoice edit icon appears on the list');
|
||||
|
||||
$this->assertLink($inv2->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertRaw('node/'. $inv2->nid .'/edit', 'The Invoice edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $inv2->nid .'/delete', 'The Invoice edit icon appears on the list');
|
||||
|
||||
$this->assertLink($inv3->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertRaw('node/'. $inv3->nid .'/edit', 'The Invoice edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $inv3->nid .'/delete', 'The Invoice edit icon appears on the list');
|
||||
|
||||
$this->assertRaw('342.42', 'Total amount is correct.');
|
||||
$this->assertRaw('60.00', 'Total Tax1 is correct.');
|
||||
$this->assertRaw('12.00', 'Total Tax2 is correct.');
|
||||
$this->assertRaw('414.42', 'Total sum correct.');
|
||||
|
||||
// Test for 'Storm invoice: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('invoices');
|
||||
|
||||
$this->assertLink($inv1->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertRaw('node/'. $inv1->nid .'/edit', 'The Invoice edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $inv1->nid .'/delete', 'The Invoice edit icon appears on the list');
|
||||
|
||||
$this->assertLink($inv2->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertRaw('node/'. $inv2->nid .'/edit', 'The Invoice edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $inv2->nid .'/delete', 'The Invoice edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($inv3->title, 'The Invoice does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $inv3->nid .'/edit', 'The Invoice edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $inv3->nid .'/delete', 'The Invoice edit icon does not appear on the list');
|
||||
|
||||
$this->assertRaw('300.00', 'Total amount is correct.');
|
||||
$this->assertRaw('60.00', 'Total Tax1 is correct.');
|
||||
$this->assertRaw('12.00', 'Total Tax2 is correct.');
|
||||
$this->assertRaw('372.00', 'Total sum correct.');
|
||||
|
||||
// Test for 'Storm invoice: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('invoices');
|
||||
|
||||
$this->assertNoLink($inv1->title, 'The Invoice does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $inv1->nid .'/edit', 'The Invoice edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $inv1->nid .'/delete', 'The Invoice edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($inv2->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertRaw('node/'. $inv2->nid .'/edit', 'The Invoice edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $inv2->nid .'/delete', 'The Invoice edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($inv3->title, 'The Invoice does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $inv3->nid .'/edit', 'The Invoice edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $inv3->nid .'/delete', 'The Invoice edit icon does not appear on the list');
|
||||
|
||||
$this->assertRaw('200.00', 'Total amount is correct.');
|
||||
$this->assertRaw('40.00', 'Total Tax1 is correct.');
|
||||
$this->assertRaw('0.00', 'Total Tax2 is correct.');
|
||||
$this->assertRaw('240.00', 'Total sum correct.');
|
||||
|
||||
// Test for 'Storm invoice: view all', 'Storm invoice: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('invoices');
|
||||
|
||||
$this->assertLink($inv1->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertNoRaw('node/'. $inv1->nid .'/edit', 'The Invoice edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $inv1->nid .'/delete', 'The Invoice edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($inv2->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertNoRaw('node/'. $inv2->nid .'/edit', 'The Invoice edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $inv2->nid .'/delete', 'The Invoice edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($inv3->title, 0, 'The Invoice appears on the list');
|
||||
$this->assertRaw('node/'. $inv3->nid .'/edit', 'The Invoice edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $inv3->nid .'/delete', 'The Invoice edit icon appears on the list');
|
||||
|
||||
$this->assertRaw('342.42', 'Total amount is correct.');
|
||||
$this->assertRaw('60.00', 'Total Tax1 is correct.');
|
||||
$this->assertRaw('12.00', 'Total Tax2 is correct.');
|
||||
$this->assertRaw('414.42', 'Total sum correct.');
|
||||
|
||||
}
|
||||
}
|
|
@ -1,192 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk note module
|
||||
*/
|
||||
class StormnoteTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Note Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Note module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormnote', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStormnoteAccess() {
|
||||
$this->drupalGet('notes');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Notes list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('notes');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Notes list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm note: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('notes');
|
||||
$this->assertText(t('Notes'), t('Make sure the correct page has been displayed by checking that the title is "Notes".'));
|
||||
}
|
||||
|
||||
public function testStormnoteCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm note: add', 'Storm note: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$note = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
$this->drupalPost('node/add/stormnote', $note, t('Save'));
|
||||
|
||||
$this->assertText(t('Note @title has been created.', array('@title' => $note['title'])));;
|
||||
}
|
||||
|
||||
public function testStormnoteList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm note: access', 'Storm note: add', 'Storm note: view all', 'Storm note: edit all', 'Storm note: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm note: access', 'Storm note: add', 'Storm note: view of user organization', 'Storm note: edit of user organization', 'Storm note: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm note: access', 'Storm note: add', 'Storm note: view own', 'Storm note: edit own', 'Storm note: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm note: access', 'Storm note: add', 'Storm note: view all', 'Storm note: edit own', 'Storm note: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create notes
|
||||
$note1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormnote', $note1, t('Save'));
|
||||
$note1 = node_load(array('title' => $note1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$note2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormnote', $note2, t('Save'));
|
||||
$note2 = node_load(array('title' => $note2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$note3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormnote', $note3, t('Save'));
|
||||
$note3 = node_load(array('title' => $note3['title']));
|
||||
|
||||
// Test for 'Storm note: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('notes');
|
||||
|
||||
$this->assertLink($note1->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note1->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note1->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertLink($note2->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertLink($note3->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note3->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note3->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm note: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('notes');
|
||||
|
||||
$this->assertLink($note1->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note1->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note1->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertLink($note2->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($note3->title, 'The Note does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note3->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note3->nid .'/delete', 'The Note delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm note: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('notes');
|
||||
|
||||
$this->assertNoLink($note1->title, 'The Note does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note1->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note1->nid .'/delete', 'The Note delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($note2->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note2->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($note3->title, 'The Note does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note3->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note3->nid .'/delete', 'The Note delete icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm note: view all', 'Storm note: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('notes');
|
||||
|
||||
$this->assertLink($note1->title, 0, 'The Note appears on the list');
|
||||
$this->assertNoRaw('node/'. $note1->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note1->nid .'/delete', 'The Note edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($note2->title, 0, 'The Note appears on the list');
|
||||
$this->assertNoRaw('node/'. $note2->nid .'/edit', 'The Note edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $note2->nid .'/delete', 'The Note delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($note3->title, 0, 'The Note appears on the list');
|
||||
$this->assertRaw('node/'. $note3->nid .'/edit', 'The Note edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $note3->nid .'/delete', 'The Note delete icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk organization module
|
||||
*/
|
||||
class StormorganizationTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'SuiteDesk Organization functionality',
|
||||
'description' => 'Test the functionality of the SuiteDesk Organization module',
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormperson');
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm organization: add'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
}
|
||||
|
||||
public function testStormorganizationAccess() {
|
||||
$this->drupalGet('organizations');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Organizations list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('organizations');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Organizations list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm organization: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('organizations');
|
||||
$this->assertText(t('Organizations'), t('Make sure the correct page has been displayed by checking that the title is "Organizations".'));
|
||||
}
|
||||
|
||||
public function testStormorganizationCreate() {
|
||||
$edit = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $edit, t('Save'));
|
||||
$this->assertText(t('Organization @title has been created.', array('@title' => $edit['title'])));
|
||||
}
|
||||
|
||||
public function testStormorganizationList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: access', 'Storm organization: view all', 'Storm organization: edit all', 'Storm organization: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: access', 'Storm organization: view belonged', 'Storm organization: edit belonged'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: access', 'Storm organization: view own', 'Storm organization: edit own', 'Storm organization: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: access', 'Storm organization: view all', 'Storm organization: edit own', 'Storm organization: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$organization1 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $organization1, t('Save'));
|
||||
$organization1 = node_load(array('title' => $organization1['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $organization1->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create organization
|
||||
$this->drupalLogin($userOwn);
|
||||
$organization2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $organization2, t('Save'));
|
||||
$organization2 = node_load(array('title' => $organization2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$organization3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $organization3, t('Save'));
|
||||
$organization3 = node_load(array('title' => $organization3['title']));
|
||||
|
||||
// Test for 'Storm organization: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('organizations');
|
||||
|
||||
$this->assertLink($organization1->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization1->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization1->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
$this->assertLink($organization2->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization2->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization2->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
$this->assertLink($organization3->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization3->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization3->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
// Test for 'Storm organization: view belonged'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('organizations');
|
||||
|
||||
$this->assertLink($organization1->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization1->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($organization2->title, 'The Organization appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization2->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization2->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($organization3->title, 'The Organization does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization3->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization3->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm organization: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('organizations');
|
||||
|
||||
$this->assertNoLink($organization1->title, 'The Organization does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($organization2->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization2->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization2->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($organization3->title, 'The Organization does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization3->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization3->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm organization: view all', 'Storm organization: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('organizations');
|
||||
|
||||
$this->assertLink($organization1->title, 0, 'The Organization appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($organization2->title, 0, 'The Organization appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization2->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization2->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($organization3->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization3->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization3->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,224 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Person module.
|
||||
*/
|
||||
class StormpersonTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'SuiteDesk Person functionality',
|
||||
'description' => 'Test the functionality of the SuiteDesk Person module',
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormperson');
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: add'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
}
|
||||
|
||||
public function testStormpersonAccess() {
|
||||
$this->drupalGet('people');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk People list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('people');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk People list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm person: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('people');
|
||||
$this->assertText(t('People'), t('Make sure the correct page has been displayed by checking that the title is "People".'));
|
||||
}
|
||||
|
||||
public function testStormpersonCreate() {
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$person = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormperson', $person, t('Save'));
|
||||
$this->assertText(t('Person @title has been created.', array('@title' => $person['title'])));
|
||||
}
|
||||
|
||||
public function testStormpersonList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view all', 'Storm person: edit all', 'Storm person: delete all'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view of user organization', 'Storm person: edit of user organization', 'Storm person: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view own', 'Storm person: edit own', 'Storm person: delete own'));
|
||||
$userLinked = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view when linked to own user account', 'Storm person: edit when linked to own user account', 'Storm person: delete when linked to own user account'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view all', 'Storm person: edit own', 'Storm person: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create persons
|
||||
$person1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person1, t('Save'));
|
||||
$person1 = node_load(array('title' => $person1['title']));
|
||||
|
||||
$person4 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'user_name' => $userLinked->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person4, t('Save'));
|
||||
$person4 = node_load(array('title' => $person4['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$person2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person2, t('Save'));
|
||||
$person2 = node_load(array('title' => $person2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$person3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person3, t('Save'));
|
||||
$person3 = node_load(array('title' => $person3['title']));
|
||||
|
||||
// Test for 'Storm person: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertLink($person1->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person1->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person1->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person2->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person3->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person3->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person3->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person4->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
// Test for 'Storm person: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertLink($person1->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person1->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person1->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person2->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($person3->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person4->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
// Test for 'Storm person: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertNoLink($person1->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person2->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($person3->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($person4->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person4->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person4->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm person: view all', 'Storm invoice: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertLink($person1->title, 0, 'The Person appears on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person2->title, 0, 'The Person appears on the list');
|
||||
$this->assertNoRaw('node/'. $person2->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person2->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person3->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person3->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person3->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person4->title, 0, 'The Person appears on the list');
|
||||
$this->assertNoRaw('node/'. $person4->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person4->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm person: view when linked to own user account'
|
||||
$this->drupalLogin($userLinked);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertNoLink($person1->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($person2->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person2->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person2->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($person3->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person4->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
}
|
||||
}
|
|
@ -1,376 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Project module
|
||||
*/
|
||||
class StormprojectTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Project Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Project module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormperson', 'stormteam');
|
||||
}
|
||||
|
||||
public function testStormprojectAccess() {
|
||||
$this->drupalGet('projects');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Projects list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('projects');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Projects list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm project: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('projects');
|
||||
$this->assertText(t('Projects'), t('Make sure the correct page has been displayed by checking that the title is "Projects".'));
|
||||
}
|
||||
|
||||
public function testStormprojectCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
|
||||
$this->assertText(t('Project @title has been created.', array('@title' => $prj['title'])));;
|
||||
}
|
||||
|
||||
public function testStormprojectList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: access', 'Storm project: add', 'Storm project: view all', 'Storm project: edit all', 'Storm project: delete all', 'Storm person: add', 'Storm team: add', 'Storm person: view all', 'Storm team: view all'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: access', 'Storm project: add', 'Storm project: view of user organization', 'Storm project: edit of user organization', 'Storm project: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: access', 'Storm project: add', 'Storm project: view own', 'Storm project: edit own', 'Storm project: delete own'));
|
||||
$userManager = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: access', 'Storm project: add', 'Storm project: view if project manager', 'Storm project: edit if project manager', 'Storm project: delete if project manager'));
|
||||
$userAssigned = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: access', 'Storm project: add', 'Storm project: view if assigned to project', 'Storm project: edit if assigned to project', 'Storm project: delete if assigned to project'));
|
||||
$userAssignedTeam = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: access', 'Storm project: add', 'Storm project: view if assigned to project', 'Storm project: edit if assigned to project', 'Storm project: delete if assigned to project'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: access', 'Storm project: add', 'Storm project: view all', 'Storm project: edit own', 'Storm project: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userManager->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$manager = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userAssigned->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$assignedPerson = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userAssignedTeam->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$assignedPersonTeam = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$team = array(
|
||||
'title' => $this->randomName(32),
|
||||
'members_array_1' => $assignedPersonTeam->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormteam', $team, t('Save'));
|
||||
$team = node_load(array('title' => $team['title']));
|
||||
|
||||
// Create project
|
||||
$project1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $project1, t('Save'));
|
||||
$project1 = node_load(array('title' => $project1['title']));
|
||||
|
||||
$projectManager = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'manager_nid' => $manager->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $projectManager, t('Save'));
|
||||
$projectManager = node_load(array('title' => $projectManager['title']));
|
||||
|
||||
$projectAssigned = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'assigned_nid' => $assignedPerson->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $projectAssigned, t('Save'));
|
||||
$projectAssigned = node_load(array('title' => $projectAssigned['title']));
|
||||
|
||||
$projectAssignedTeam = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $projectAssignedTeam, t('Save'));
|
||||
$projectAssignedTeam = node_load(array('title' => $projectAssignedTeam['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$project2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $project2, t('Save'));
|
||||
$project2 = node_load(array('title' => $project2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$project3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $project3, t('Save'));
|
||||
$project3 = node_load(array('title' => $project3['title']));
|
||||
|
||||
// Test for 'Storm project: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('projects');
|
||||
|
||||
$this->assertLink($project1->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $project1->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $project1->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($project2->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $project2->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $project2->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($project3->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $project3->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $project3->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($projectManager->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectManager->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectManager->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($projectAssigned->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssigned->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssigned->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($projectAssignedTeam->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssignedTeam->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssignedTeam->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm project: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('projects');
|
||||
|
||||
$this->assertLink($project1->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $project1->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $project1->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($project2->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $project2->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $project2->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($project3->title, 0, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($projectManager->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectManager->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectManager->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($projectAssigned->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssigned->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssigned->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($projectAssignedTeam->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssignedTeam->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssignedTeam->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm project: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('projects');
|
||||
|
||||
$this->assertNoLink($project1->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($project2->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $project2->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $project2->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($project3->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($projectManager->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectManager->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectManager->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($projectAssigned->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssigned->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssigned->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($projectAssignedTeam->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssignedTeam->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssignedTeam->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm project: view all', 'Storm project: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('projects');
|
||||
|
||||
$this->assertLink($project1->title, 0, 'The Project appears on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($project2->title, 0, 'The Project appears on the list');
|
||||
$this->assertNoRaw('node/'. $project2->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project2->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($project3->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $project3->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $project3->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertLink($projectManager->title, 0, 'The Project appears on the list');
|
||||
$this->assertNoRaw('node/'. $projectManager->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectManager->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($projectAssigned->title, 0, 'The Project appears on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssigned->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssigned->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($projectAssignedTeam->title, 0, 'The Project appears on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssignedTeam->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssignedTeam->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm project: view if project manager'
|
||||
$this->drupalLogin($userManager);
|
||||
$this->drupalGet('projects');
|
||||
|
||||
$this->assertNoLink($project1->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($project2->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project2->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project2->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($project3->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($projectManager->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectManager->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectManager->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($projectAssigned->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssigned->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssigned->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($projectAssignedTeam->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssignedTeam->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssignedTeam->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm project: view if assigned to project'
|
||||
$this->drupalLogin($userAssigned);
|
||||
$this->drupalGet('projects');
|
||||
|
||||
$this->assertNoLink($project1->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($project2->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project2->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project2->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($project3->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($projectManager->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectManager->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectManager->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($projectAssigned->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssigned->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssigned->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($projectAssignedTeam->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssignedTeam->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssignedTeam->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm project: view if assigned to project' (using team)
|
||||
$this->drupalLogin($userAssignedTeam);
|
||||
$this->drupalGet('projects');
|
||||
|
||||
$this->assertNoLink($project1->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project1->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($project2->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project2->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project2->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($project3->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $project3->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($projectManager->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectManager->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectManager->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($projectAssigned->title, 'The Project does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssigned->nid .'/edit', 'The Project edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $projectAssigned->nid .'/delete', 'The Project delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($projectAssignedTeam->title, 0, 'The Project appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssignedTeam->nid .'/edit', 'The Project edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $projectAssignedTeam->nid .'/delete', 'The Project delete icon appears on the list');
|
||||
}
|
||||
}
|
|
@ -1,338 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Task module
|
||||
*/
|
||||
class StormtaskTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Task Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Task module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormperson', 'stormteam');
|
||||
}
|
||||
|
||||
public function testStormtaskAccess() {
|
||||
$this->drupalGet('tasks');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Tasks list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('tasks');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Tasks list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm task: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('tasks');
|
||||
$this->assertText(t('Tasks'), t('Make sure the correct page has been displayed by checking that the title is "Tasks".'));
|
||||
}
|
||||
|
||||
public function testStormtaskCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
|
||||
$this->assertText(t('Task @title has been created.', array('@title' => $task['title'])));;
|
||||
}
|
||||
|
||||
public function testStormtaskList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm task: access', 'Storm task: add', 'Storm task: view all', 'Storm task: edit all', 'Storm task: delete all', 'Storm person: add', 'Storm team: add', 'Storm person: view all', 'Storm team: view all', 'Storm project: add', 'Storm project: view all'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm task: access', 'Storm task: add', 'Storm task: view of user organization', 'Storm task: edit of user organization', 'Storm task: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm task: access', 'Storm task: add', 'Storm task: view own', 'Storm task: edit own', 'Storm task: delete own', 'Storm project: view all'));
|
||||
$userAssigned = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm task: access', 'Storm task: add', 'Storm task: view if assigned to task', 'Storm task: edit if assigned to task', 'Storm task: delete if assigned to task'));
|
||||
$userAssignedTeam = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm task: access', 'Storm task: add', 'Storm task: view if assigned to task', 'Storm task: edit if assigned to task', 'Storm task: delete if assigned to task'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm task: access', 'Storm task: add', 'Storm task: view all', 'Storm task: edit own', 'Storm task: delete own', 'Storm project: view all'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userAssigned->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$assignedPerson = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userAssignedTeam->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$assignedPersonTeam = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$team = array(
|
||||
'title' => $this->randomName(32),
|
||||
'members_array_1' => $assignedPersonTeam->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormteam', $team, t('Save'));
|
||||
$team = node_load(array('title' => $team['title']));
|
||||
|
||||
// Create project foreach organization
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectOrg = node_load(array('title' => $prj['title']));
|
||||
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectTeam = node_load(array('title' => $prj['title']));
|
||||
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org2->nid,
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectOrg2 = node_load(array('title' => $prj['title']));
|
||||
|
||||
// Create tasks
|
||||
$task1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormtask', $task1, t('Save'), array('query' => 'organization_nid='.$org->nid));
|
||||
$task1 = node_load(array('title' => $task1['title']));
|
||||
|
||||
$taskAssigned = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'assigned_nid' => $assignedPerson->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormtask', $taskAssigned, t('Save'), array('query' => 'organization_nid='.$org->nid.'&project_nid='.$projectOrg->nid));
|
||||
$taskAssigned = node_load(array('title' => $taskAssigned['title']));
|
||||
|
||||
$taskAssignedTeam = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectTeam->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormtask', $taskAssignedTeam, t('Save'), array('query' => 'organization_nid='.$org->nid.'&project_nid='.$projectTeam->nid));
|
||||
$taskAssignedTeam = node_load(array('title' => $taskAssignedTeam['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$task2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormtask', $task2, t('Save'), array('query' => 'organization_nid='.$org->nid));
|
||||
$task2 = node_load(array('title' => $task2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$task3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
'project_nid' => $projectOrg2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormtask', $task3, t('Save'), array('query' => 'organization_nid='.$org2->nid));
|
||||
$task3 = node_load(array('title' => $task3['title']));
|
||||
|
||||
// Test for 'Storm task: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('tasks');
|
||||
|
||||
$this->assertLink($task1->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $task1->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $task1->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertLink($task2->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $task2->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $task2->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertLink($task3->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $task3->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $task3->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertLink($taskAssigned->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssigned->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssigned->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertLink($taskAssignedTeam->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssignedTeam->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssignedTeam->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm task: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('tasks');
|
||||
|
||||
$this->assertLink($task1->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $task1->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $task1->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertLink($task2->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $task2->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $task2->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($task3->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task3->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task3->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($taskAssigned->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssigned->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssigned->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertLink($taskAssignedTeam->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssignedTeam->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssignedTeam->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm task: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('tasks');
|
||||
|
||||
$this->assertNoLink($task1->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task1->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task1->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($task2->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $task2->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $task2->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($task3->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task3->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task3->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($taskAssigned->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssigned->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssigned->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($taskAssignedTeam->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssignedTeam->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssignedTeam->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm task: view all', 'Storm task: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('tasks');
|
||||
|
||||
$this->assertLink($task1->title, 0, 'The Task appears on the list');
|
||||
$this->assertNoRaw('node/'. $task1->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task1->nid .'/delete', 'The Task edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($task2->title, 0, 'The Task appears on the list');
|
||||
$this->assertNoRaw('node/'. $task2->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task2->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($task3->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $task3->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $task3->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertLink($taskAssigned->title, 0, 'The Task appears on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssigned->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssigned->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($taskAssignedTeam->title, 0, 'The Task appears on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssignedTeam->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssignedTeam->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm task: view if assigned to task'
|
||||
$this->drupalLogin($userAssigned);
|
||||
$this->drupalGet('tasks');
|
||||
|
||||
$this->assertNoLink($task1->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task1->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task1->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($task2->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task2->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task2->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($task3->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task3->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task3->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($taskAssigned->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssigned->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssigned->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($taskAssignedTeam->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssignedTeam->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssignedTeam->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm task: view if assigned to task' (using team)
|
||||
$this->drupalLogin($userAssignedTeam);
|
||||
$this->drupalGet('tasks');
|
||||
|
||||
$this->assertNoLink($task1->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task1->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task1->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($task2->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task2->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task2->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($task3->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task3->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $task3->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($taskAssigned->title, 'The Task does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssigned->nid .'/edit', 'The Task edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $taskAssigned->nid .'/delete', 'The Task delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($taskAssignedTeam->title, 0, 'The Task appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssignedTeam->nid .'/edit', 'The Task edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $taskAssignedTeam->nid .'/delete', 'The Task delete icon appears on the list');
|
||||
}
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Team module.
|
||||
*/
|
||||
class StormteamTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Team Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Team module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormperson', 'stormteam');
|
||||
}
|
||||
|
||||
public function testStormteamCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm team: add', 'Storm team: view all', 'Storm person: add', 'Storm person: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create a team
|
||||
$team = array(
|
||||
'title' => $this->randomName(32),
|
||||
);
|
||||
|
||||
$this->drupalPost('node/add/stormteam', $team, t('Save'));
|
||||
|
||||
$this->assertText(t('Team @title has been created.', array('@title' => $team['title'])));;
|
||||
}
|
||||
|
||||
public function testStormteamList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm team: access', 'Storm team: add', 'Storm team: view all', 'Storm team: edit all', 'Storm team: delete all', 'Storm person: add', 'Storm person: view all'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm team: access', 'Storm team: add', 'Storm team: view belonged', 'Storm team: edit belonged', 'Storm team: delete belonged'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm team: access', 'Storm team: add', 'Storm team: view own', 'Storm team: edit own', 'Storm team: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm team: access', 'Storm team: add', 'Storm team: view all', 'Storm team: edit own', 'Storm team: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$person = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person, t('Save'));
|
||||
$person = node_load(array('title' => $person['title']));
|
||||
|
||||
// Create teams
|
||||
$team1 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'members_array_1' => $person->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormteam', $team1, t('Save'));
|
||||
$team1 = node_load(array('title' => $team1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$team2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
);
|
||||
$this->drupalPost('node/add/stormteam', $team2, t('Save'));
|
||||
$team2 = node_load(array('title' => $team2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$team3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
);
|
||||
$this->drupalPost('node/add/stormteam', $team3, t('Save'));
|
||||
$team3 = node_load(array('title' => $team3['title']));
|
||||
|
||||
// Test for 'Storm team: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('teams');
|
||||
|
||||
$this->assertLink($team1->title, 0, 'The Team appears on the list');
|
||||
$this->assertRaw('node/'. $team1->nid .'/edit', 'The Team edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $team1->nid .'/delete', 'The Team delete icon appears on the list');
|
||||
|
||||
$this->assertLink($team2->title, 0, 'The Team appears on the list');
|
||||
$this->assertRaw('node/'. $team2->nid .'/edit', 'The Team edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $team2->nid .'/delete', 'The Team delete icon appears on the list');
|
||||
|
||||
$this->assertLink($team3->title, 0, 'The Team appears on the list');
|
||||
$this->assertRaw('node/'. $team3->nid .'/edit', 'The Team edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $team3->nid .'/delete', 'The Team delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm team: view belonged'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('teams');
|
||||
|
||||
$this->assertLink($team1->title, 0, 'The Team appears on the list');
|
||||
$this->assertRaw('node/'. $team1->nid .'/edit', 'The Team edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $team1->nid .'/delete', 'The Team delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($team2->title, 'The Team does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team2->nid .'/edit', 'The Team edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team2->nid .'/delete', 'The Team delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($team3->title, 'The Team does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team3->nid .'/edit', 'The Team edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team3->nid .'/delete', 'The Team delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm team: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('teams');
|
||||
|
||||
$this->assertNoLink($team1->title, 'The Team does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team1->nid .'/edit', 'The Team edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team1->nid .'/delete', 'The Team delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($team2->title, 0, 'The Team appears on the list');
|
||||
$this->assertRaw('node/'. $team2->nid .'/edit', 'The Team edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $team2->nid .'/delete', 'The Team delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($team3->title, 'The Team does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team3->nid .'/edit', 'The Team edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team3->nid .'/delete', 'The Team delete icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm team: view all', 'Storm team: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('teams');
|
||||
|
||||
$this->assertLink($team1->title, 0, 'The Team appears on the list');
|
||||
$this->assertNoRaw('node/'. $team1->nid .'/edit', 'The Team edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team1->nid .'/delete', 'The Team edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($team2->title, 0, 'The Team appears on the list');
|
||||
$this->assertNoRaw('node/'. $team2->nid .'/edit', 'The Team edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $team2->nid .'/delete', 'The Team delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($team3->title, 0, 'The Team appears on the list');
|
||||
$this->assertRaw('node/'. $team3->nid .'/edit', 'The Team edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $team3->nid .'/delete', 'The Team delete icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
|
@ -1,344 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Ticket module.
|
||||
*/
|
||||
class StormticketTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Ticket Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Ticket module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormticket', 'stormperson', 'stormteam');
|
||||
}
|
||||
|
||||
public function testStormticketAccess() {
|
||||
$this->drupalGet('tickets');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Tickets list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('tickets');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Tickets list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm ticket: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('tickets');
|
||||
$this->assertText(t('Tickets'), t('Make sure the correct page has been displayed by checking that the title is "Tickets".'));
|
||||
}
|
||||
|
||||
public function testStormticketCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm ticket: add', 'Storm ticket: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$ticket = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
$this->drupalPost('node/add/stormticket', $ticket, t('Save'));
|
||||
|
||||
$this->assertText(t('Ticket @title has been created.', array('@title' => $ticket['title'])));;
|
||||
}
|
||||
|
||||
public function testStormticketList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view all', 'Storm ticket: edit all', 'Storm ticket: delete all', 'Storm person: add', 'Storm team: add', 'Storm person: view all', 'Storm team: view all', 'Storm project: add', 'Storm project: view all'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view of user organization', 'Storm ticket: edit of user organization', 'Storm ticket: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view own', 'Storm ticket: edit own', 'Storm ticket: delete own', 'Storm project: view all'));
|
||||
$userAssigned = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view if assigned to ticket', 'Storm ticket: edit if assigned to ticket', 'Storm ticket: delete if assigned to ticket'));
|
||||
$userAssignedTeam = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view if assigned to ticket', 'Storm ticket: edit if assigned to ticket', 'Storm ticket: delete if assigned to ticket'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm ticket: access', 'Storm ticket: add', 'Storm ticket: view all', 'Storm ticket: edit own', 'Storm ticket: delete own', 'Storm project: view all'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userAssigned->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$assignedPerson = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userAssignedTeam->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
$assignedPersonTeam = node_load(array('title' => $personOrg['title']));
|
||||
|
||||
$team = array(
|
||||
'title' => $this->randomName(32),
|
||||
'members_array_1' => $assignedPersonTeam->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormteam', $team, t('Save'));
|
||||
$team = node_load(array('title' => $team['title']));
|
||||
|
||||
// Create project foreach organization
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectOrg = node_load(array('title' => $prj['title']));
|
||||
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org->nid,
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectTeam = node_load(array('title' => $prj['title']));
|
||||
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => $org2->nid,
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$projectOrg2 = node_load(array('title' => $prj['title']));
|
||||
|
||||
// Create tickets
|
||||
$ticket1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticket1, t('Save'), array('query' => 'organization_nid='.$org->nid));
|
||||
$ticket1 = node_load(array('title' => $ticket1['title']));
|
||||
|
||||
$ticketAssigned = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'assigned_nid' => $assignedPerson->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticketAssigned, t('Save'), array('query' => 'organization_nid='.$org->nid.'&project_nid='.$projectOrg->nid));
|
||||
$ticketAssigned = node_load(array('title' => $ticketAssigned['title']));
|
||||
|
||||
$ticketAssignedTeam = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectTeam->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'assigned_nid' => $team->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticketAssignedTeam, t('Save'), array('query' => 'organization_nid='.$org->nid.'&project_nid='.$projectTeam->nid));
|
||||
$ticketAssignedTeam = node_load(array('title' => $ticketAssignedTeam['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$ticket2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'project_nid' => $projectOrg->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticket2, t('Save'), array('query' => 'organization_nid='.$org->nid));
|
||||
$ticket2 = node_load(array('title' => $ticket2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$ticket3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
'project_nid' => $projectOrg2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormticket', $ticket3, t('Save'), array('query' => 'organization_nid='.$org2->nid));
|
||||
$ticket3 = node_load(array('title' => $ticket3['title']));
|
||||
|
||||
// Test for 'Storm ticket: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertLink($ticket1->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticket2->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticket3->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticketAssigned->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticketAssignedTeam->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm ticket: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertLink($ticket1->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticket2->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($ticket3->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticketAssigned->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticketAssignedTeam->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm ticket: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertNoLink($ticket1->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticket2->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($ticket3->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticketAssigned->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticketAssignedTeam->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm ticket: view all', 'Storm ticket: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertLink($ticket1->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/delete', 'The Ticket edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticket2->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticket3->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertLink($ticketAssigned->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticketAssignedTeam->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm ticket: view if assigned to ticket'
|
||||
$this->drupalLogin($userAssigned);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertNoLink($ticket1->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticket2->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticket3->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticketAssigned->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($ticketAssignedTeam->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm ticket: view if assigned to ticket' (using team)
|
||||
$this->drupalLogin($userAssignedTeam);
|
||||
$this->drupalGet('tickets');
|
||||
|
||||
$this->assertNoLink($ticket1->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket1->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticket2->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket2->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticket3->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticket3->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($ticketAssigned->title, 'The Ticket does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/edit', 'The Ticket edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $ticketAssigned->nid .'/delete', 'The Ticket delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($ticketAssignedTeam->title, 0, 'The Ticket appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/edit', 'The Ticket edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $ticketAssignedTeam->nid .'/delete', 'The Ticket delete icon appears on the list');
|
||||
}
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Timetracking module.
|
||||
*/
|
||||
class StormtimetrackingTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Timetracking Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Timetracking module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormticket', 'stormtimetracking', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStormtimetrackingCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm ticket: add', 'Storm ticket: view all', 'Storm timetracking: add', 'Storm timetracking: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$ticket = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$timetracking = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
$this->drupalPost('node/add/stormticket', $ticket, t('Save'));
|
||||
$this->drupalPost('node/add/stormtimetracking', $timetracking, t('Save'));
|
||||
|
||||
$this->assertText(t('Timetracking @title has been created.', array('@title' => $timetracking['title'])));;
|
||||
}
|
||||
|
||||
public function testStormtimetrackingList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm timetracking: access', 'Storm timetracking: add', 'Storm timetracking: view all', 'Storm timetracking: edit all', 'Storm timetracking: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm timetracking: access', 'Storm timetracking: add', 'Storm timetracking: view of user organization', 'Storm timetracking: edit of user organization', 'Storm timetracking: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm timetracking: access', 'Storm timetracking: add', 'Storm timetracking: view own', 'Storm timetracking: edit own', 'Storm timetracking: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm timetracking: access', 'Storm timetracking: add', 'Storm timetracking: view all', 'Storm timetracking: edit own', 'Storm timetracking: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create timetrackings
|
||||
$timetracking1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormtimetracking', $timetracking1, t('Save'));
|
||||
$timetracking1 = node_load(array('title' => $timetracking1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$timetracking2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormtimetracking', $timetracking2, t('Save'));
|
||||
$timetracking2 = node_load(array('title' => $timetracking2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$timetracking3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormtimetracking', $timetracking3, t('Save'));
|
||||
$timetracking3 = node_load(array('title' => $timetracking3['title']));
|
||||
|
||||
// Test for 'Storm timetracking: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('timetrackings');
|
||||
|
||||
$this->assertLink($timetracking1->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking1->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking1->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertLink($timetracking2->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertLink($timetracking3->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking3->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking3->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm timetracking: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('timetrackings');
|
||||
|
||||
$this->assertLink($timetracking1->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking1->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking1->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertLink($timetracking2->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($timetracking3->title, 'The Timetracking does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking3->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking3->nid .'/delete', 'The Timetracking delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm timetracking: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('timetrackings');
|
||||
|
||||
$this->assertNoLink($timetracking1->title, 'The Timetracking does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking1->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking1->nid .'/delete', 'The Timetracking delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($timetracking2->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($timetracking3->title, 'The Timetracking does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking3->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking3->nid .'/delete', 'The Timetracking delete icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm timetracking: view all', 'Storm timetracking: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('timetrackings');
|
||||
|
||||
$this->assertLink($timetracking1->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking1->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking1->nid .'/delete', 'The Timetracking edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($timetracking2->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking2->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking2->nid .'/delete', 'The Timetracking delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($timetracking3->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking3->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking3->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
|
||||
Overview
|
||||
========
|
||||
In many cases, it's useful to allow users to define patterns or large
|
||||
chunks of text that contain programmatically derived values. For example,
|
||||
form email messages addressed to a given user, or url path aliases
|
||||
containing the title of a given node. Both examples require bits of data
|
||||
that vary each time the text is generated -- node titles, user ids, and
|
||||
so on. Rather than forcing users to embed ugly snippets of PHP, or creating
|
||||
elaborate and bizarre UIs for configuring the patterns via the browser,
|
||||
it's most useful to give users a set of 'placeholder' tokens to place in
|
||||
their text.
|
||||
|
||||
Token.module provides a shared API for exposing and using placeholder
|
||||
tokens and their appropriate replacement values. It does nothing *by
|
||||
itself* -- other modules can use it to avoid reinventing the wheel.
|
||||
|
||||
Using Token Replacement
|
||||
=======================
|
||||
To apply token replacement to a chunk of text, you have two options. The
|
||||
first, and simplest, is:
|
||||
|
||||
token_replace($original, $type = 'global', $object = NULL,
|
||||
$leading = '[', $trailing = ']')
|
||||
|
||||
$original is the source text to perform substitutions on: it can be either
|
||||
a simple string, or an array of multiple strings.
|
||||
|
||||
$type and $object are to be used when performing substitution based on a
|
||||
particular Drupal object. Replacing tokens in an email with values from
|
||||
a particular user account, or replacing tokens in a path alias pattern with
|
||||
values from the node being aliased, are two examples.
|
||||
|
||||
$type should contain the general object type (node, comment, user, etc.)
|
||||
while $object should contain the object itself.
|
||||
|
||||
$leading and $trailing can be used to override the default token style.
|
||||
For example, to replace tokens using %this style, pass in '%' and '' for
|
||||
the $leading and $trailing values. Note that passing in a leading but NOT
|
||||
trailing value can lead to false positives if two tokens are named in a
|
||||
similar fashion (%node_term and %node_term_id, for example).
|
||||
|
||||
|
||||
|
||||
Altering The Replacement Values
|
||||
===============================
|
||||
If your module needs to perform additional cleanup work on the replacement
|
||||
values before doing the actual substitutions (cleaning replacement values
|
||||
to make them appropriate for path aliasing, truncating them to a particular
|
||||
length, etc.) you can manually retrieve the list of tokens and replacement
|
||||
values, then call str_replace() yourself.
|
||||
|
||||
token_get_values($type = 'global', $object = NULL)
|
||||
|
||||
Pass in the $type and $object as you would with the simpler token_replace()
|
||||
function. The return value will be an object containing one array of tokens
|
||||
and one array of values as in this example:
|
||||
|
||||
stdClass Object {
|
||||
[tokens] => array(
|
||||
[0] => mytoken1,
|
||||
[1] => mytoken2
|
||||
),
|
||||
[values] => array(
|
||||
[0] => value1,
|
||||
[1] => value2,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Providing Placeholder Tokens
|
||||
============================
|
||||
Token.module provides a small set of default placeholders for global values
|
||||
like the name of the currently logged in user, the site's URL, and so on.
|
||||
Any module can provide additional tokens by implementing two hooks.
|
||||
|
||||
Security note: For tokens which include user input, users and modules
|
||||
expect to see both a ['token-name'] and a ['token-name-raw'] value.
|
||||
|
||||
|
||||
hook_token_values($type, $object = NULL)
|
||||
========================================
|
||||
This function should return a keyed array of placeholders, and their
|
||||
replacement values. $type contains the current context -- 'node', 'user',
|
||||
'global', etc. $object contains the specific node, user, etc. that
|
||||
should be used as the basis for the replacements. *Only* generate and
|
||||
return replacement tokens when $type is something that your module can
|
||||
really deal with. That helps keep things speedy and avoid needlessly
|
||||
searching for jillions of replacement tokens. The $options array can
|
||||
contain additional options (exact use is dynamic and not easily documented).
|
||||
|
||||
For example:
|
||||
|
||||
function my_user_token_values($type, $object = NULL, $options = array()) {
|
||||
if ($type == 'user') {
|
||||
$user = $object;
|
||||
$tokens['name'] = $user->name;
|
||||
$tokens['mail'] = $user->mail;
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hook_token_list($type = 'all')
|
||||
==============================
|
||||
This function is used to provide help and inline documentation for all
|
||||
of the possible replacement tokens.
|
||||
|
||||
As with hook_token_values, $type indicates the context that token help
|
||||
is being generated for. Unlike hook_token_values however, you should
|
||||
show ALL tokens at the same time if $type is 'all'. As such, the help
|
||||
text should be keyed by the $type context your module will use when
|
||||
doing the actual replacements. For example:
|
||||
|
||||
function my_user_token_list($type = 'all') {
|
||||
if ($type == 'user' || $type == 'all') {
|
||||
$tokens['user']['name'] = t("The user's name");
|
||||
$tokens['user']['mail'] = t("The user's email address");
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
Examples of more elaborate token replacement setups can be found in the
|
||||
token_node.inc file that's bundled with token.module.
|
||||
|
||||
Security Note
|
||||
========
|
||||
If use any of the tokens in the ['raw'] sub-array then please note that these
|
||||
are unfiltered values which could conceivably contain XSS attacks or other
|
||||
malicious data. Your module should then provide it's own filtering to ensure the
|
||||
safety of site users.
|
|
@ -1,690 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the token module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper test class with some added functions for testing.
|
||||
*/
|
||||
class TokenTestHelper extends DrupalWebTestCase {
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'path';
|
||||
$modules[] = 'token';
|
||||
$modules[] = 'token_test';
|
||||
parent::setUp($modules);
|
||||
|
||||
// Clear the token static cache.
|
||||
token_get_values('reset');
|
||||
}
|
||||
|
||||
function assertToken($type, $object, $token, $expected, array $options = array()) {
|
||||
$this->assertTokens($type, $object, array($token => $expected), $options);
|
||||
}
|
||||
|
||||
function assertTokens($type, $object, array $tokens, array $options = array()) {
|
||||
$values = token_get_values($type, $object, FALSE, $options);
|
||||
$values = array_combine($values->tokens, $values->values);
|
||||
foreach ($tokens as $token => $expected) {
|
||||
if (!isset($expected)) {
|
||||
$this->assertTrue(!isset($values[$token]), t("Token value for [@token] was not generated.", array('@token' => $token)));
|
||||
}
|
||||
elseif (!isset($values[$token])) {
|
||||
$this->fail(t("Token value for [@token] was not generated.", array('@token' => $token)));
|
||||
}
|
||||
else {
|
||||
$this->assertIdentical($values[$token], $expected, t("Token value for [@token] was '@actual', expected value '@expected'.", array('@token' => $token, '@actual' => $values[$token], '@expected' => $expected)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a page request and test for token generation.
|
||||
*/
|
||||
function assertPageTokens($url, array $tokens, array $data = array('global' => NULL), array $options = array()) {
|
||||
if (empty($tokens)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$token_page_tokens = array(
|
||||
'tokens' => $tokens,
|
||||
'data' => $data,
|
||||
'options' => $options,
|
||||
);
|
||||
variable_set('token_page_tokens', $token_page_tokens);
|
||||
|
||||
$options += array('url_options' => array());
|
||||
$this->drupalGet($url, $options['url_options']);
|
||||
$this->refreshVariables();
|
||||
$result = variable_get('token_page_tokens', array());
|
||||
|
||||
if (!isset($result['values']) || !is_array($result['values'])) {
|
||||
return $this->fail('Failed to generate tokens.');
|
||||
}
|
||||
|
||||
foreach ($tokens as $token => $expected) {
|
||||
if (!isset($expected)) {
|
||||
$this->assertTrue(!isset($result['values'][$token]) || $result['values'][$token] === $token, t("Token value for @token was not generated.", array('@token' => $token)));
|
||||
}
|
||||
elseif (!isset($result['values'][$token])) {
|
||||
$this->fail(t('Failed to generate token @token.', array('@token' => $token)));
|
||||
}
|
||||
else {
|
||||
$this->assertIdentical($result['values'][$token], (string) $expected, t("Token value for @token was '@actual', expected value '@expected'.", array('@token' => $token, '@actual' => $result['values'][$token], '@expected' => $expected)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TokenUnitTestCase extends TokenTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Token unit tests',
|
||||
'description' => 'Test basic, low-level token functions.',
|
||||
'group' => 'Token',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test token_get_invalid_tokens() and token_get_invalid_tokens_by_context().
|
||||
*/
|
||||
public function testGetInvalidTokens() {
|
||||
$tests = array();
|
||||
$tests[] = array(
|
||||
'valid tokens' => array(
|
||||
'[title-raw]',
|
||||
'[yyyy]',
|
||||
'[mod-yyyy]',
|
||||
'[site-name]',
|
||||
'[site-slogan]',
|
||||
'[user-id]',
|
||||
),
|
||||
'invalid tokens' => array(
|
||||
'[title-invalid]',
|
||||
'[invalid]',
|
||||
'[mod-invalid]',
|
||||
'[invalid-title]',
|
||||
'[site-invalid]',
|
||||
'[uid]',
|
||||
'[comment-cid]',
|
||||
),
|
||||
'types' => array('node'),
|
||||
);
|
||||
$tests[] = array(
|
||||
'valid tokens' => array(
|
||||
'[title-raw]',
|
||||
'[yyyy]',
|
||||
'[mod-yyyy]',
|
||||
'[site-name]',
|
||||
'[site-slogan]',
|
||||
'[user-id]',
|
||||
'[uid]',
|
||||
'[comment-cid]',
|
||||
),
|
||||
'invalid tokens' => array(
|
||||
'[title-invalid]',
|
||||
'[invalid]',
|
||||
'[mod-invalid]',
|
||||
'[invalid-title]',
|
||||
'[site-invalid]',
|
||||
),
|
||||
'types' => array('all'),
|
||||
);
|
||||
$tests[] = array(
|
||||
'valid tokens' => array(
|
||||
'[alpha]',
|
||||
'[beta-1]',
|
||||
'[beta-2]',
|
||||
'[gamma_A]',
|
||||
'[delta-extra]',
|
||||
'[epsilon-zeta-A]',
|
||||
),
|
||||
'invalid tokens' => array(
|
||||
'[alpha-plus]',
|
||||
'[beta]',
|
||||
'[beta-]',
|
||||
'[beta_]',
|
||||
'[beta_1]',
|
||||
'[beta-A]',
|
||||
'[gamma]',
|
||||
'[gamma_]',
|
||||
'[gamma-A]',
|
||||
'[delta]',
|
||||
'[epsilon-zeta-]',
|
||||
),
|
||||
'types' => array('all'),
|
||||
);
|
||||
|
||||
foreach ($tests as $test) {
|
||||
$tokens = array_merge($test['valid tokens'], $test['invalid tokens']);
|
||||
shuffle($tokens);
|
||||
|
||||
$invalid_tokens = token_get_invalid_tokens_by_context(implode(' ', $tokens), $test['types']);
|
||||
|
||||
sort($invalid_tokens);
|
||||
sort($test['invalid tokens']);
|
||||
$this->assertEqual($invalid_tokens, $test['invalid tokens'], 'Invalid tokens detected properly: ' . implode(', ', $invalid_tokens));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the $options['clear'] parameter for token_replace().
|
||||
*/
|
||||
public function testClearOption() {
|
||||
$tests[] = array(
|
||||
'input' => 'Foo [site-name][invalid-token] bar [another-invalid-token] [invalid-token]',
|
||||
'output' => 'Foo Drupal bar ',
|
||||
'options' => array('clear' => TRUE),
|
||||
);
|
||||
$tests[] = array(
|
||||
'input' => 'Foo [site-name][invalid-token] bar [another-invalid-token] [invalid-token]',
|
||||
'output' => 'Foo Drupal[invalid-token] bar [another-invalid-token] [invalid-token]',
|
||||
'options' => array(),
|
||||
);
|
||||
|
||||
foreach ($tests as $test) {
|
||||
$output = token_replace($test['input'], 'global', NULL, TOKEN_PREFIX, TOKEN_SUFFIX, $test['options']);
|
||||
$this->assertIdentical($output, $test['output']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether token-replacement works in various contexts.
|
||||
*
|
||||
* @see http://drupal.org/node/733192
|
||||
*/
|
||||
function testSystemTokenRecognition() {
|
||||
global $language;
|
||||
|
||||
// Generate prefixes and suffixes for the token context.
|
||||
$tests = array(
|
||||
array('prefix' => 'this is the ', 'suffix' => ' site'),
|
||||
array('prefix' => 'this is the', 'suffix' => 'site'),
|
||||
array('prefix' => '[', 'suffix' => ']'),
|
||||
array('prefix' => '', 'suffix' => ']]]'),
|
||||
array('prefix' => '[[[', 'suffix' => ''),
|
||||
array('prefix' => ':[:', 'suffix' => '--]'),
|
||||
array('prefix' => '-[-', 'suffix' => ':]:'),
|
||||
array('prefix' => '[:', 'suffix' => ']'),
|
||||
array('prefix' => '[site:', 'suffix' => ':name]'),
|
||||
array('prefix' => '[site:', 'suffix' => ']'),
|
||||
);
|
||||
|
||||
// Check if the token is recognized in each of the contexts.
|
||||
foreach ($tests as $test) {
|
||||
$input = $test['prefix'] . '[site-name]' . $test['suffix'];
|
||||
$expected = $test['prefix'] . 'Drupal' . $test['suffix'];
|
||||
$output = token_replace($input);
|
||||
$this->assertEqual($output, $expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test token caching.
|
||||
*/
|
||||
function testTokenCaching() {
|
||||
// Run global tokens once so that the cache is primed.
|
||||
$tokens = array(
|
||||
'option-foo' => '',
|
||||
);
|
||||
$this->assertTokens('global', NULL, $tokens);
|
||||
|
||||
// Run global tokens again with different options. This should return a
|
||||
// different value for the [option-foo] token.
|
||||
$tokens = array(
|
||||
'option-foo' => 'bar',
|
||||
);
|
||||
$this->assertTokens('global', NULL, $tokens, array('foo' => 'bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the token_scan() function.
|
||||
*/
|
||||
function testTokenScan() {
|
||||
$tests = array(
|
||||
array('text' => 'Test [foo] [[bar]] test.', 'tokens' => array('foo', 'bar')),
|
||||
array('text' => 'Test [foo] [] test.', 'tokens' => array('foo')),
|
||||
array('text' => 'Test [foo][] test.', 'tokens' => array('foo')),
|
||||
array('text' => 'Test [foo][bar] test.', 'tokens' => array('foo', 'bar')),
|
||||
// Test the e-mail token syntax.
|
||||
array('text' => 'Test %foo %%bar test.', 'tokens' => array('foo', 'bar'), 'leading' => '%', 'trailing' => ''),
|
||||
array('text' => 'Test %foo % test.', 'tokens' => array('foo'), 'leading' => '%', 'trailing' => ''),
|
||||
array('text' => 'Test %foo% test.', 'tokens' => array('foo'), 'leading' => '%', 'trailing' => ''),
|
||||
array('text' => 'Test %foo%%bar test.', 'tokens' => array('foo', 'bar'), 'leading' => '%', 'trailing' => ''),
|
||||
// Test the rules token syntax.
|
||||
array('text' => 'Test [global:foo] [global:bar] test.', 'tokens' => array('foo', 'bar'), 'leading' => '[global:'),
|
||||
array('text' => 'Test [node:foo] [node:] test.', 'tokens' => array('foo'), 'leading' => '[node:'),
|
||||
array('text' => 'Test [node:foo][node:] test.', 'tokens' => array('foo'), 'leading' => '[node:'),
|
||||
array('text' => 'Test [node:foo][node:bar] test.', 'tokens' => array('foo', 'bar'), 'leading' => '[node:'),
|
||||
);
|
||||
foreach ($tests as $test) {
|
||||
$test += array('leading' => TOKEN_PREFIX, 'trailing' => TOKEN_SUFFIX);
|
||||
$this->assertEqual(token_scan($test['text'], $test['leading'], $test['trailing']), $test['tokens']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TokenNodeTestCase extends TokenTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Node token tests',
|
||||
'description' => 'Test the node tokens.',
|
||||
'group' => 'Token',
|
||||
);
|
||||
}
|
||||
|
||||
function testNodeTokens() {
|
||||
$time = time();
|
||||
$created = gmmktime(0, 0, 0, 11, 19, 1978);
|
||||
$changed = gmmktime(0, 0, 0, 7, 4, 1984);
|
||||
$node = $this->drupalCreateNode(array(
|
||||
'type' => 'page',
|
||||
'language' => 'und',
|
||||
'created' => $created,
|
||||
'log' => '<blink>' . $this->randomName() . '</blink>',
|
||||
));
|
||||
$node->changed = $changed;
|
||||
path_set_alias('node/' . $node->nid, 'content/first-node');
|
||||
|
||||
$tokens = array(
|
||||
'nid' => $node->nid,
|
||||
'type' => 'page',
|
||||
'type-name' => 'Page',
|
||||
'language' => 'und',
|
||||
'node-path' => 'content/first-node',
|
||||
'node-url' => url('node/' . $node->nid, array('absolute' => TRUE)),
|
||||
'small' => '11/19/1978 - 00:00',
|
||||
'yyyy' => '1978',
|
||||
'yy' => '78',
|
||||
'month' => 'November',
|
||||
'mon' => 'Nov',
|
||||
'mm' => '11',
|
||||
'm' => '11',
|
||||
'ww' => '46',
|
||||
'date' => '7',
|
||||
'day' => 'Sunday',
|
||||
'ddd' => 'Sun',
|
||||
'dd' => '19',
|
||||
'd' => '19',
|
||||
'raw' => 280281600,
|
||||
'since' => format_interval($time - 280281600),
|
||||
'mod-small' => '07/04/1984 - 00:00',
|
||||
'mod-yyyy' => '1984',
|
||||
'mod-yy' => '84',
|
||||
'mod-month' => 'July',
|
||||
'mod-mon' => 'Jul',
|
||||
'mod-mm' => '07',
|
||||
'mod-m' => '7',
|
||||
'mod-ww' => '27',
|
||||
'mod-date' => '3',
|
||||
'mod-day' => 'Wednesday',
|
||||
'mod-ddd' => 'Wed',
|
||||
'mod-dd' => '04',
|
||||
'mod-d' => '4',
|
||||
'mod-raw' => 457747200,
|
||||
'mod-since' => format_interval($time - 457747200),
|
||||
'log' => filter_xss($node->log),
|
||||
'log-raw' => $node->log,
|
||||
);
|
||||
$this->assertTokens('node', $node, $tokens);
|
||||
|
||||
// Check that a new revision of a node returns different tokens.
|
||||
$node->revision = TRUE;
|
||||
$node->title = 'New revision';
|
||||
node_save($node);
|
||||
$this->assertTokens('node', $node, array('title' => 'New revision'));
|
||||
}
|
||||
}
|
||||
|
||||
class TokenCommentTestCase extends TokenTestHelper {
|
||||
protected $node;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Comment token tests',
|
||||
'description' => 'Test the comment tokens.',
|
||||
'group' => 'Token',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'comment';
|
||||
parent::setUp($modules);
|
||||
$this->node = $this->drupalCreateNode(array('comment' => 2));
|
||||
}
|
||||
|
||||
function loadComment($cid) {
|
||||
return db_fetch_object(db_query('SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid));
|
||||
}
|
||||
|
||||
function createComment(array $comment) {
|
||||
$comment += array(
|
||||
'cid' => 0,
|
||||
'nid' => $this->node->nid,
|
||||
'pid' => 0,
|
||||
'uid' => 0,
|
||||
'subject' => $this->randomName(),
|
||||
'comment' => $this->randomName(64),
|
||||
'format' => 1,
|
||||
'timestamp' => gmmktime(0, 0, 0, 7, 4, 1984),
|
||||
'status' => COMMENT_PUBLISHED,
|
||||
);
|
||||
|
||||
$cid = comment_save($comment);
|
||||
return $this->loadComment($cid);
|
||||
}
|
||||
|
||||
function testCommentTokens() {
|
||||
$time = time();
|
||||
$comment = $this->createComment(array(
|
||||
'timestamp' => gmmktime(0, 0, 0, 7, 4, 1984),
|
||||
));
|
||||
|
||||
$tokens = array(
|
||||
'comment-cid' => $comment->cid,
|
||||
'comment-nid' => $this->node->nid,
|
||||
'comment-yyyy' => '1984',
|
||||
'comment-yy' => '84',
|
||||
'comment-month' => 'July',
|
||||
'comment-mon' => 'Jul',
|
||||
'comment-mm' => '07',
|
||||
'comment-m' => '7',
|
||||
'comment-ww' => '27',
|
||||
'comment-date' => '3',
|
||||
'comment-day' => 'Wednesday',
|
||||
'comment-ddd' => 'Wed',
|
||||
'comment-dd' => '04',
|
||||
'comment-d' => '4',
|
||||
'comment-raw' => '457747200',
|
||||
'comment-since' => format_interval($time - 457747200),
|
||||
'comment-node-title' => check_plain($this->node->title),
|
||||
'comment-node-title-raw' => $this->node->title,
|
||||
);
|
||||
$this->assertTokens('comment', $comment, $tokens);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class TokenTaxonomyTestCase extends TokenTestHelper {
|
||||
protected $vocabulary;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Taxonomy and vocabulary token tests',
|
||||
'description' => 'Test the taxonomy tokens.',
|
||||
'group' => 'Token',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'taxonomy';
|
||||
parent::setUp($modules);
|
||||
// Reset the static taxonomy.module caches.
|
||||
taxonomy_vocabulary_load(0, TRUE);
|
||||
taxonomy_get_term(0, TRUE);
|
||||
}
|
||||
|
||||
function addVocabulary(array $vocabulary = array()) {
|
||||
$vocabulary += array(
|
||||
'name' => drupal_strtolower($this->randomName(5)),
|
||||
'nodes' => array('story' => 'story'),
|
||||
);
|
||||
taxonomy_save_vocabulary($vocabulary);
|
||||
return (object) $vocabulary;
|
||||
}
|
||||
|
||||
function addTerm(stdClass $vocabulary, array $term = array()) {
|
||||
$term += array(
|
||||
'name' => drupal_strtolower($this->randomName(5)),
|
||||
'vid' => $vocabulary->vid,
|
||||
);
|
||||
taxonomy_save_term($term);
|
||||
return (object) $term;
|
||||
}
|
||||
|
||||
function testTaxonomyTokens() {
|
||||
$vocabulary = $this->addVocabulary(array(
|
||||
'name' => '<blink>Vocab Name</blink>',
|
||||
'description' => '<blink>Vocab Description</blink>',
|
||||
));
|
||||
$term = $this->addTerm($vocabulary, array(
|
||||
'name' => '<blink>Term Name</blink>',
|
||||
'description' => '<blink>Term Description</blink>',
|
||||
));
|
||||
|
||||
$tokens = array(
|
||||
'tid' => $term->tid,
|
||||
'cat' => check_plain($term->name),
|
||||
'cat-raw' => $term->name,
|
||||
'cat-description' => 'Term Description',
|
||||
'vid' => $vocabulary->vid,
|
||||
'vocab' => check_plain($vocabulary->name),
|
||||
'vocab-raw' => $vocabulary->name,
|
||||
'vocab-description' => 'Vocab Description',
|
||||
'vocab-description-raw' => $vocabulary->description,
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term, $tokens);
|
||||
|
||||
$tokens = array(
|
||||
'vocabulary-vid' => $vocabulary->vid,
|
||||
'vocabulary-name' => check_plain($vocabulary->name),
|
||||
'vocabulary-name-raw' => $vocabulary->name,
|
||||
'vocabulary-description' => 'Vocab Description',
|
||||
'vocabulary-description-raw' => $vocabulary->description,
|
||||
);
|
||||
$this->assertTokens('vocabulary', $vocabulary, $tokens);
|
||||
}
|
||||
}
|
||||
|
||||
class TokenMenuTestCase extends TokenTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Menu token tests',
|
||||
'description' => 'Test the menu tokens.',
|
||||
'group' => 'Token',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'menu';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
function testMenuTokens() {
|
||||
$root_link = array(
|
||||
'link_path' => 'root',
|
||||
'link_title' => 'Root link',
|
||||
'menu_name' => 'primary-links',
|
||||
);
|
||||
menu_link_save($root_link);
|
||||
|
||||
// Add another link with the root link as the parent
|
||||
$parent_link = array(
|
||||
'link_path' => 'root/parent',
|
||||
'link_title' => 'Parent link',
|
||||
'menu_name' => 'primary-links',
|
||||
'plid' => $root_link['mlid'],
|
||||
);
|
||||
menu_link_save($parent_link);
|
||||
|
||||
$node_link = array(
|
||||
'enabled' => TRUE,
|
||||
'link_title' => 'Node link',
|
||||
'plid' => $parent_link['mlid'],
|
||||
'customized' => 0,
|
||||
);
|
||||
$node = $this->drupalCreateNode(array('menu' => $node_link));
|
||||
|
||||
// Test [node:menu] tokens.
|
||||
$tokens = array(
|
||||
'menu' => 'Primary links',
|
||||
'menu-raw' => 'Primary links',
|
||||
'menupath' => 'Root link/Parent link/Node link',
|
||||
'menupath-raw' => 'Root link/Parent link/Node link',
|
||||
'menu-link-title' => 'Node link',
|
||||
'menu-link-title-raw' => 'Node link',
|
||||
'menu-link-mlid' => $node->menu['mlid'],
|
||||
'menu-link-plid' => $node->menu['plid'],
|
||||
'menu-link-plid' => $parent_link['mlid'],
|
||||
'menu-link-parent-path' => 'root/parent',
|
||||
'menu-link-parent-path-raw' => 'root/parent',
|
||||
);
|
||||
$this->assertTokens('node', $node, $tokens);
|
||||
|
||||
// Reload the node which will not have $node->menu defined and re-test.
|
||||
$loaded_node = node_load($node->nid);
|
||||
// We have to reset the token static cache because tokens are cached by
|
||||
// node ID only and not if the node object has changed.
|
||||
$this->assertTokens('node', $loaded_node, $tokens, array('reset' => TRUE));
|
||||
|
||||
// Regression test for http://drupal.org/node/1317926 to ensure the
|
||||
// original node object is not changed when calling menu_node_prepare().
|
||||
$this->assertTrue(!isset($loaded_node->menu), t('The $node->menu property was not modified during token replacement.'), 'Regression');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unit tests for the book tokens provided by Pathauto.
|
||||
*/
|
||||
class TokenBookTestCase extends TokenTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Book tokens',
|
||||
'description' => 'Tests the book tokens.',
|
||||
'group' => 'Token',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'book';
|
||||
$modules[] = 'menu';
|
||||
parent::setUp($modules);
|
||||
|
||||
variable_set('book_allowed_types', array('book', 'page'));
|
||||
}
|
||||
|
||||
function testBookTokens() {
|
||||
// Add a non-book node.
|
||||
$non_book_node = $this->drupalCreateNode(array('type' => 'book'));
|
||||
$tokens = array(
|
||||
'book' => '',
|
||||
'book-raw' => '',
|
||||
'book_id' => '',
|
||||
'bookpath' => '',
|
||||
'bookpath-raw' => '',
|
||||
);
|
||||
$this->assertTokens('node', $non_book_node, $tokens);
|
||||
|
||||
// Add a root book page.
|
||||
$parent_node = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Root',
|
||||
'book' => array('bid' => 'new') + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'book' => 'Root',
|
||||
'book-raw' => 'Root',
|
||||
'book_id' => $parent_node->book['bid'],
|
||||
'bookpath' => '',
|
||||
'bookpath-raw' => '',
|
||||
// Check that even those book menu links have been created for this node,
|
||||
// that the menu links still return nothing.
|
||||
'menu' => '',
|
||||
'menupath' => '',
|
||||
'menu-link-title' => '',
|
||||
'menu-link-title-raw' => '',
|
||||
'menu-link-mlid' => '',
|
||||
'menu-link-plid' => '',
|
||||
'menu-link-parent-path' => '',
|
||||
);
|
||||
$this->assertTokens('node', $parent_node, $tokens);
|
||||
|
||||
// Add a first child page.
|
||||
$child_node1 = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Sub page1',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $parent_node->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'book' => 'Root',
|
||||
'book-raw' => 'Root',
|
||||
'book_id' => $parent_node->book['bid'],
|
||||
'bookpath' => 'Root',
|
||||
'bookpath-raw' => 'Root',
|
||||
);
|
||||
$this->assertTokens('node', $child_node1, $tokens);
|
||||
|
||||
// Add a second child page.
|
||||
$child_node2 = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Sub page2',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $parent_node->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'book' => 'Root',
|
||||
'book-raw' => 'Root',
|
||||
'book_id' => $parent_node->book['bid'],
|
||||
'bookpath' => 'Root',
|
||||
'bookpath-raw' => 'Root',
|
||||
);
|
||||
$this->assertTokens('node', $child_node2, $tokens);
|
||||
|
||||
// Add a child page on an existing child page.
|
||||
$sub_child_node1 = $this->drupalCreateNode(array(
|
||||
'type' => 'page',
|
||||
'title' => 'Sub-sub Page1',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $child_node1->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'book' => 'Root',
|
||||
'book-raw' => 'Root',
|
||||
'book_id' => $parent_node->book['bid'],
|
||||
'bookpath' => 'Root/Sub page1',
|
||||
'bookpath-raw' => 'Root/Sub page1',
|
||||
);
|
||||
$this->assertTokens('node', $sub_child_node1, $tokens);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the current page tokens.
|
||||
*/
|
||||
class TokenCurrentPageTestCase extends TokenTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Current page token tests',
|
||||
'description' => 'Test the current page tokens.',
|
||||
'group' => 'Token',
|
||||
);
|
||||
}
|
||||
|
||||
function testCurrentPageTokens() {
|
||||
$tokens = array(
|
||||
'[current-page-title]' => '',
|
||||
'[current-page-path]' => 'node',
|
||||
'[current-page-url]' => url('node', array('absolute' => TRUE)),
|
||||
'[current-page-number]' => 1,
|
||||
);
|
||||
$this->assertPageTokens('', $tokens);
|
||||
|
||||
$node = $this->drupalCreateNode(array('title' => 'Node title', 'path' => 'node-alias'));
|
||||
$tokens = array(
|
||||
'[current-page-title]' => 'Node title',
|
||||
'[current-page-path]' => 'node-alias',
|
||||
'[current-page-url]' => url("node/{$node->nid}", array('absolute' => TRUE)),
|
||||
'[current-page-number]' => 1,
|
||||
);
|
||||
$this->assertPageTokens("node/{$node->nid}", $tokens);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
name = TokenSTARTER
|
||||
description = Provides additional tokens and a base on which to build your own tokens.
|
||||
package = Core - extended
|
||||
dependencies[] = token
|
||||
core = 6.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-09-12
|
||||
version = "6.x-1.19"
|
||||
core = "6.x"
|
||||
project = "token"
|
||||
datestamp = "1347470077"
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* The Token API module.
|
||||
*
|
||||
* The Token module provides an API for providing tokens to other modules.
|
||||
* Tokens are small bits of text that can be placed into larger documents
|
||||
* via simple placeholders, like %site-name or [user].
|
||||
*
|
||||
* @ingroup token
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_token_list().
|
||||
*/
|
||||
function tokenSTARTER_token_list($type = 'all') {
|
||||
$tokens = array();
|
||||
|
||||
if ($type == 'global' || $type == 'all') {
|
||||
$tokens['global']['random-sha1'] = t("A randomly generated SHA1 hash.");
|
||||
$tokens['global']['site-date-timestamp'] = t('The current timestamp in seconds past January 1, 1970.');
|
||||
$tokens['global']['random-num-1'] = t('A randomly generated single-digit number.');
|
||||
$tokens['global']['random-num-3'] = t('A randomly generated three-digit number.');
|
||||
$tokens['global']['random-num-10'] = t('A randomly generated ten-digit number.');
|
||||
$tokens['global']['random-alpha-1'] = t('Randomly generated single-digit letter.');
|
||||
$tokens['global']['random-alpha-3'] = t('Randomly generated three-digit letters.');
|
||||
$tokens['global']['random-alpha-10'] = t('Randomly generated ten-digit letters.');
|
||||
}
|
||||
if ($type == 'node' || $type == 'all') {
|
||||
// Node tokens here.
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_token_values().
|
||||
*/
|
||||
function tokenSTARTER_token_values($type, $object = NULL, $options = array()) {
|
||||
$values = array();
|
||||
switch ($type) {
|
||||
case 'global':
|
||||
$values['random-sha1'] = sha1(rand());
|
||||
// Create random numbers.
|
||||
$values['random-num-1'] = mt_rand(0, 9);
|
||||
$values['random-num-3'] = mt_rand(100, 999);
|
||||
$values['random-num-10'] = mt_rand(10000, 99999) . mt_rand(10000, 99999);
|
||||
// Create random letters.
|
||||
$letters = range('a', 'z');
|
||||
$values['random-alpha-1'] = $letters[array_rand($letters, 1)];
|
||||
shuffle($letters);
|
||||
$values['random-alpha-3'] = implode('', array_slice($letters, 0, 3));
|
||||
shuffle($letters);
|
||||
$values['random-alpha-10'] = implode('', array_slice($letters, 0, 10));
|
||||
// Create a UNIX timestamp token.
|
||||
$time = time();
|
||||
$tz = variable_get('date_default_timezone', 0);
|
||||
$values['site-date-timestamp'] = format_date($time, 'custom', 'Y', $tz);
|
||||
|
||||
break;
|
||||
case 'node':
|
||||
// Node tokens here.
|
||||
break;
|
||||
}
|
||||
return $values;
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the token_actions module.
|
||||
*/
|
||||
|
||||
class TokenActionsTestCase extends DrupalWebTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Token action tests'),
|
||||
'description' => t('Test some of the token actions and tokens.'),
|
||||
'group' => t('Token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('token', 'token_actions', 'trigger');
|
||||
$user = $this->drupalCreateUser(array('administer actions', 'administer site configuration', 'administer users'));
|
||||
$this->drupalLogin($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test user actions and triggers.
|
||||
*/
|
||||
function testUserActions() {
|
||||
$insert_action = $this->createAction('token_actions_message_action', array(
|
||||
'message' => 'Yay [site-name] has a new user [user] with an ID of [uid] and e-mail address of [mail]!',
|
||||
));
|
||||
$this->assignTriggerAction('user', 'insert', $insert_action);
|
||||
|
||||
// Create a user to trigger the action.
|
||||
$edit = array();
|
||||
$edit['name'] = $this->randomName();
|
||||
$edit['mail'] = $edit['name'] .'@example.com';
|
||||
$edit['pass[pass1]'] = $this->randomName();
|
||||
$edit['pass[pass2]'] = $edit['pass[pass1]'];
|
||||
|
||||
$this->drupalPost('admin/user/user/create', $edit, t('Create new account'));
|
||||
$account = user_load(array('name' => $edit['name']));
|
||||
$this->assertText("Yay Drupal has a new user {$account->name} with an ID of {$account->uid} and e-mail address of {$account->mail}!", 'Tokenized message displays');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an action.
|
||||
*
|
||||
* @param $action
|
||||
* The machine name of the action.
|
||||
* @param $edit
|
||||
* An optional array to pass onto drupalPost() for configuring the action.
|
||||
*
|
||||
* @return
|
||||
* The created action object.
|
||||
*/
|
||||
function createAction($action, $edit = array()) {
|
||||
$edit += array(
|
||||
'actions_description' => $this->randomName(),
|
||||
);
|
||||
$this->drupalPost('admin/settings/actions/configure/'. md5($action), $edit, t('Save'));
|
||||
$this->assertText('The action has been successfully saved.');
|
||||
return db_fetch_object(db_query("SELECT * FROM {actions} WHERE type = 'system' AND callback = '%s' AND description = '%s'", $action, $edit['actions_description']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign an action to a trigger.
|
||||
*
|
||||
* @param $type
|
||||
* The trigger type.
|
||||
* @param $trigger
|
||||
* The trigger.
|
||||
* @param $action
|
||||
* The action object.
|
||||
*/
|
||||
function assignTriggerAction($type, $trigger, $action) {
|
||||
$edit['aid'] = md5($action->aid);
|
||||
$this->drupalPost("admin/build/trigger/{$type}", $edit, 'Assign', array(), array(), "trigger-{$type}-{$trigger}-assign-form");
|
||||
return $this->assertLinkByHref("admin/build/trigger/unassign/{$type}/{$trigger}/{$edit['aid']}", 0, t('Action assigned to @type @trigger trigger.', array('@type' => $type, '@trigger' => $trigger)));
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
- If the interface text is *bolded*, it got strong tags.
|
||||
- If it's a button they need to click, that's *bold* too.
|
||||
- If the text is not bolded (ex: links to click, options to check), it
|
||||
got /italicized/.
|
||||
- If it's user-entered text it got 'single quotes'.
|
||||
|
Reference in a new issue