updated date pathauto addressfield honeypot features modules

This commit is contained in:
Bachir Soussi Chiadmi
2015-10-12 12:03:12 +02:00
parent 0ba0c21bb9
commit eb699f528d
109 changed files with 5363 additions and 2372 deletions

View File

@@ -132,11 +132,11 @@ class DateAPITestCase extends DrupalWebTestCase {
// Test week range with calendar weeks.
variable_set('date_first_day', 0);
variable_set('date_api_use_iso8601', FALSE);
$expected = '2008-01-27 to 2008-02-03';
$expected = '2008-01-27 to 2008-02-02';
$result = date_week_range(5, 2008);
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
$this->assertEqual($expected, $value, "Test calendar date_week_range(5, 2008): should be $expected, found $value.");
$expected = '2009-01-25 to 2009-02-01';
$expected = '2009-01-25 to 2009-01-31';
$result = date_week_range(5, 2009);
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
$this->assertEqual($expected, $value, "Test calendar date_week_range(5, 2009): should be $expected, found $value.");
@@ -144,11 +144,11 @@ class DateAPITestCase extends DrupalWebTestCase {
// And now with ISO weeks.
variable_set('date_first_day', 1);
variable_set('date_api_use_iso8601', TRUE);
$expected = '2008-01-28 to 2008-02-04';
$expected = '2008-01-28 to 2008-02-03';
$result = date_week_range(5, 2008);
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
$this->assertEqual($expected, $value, "Test ISO date_week_range(5, 2008): should be $expected, found $value.");
$expected = '2009-01-26 to 2009-02-02';
$expected = '2009-01-26 to 2009-02-01';
$result = date_week_range(5, 2009);
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
$this->assertEqual($expected, $value, "Test ISO date_week_range(5, 2009): should be $expected, found $value.");
@@ -396,6 +396,28 @@ class DateAPITestCase extends DrupalWebTestCase {
$date = new dateObject($input, $timezone, $format);
$this->assertNotEqual(count($date->errors), 0, '23 abc 2012 should be an invalid date');
// Test Granularity.
$input = '2005-06-01 10:30:45';
$timezone = NULL;
$format = 'Y-m-d H:i:s';
$date = new dateObject($input, $timezone, $format);
$date->removeGranularity('hour');
$date->removeGranularity('second');
$date->removeGranularity('minute');
$value = $date->format($format);
$expected = '2005-06-01';
$this->assertEqual($expected, $value, "The date with removed granularity should be $expected, found $value.");
$date->addGranularity('hour');
$date->addGranularity('second');
$date->addGranularity('minute');
$value = $date->format($format);
$expected = '2005-06-01 10:30:45';
$this->assertEqual($expected, $value, "The date with added granularity should be $expected, found $value.");
}
/**

View File

@@ -52,7 +52,7 @@ abstract class DateFieldBasic extends DrupalWebTestCase {
$repeat = !empty($repeat) ? $repeat : 0;
$todate = !empty($todate) ? $todate : 'optional';
$widget_type = !empty($widget_type) ? $widget_type : 'date_select';
$tz_handling = !empty($tz_handing) ? $tz_handling : 'site';
$tz_handling = !empty($tz_handling) ? $tz_handling : 'site';
$granularity = !empty($granularity) ? $granularity : array('year', 'month', 'day', 'hour', 'minute');
$year_range = !empty($year_range) ? $year_range : '2010:+1';
$input_format = !empty($input_format) ? $input_format : date_default_format($widget_type);
@@ -151,6 +151,123 @@ abstract class DateFieldBasic extends DrupalWebTestCase {
}
/**
* Creates a date field from an array of settings values.
*
* All values have defaults, only need to specify values that need to be
* different.
*/
protected function createMultiDateField($values = array()) {
extract($values);
$field_name = !empty($field_name) ? $field_name : 'field_test';
$entity_type = !empty($entity_type) ? $entity_type : 'node';
$bundle = !empty($bundle) ? $bundle : 'story';
$label = !empty($label) ? $label : 'Test';
$field_type = !empty($field_type) ? $field_type : 'datetime';
$repeat = !empty($repeat) ? $repeat : 0;
$todate = !empty($todate) ? $todate : 'optional';
$widget_type = !empty($widget_type) ? $widget_type : 'date_select';
$this->verbose(!empty($tz_handling));
$tz_handling = !empty($tz_handling) ? $tz_handling : 'site';
$granularity = !empty($granularity) ? $granularity : array('year', 'month', 'day', 'hour', 'minute');
$year_range = !empty($year_range) ? $year_range : '2010:+1';
$input_format = !empty($input_format) ? $input_format : date_default_format($widget_type);
$input_format_custom = !empty($input_format_custom) ? $input_format_custom : '';
$text_parts = !empty($text_parts) ? $text_parts : array();
$increment = !empty($increment) ? $increment : 15;
$default_value = !empty($default_value) ? $default_value : 'now';
$default_value2 = !empty($default_value2) ? $default_value2 : 'blank';
$default_format = !empty($default_format) ? $default_format : 'long';
$cache_enabled = !empty($cache_enabled);
$cache_count = !empty($cache_count) ? $cache_count : 4;
$cardinality = !empty($cardinality) ? $cardinality : 1;
$field = array(
'field_name' => $field_name,
'type' => $field_type,
'cardinality' => $cardinality,
'settings' => array(
'granularity' => $granularity,
'tz_handling' => $tz_handling,
'timezone_db' => date_get_timezone_db($tz_handling),
'repeat' => $repeat,
'todate' => $todate,
'cache_enabled' => $cache_enabled,
'cache_count' => $cache_count,
),
);
$instance = array(
'entity_type' => $entity_type,
'field_name' => $field_name,
'label' => $label,
'bundle' => $bundle,
// Move the date right below the title.
'weight' => -4,
'widget' => array(
'type' => $widget_type,
// Increment for minutes and seconds, can be 1, 5, 10, 15, or 30.
'settings' => array(
'increment' => $increment,
// The number of years to go back and forward in drop-down year
// selectors.
'year_range' => $year_range,
'input_format' => $input_format,
'input_format_custom' => $input_format_custom,
'text_parts' => $text_parts,
'label_position' => 'above',
'repeat_collapsed' => 0,
),
'weight' => -4,
),
'settings' => array(
'default_value' => $default_value,
'default_value2' => $default_value2,
),
);
$instance['display'] = array(
'default' => array(
'label' => 'above',
'type' => 'date_default',
'settings' => array(
'format_type' => $default_format,
'show_repeat_rule' => 'show',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'fromto' => 'both',
),
'module' => 'date',
'weight' => 0 ,
),
'teaser' => array(
'label' => 'above',
'type' => 'date_default',
'weight' => 0,
'settings' => array(
'format_type' => $default_format,
'show_repeat_rule' => 'show',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'fromto' => 'both',
),
'module' => 'date',
),
);
$field = field_create_field($field);
$instance = field_create_instance($instance);
field_info_cache_clear(TRUE);
field_cache_clear(TRUE);
// Look at how the field got configured.
$this->drupalGet("admin/structure/types/manage/$bundle/fields/$field_name");
$this->drupalGet("admin/structure/types/manage/$bundle/display");
}
/**
* @todo.
*/

View File

@@ -50,6 +50,111 @@ class DateTimezoneTestCase extends DateFieldBasic {
}
}
/**
* Validates timezone handling with a multi-value date field.
*/
public function testMultiUserTimezone() {
// Create date fields with combinations of various types and granularity
// using the "Date's Timezone" strategy.
$field_type = 'datetime';
$tz_handling = 'date';
$max_granularity = 'minute';
// Create date field
$field_name = "field_test";
$label = 'Test';
$options = array(
'label' => $label,
'widget_type' => 'date_text',
'field_name' => $field_name,
'field_type' => $field_type,
'input_format' => 'custom',
'input_format_custom' => 'm/d/Y - H:i:s T',
'cardinality' => 3,
'tz_handling' => $tz_handling,
);
$this->createMultiDateField($options);
// Submit a date field form with multiple values
$this->dateMultiValueForm($field_name, $field_type, $max_granularity, $tz_handling);
$this->deleteDateField($label);
}
/**
* Tests the submission of a date field's widget form when using unlimited
* cardinality
*/
public function dateMultiValueForm($field_name, $field_type, $max_granularity, $tz_handling) {
variable_set('date_format_long', 'D, m/d/Y - H:i:s T');
$edit = array();
$should_be = array();
$edit['title'] = $this->randomName(8);
$timezones = array('America/Chicago', 'America/Los_Angeles', 'America/New_York');
switch ($max_granularity) {
case 'hour':
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
$should_be[0] = 'Thu, 10/07/2010 - 10 CDT';
$edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
$should_be[1] = 'Thu, 10/07/2010 - 10 PDT';
$edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
$should_be[2] = 'Thu, 10/07/2010 - 10 EDT';
break;
case 'minute':
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
$should_be[0] = 'Thu, 10/07/2010 - 10:30 CDT';
$edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
$should_be[1] = 'Thu, 10/07/2010 - 10:30 PDT';
$edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
$should_be[2] = 'Thu, 10/07/2010 - 10:30 EDT';
break;
case 'second':
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
$should_be[0] = 'Thu, 10/07/2010 - 10:30:30 CDT';
$edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
$should_be[1] = 'Thu, 10/07/2010 - 10:30:30 PDT';
$edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
$should_be[2] = 'Thu, 10/07/2010 - 10:30:30 EDT';
break;
}
$this->drupalPost('node/add/story', $edit, t('Save'));
$this->assertText($edit['title'], "Node has been created");
foreach ($should_be as $assertion) {
$this->assertText($assertion, "Found the correct date for a $field_type field using $max_granularity granularity with $tz_handling timezone handling.");
}
// Goto the edit page and save the node again.
$node = $this->drupalGetNodeByTitle($edit['title']);
$this->drupalGet('node/' . $node->nid . '/edit');
// Re-assert the proper date timezones.
foreach ($timezones as $key => $timezone) {
$this->assertOptionSelected('edit-field-test-und-' . $key . '-timezone-timezone', $timezone, "Found the correct timezone $timezone for a $field_type field using $max_granularity granularity with $tz_handling timezone handling.");
}
}
/**
* @todo.
*/

View File

@@ -0,0 +1,129 @@
<?php
/**
* @file
* Views date pager test.
*/
class ViewsPagerTestCase extends DrupalWebTestCase {
/**
* Test info.
*/
public static function getInfo() {
return array(
'name' => 'Date views pager skipping test',
'description' => "Views date pager, option to skip empty pages test",
'group' => 'Date',
);
}
/**
* Test setup actions.
*/
public function setUp() {
// Load the 'date_views', 'views', 'views_ui', 'ctools' modules.
parent::setUp('date_views', 'views', 'views_ui', 'ctools');
// Set required permissions.
$permissions = array('administer views', 'administer site configuration');
// Create admin user and login.
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Create a new view for test.
$view = new view();
$view->name = 'test_date_pager';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'test_date_pager';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'test_date_pager';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'date_views_pager';
$handler->display->display_options['pager']['options']['skip_empty_pages'] = 1;
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Date: Date (node) */
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'hour';
$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
'node.created' => 'node.created',
);
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->display->display_options['path'] = 'test_date_pager';
$view->save();
}
/**
* Test pager skipping.
*/
public function testPagerSkipping() {
// Go to view admin page.
$this->drupalGet('admin/structure/views/view/display/test_date_pager/edit');
// Go to pager options.
$this->drupalGet('admin/structure/views/nojs/display/test_date_pager/default/pager_options');
// Check if "Skip empty pages" text - exist.
$this->assertText('Skip empty pages');
// Check if field and it's value is correct.
$this->assertFieldByName('pager_options[skip_empty_pages]', '1');
// Go back to view admin page.
$this->drupalGet('admin/structure/views/view/display/test_date_pager/edit');
// Check if pager on empty page are gone.
$this->assertNoText('« Prev', 'Previous pager does not exist');
$this->assertNoText('Next »', 'Next pager does not exist');
}
/**
* Test the view page has no PHP warnings.
*/
public function testPagerWarning() {
$this->drupalCreateNode(array('type' => 'blog'));
// Set pager to skip empty pages.
$edit = array(
'pager_options[skip_empty_pages]' => FALSE,
);
$this->drupalPost('admin/structure/views/nojs/display/test_date_pager/default/pager_options', $edit, t('Apply'));
// Save the view.
$this->drupalPost('admin/structure/views/view/test_date_pager/edit', array(), t('Save'));
// Visit view page. This will throw error, if any PHP warnings or errors.
$this->drupalGet('test_date_pager');
}
}

View File

@@ -0,0 +1,106 @@
<?php
/**
* @file
* Tests date popup in Views
*/
class DateViewsPopupTestCase extends DateFieldBasic {
/**
* Test info.
*/
public static function getInfo() {
return array(
'name' => 'Date Views - Popup Test',
'description' => 'Tests date popup in Views',
'group' => 'Date',
);
}
/**
* Test setup actions.
*/
public function setUp() {
parent::setUp();
// Load the 'date_popup', 'date_views', 'views', 'views_ui', 'ctools' modules.
$modules = array('date_popup', 'date_views', 'views', 'views_ui', 'ctools');
$success = module_enable($modules, TRUE);
$this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
// Reset/rebuild all data structures after enabling the modules.
$this->resetAll();
// Create a date field.
$field_name = "field_test_date_popup";
$label = 'Test';
$options = array(
'label' => 'Test',
'widget_type' => 'date_popup',
'field_name' => $field_name,
'field_type' => 'datetime',
'input_format' => 'm/d/Y - H:i',
);
$this->createDateField($options);
// Set required permissions.
$permissions = array('administer views', 'administer site configuration');
// Create admin user and login.
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Create the view.
$view = new view();
$view->name = 'test_date_popup';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Test date_popup';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'test_date_popup_page';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Filter criterion: Content: test_date_popup (field_test_date_popup) */
$handler->display->display_options['filters']['field_test_date_popup_value']['id'] = 'field_test_date_popup_value';
$handler->display->display_options['filters']['field_test_date_popup_value']['table'] = 'field_data_field_test_date_popup';
$handler->display->display_options['filters']['field_test_date_popup_value']['field'] = 'field_test_date_popup_value';
$handler->display->display_options['filters']['field_test_date_popup_value']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator_id'] = 'field_test_date_popup_value_op';
$handler->display->display_options['filters']['field_test_date_popup_value']['expose']['label'] = 'test_date_popup (field_test_date_popup)';
$handler->display->display_options['filters']['field_test_date_popup_value']['expose']['operator'] = 'field_test_date_popup_value_op';
$handler->display->display_options['filters']['field_test_date_popup_value']['expose']['identifier'] = 'field_test_date_popup_value';
$handler->display->display_options['filters']['field_test_date_popup_value']['form_type'] = 'date_popup';
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'test-date-popup';
$view->save();
}
/**
* Test date popup.
*/
public function testDatePopup() {
// Go to view page.
$this->drupalGet('test-date-popup');
}
}