security updates
have to check views and entityreference for custom patches
This commit is contained in:
@@ -5,8 +5,7 @@
|
||||
* Test date UI.
|
||||
*/
|
||||
|
||||
class DateUITestCase extends DrupalWebTestCase {
|
||||
protected $privileged_user;
|
||||
class DateUITestCase extends DateFieldBasic {
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
@@ -23,14 +22,7 @@ class DateUITestCase extends DrupalWebTestCase {
|
||||
* @todo.
|
||||
*/
|
||||
public function setUp() {
|
||||
// Load the date_api module.
|
||||
parent::setUp('field', 'field_ui', 'date_api', 'date', 'date_popup', 'date_tools');
|
||||
|
||||
// Create and log in our privileged user.
|
||||
$this->privileged_user = $this->drupalCreateUser(
|
||||
array('administer content types', 'administer nodes', 'bypass node access', 'administer date tools')
|
||||
);
|
||||
$this->drupalLogin($this->privileged_user);
|
||||
parent::setUp();
|
||||
|
||||
variable_set('date_format_long', 'D, m/d/Y - H:i');
|
||||
}
|
||||
@@ -39,82 +31,34 @@ class DateUITestCase extends DrupalWebTestCase {
|
||||
* @todo.
|
||||
*/
|
||||
public function testFieldUI() {
|
||||
$edit = array();
|
||||
$edit['name'] = 'Story';
|
||||
$edit['type'] = 'story';
|
||||
$this->drupalPost('admin/structure/types/add', $edit, t('Save content type'));
|
||||
$this->assertText('The content type Story has been added.', 'Content type added.');
|
||||
$label = 'Test';
|
||||
$current_year = date('Y');
|
||||
|
||||
// Creates select list field stored as a date with default settings.
|
||||
$this->createDateField($type = 'date', $widget = 'date_select');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'select');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a date field using the date_select widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates text field stored as a date with default settings.
|
||||
$this->createDateField($type = 'date', $widget = 'date_text');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'text');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a date field using the date_text widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates popup field stored as a date with default settings.
|
||||
$this->createDateField($type = 'date', $widget = 'date_popup');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'popup');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a date field using the date_popup widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates select list field stored as a datestamp with default settings.
|
||||
$this->createDateField($type = 'datestamp', $widget = 'date_select');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'select');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datestamp field using the date_select widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates text field stored as a datestamp with default settings.
|
||||
$this->createDateField($type = 'datestamp', $widget = 'date_text');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'text');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datestamp field using the date_text widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates popup field stored as a datestamp with default settings.
|
||||
$this->createDateField($type = 'datestamp', $widget = 'date_popup');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'popup');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datestamp field using the date_popup widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates select list field stored as a datetime with default settings.
|
||||
$this->createDateField($type = 'datetime', $widget = 'date_select');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'select');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datetime field using the date_select widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates text field stored as a datetime with default settings.
|
||||
$this->createDateField($type = 'datetime', $widget = 'date_text');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'text');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datetime field using the date_text widget.');
|
||||
$this->deleteDateField();
|
||||
// Creates popup field stored as a datetime with default settings.
|
||||
$this->createDateField($type = 'datetime', $widget = 'date_popup');
|
||||
$edit = array();
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->dateForm($options = 'popup');
|
||||
$this->assertText('Thu, 10/07/2010 - 10:30', 'Found the correct date for a datetime field using the date_popup widget.');
|
||||
$this->deleteDateField();
|
||||
$field_types = array('date', 'datestamp', 'datetime');
|
||||
$widget_types = array('date_select', 'date_text', 'date_popup');
|
||||
|
||||
// Test widgets with default settings using every widget and field type.
|
||||
foreach ($field_types as $field_type) {
|
||||
foreach ($widget_types as $widget_type) {
|
||||
$this->createDateField(
|
||||
array(
|
||||
'label' => $label,
|
||||
'field_type' => $field_type,
|
||||
'widget_type' => $widget_type,
|
||||
)
|
||||
);
|
||||
$this->dateForm($widget_type);
|
||||
$this->assertText(format_string('10/07/!year - 10:30', array('!year' => $current_year)), 'Found the correct date for a date field using the ' . $widget_type . ' widget.');
|
||||
$this->deleteDateField($label);
|
||||
}
|
||||
}
|
||||
|
||||
// Test timezone handling validation on the field settings form.
|
||||
$this->createDateField($type = 'date', $widget = 'date_select');
|
||||
$this->createDateField(array('label' => $label, 'field_type' => 'date', 'widget_type' => 'date_select', 'granularity' => array('year', 'month', 'day')));
|
||||
$edit = array('field[settings][granularity][hour]' => FALSE);
|
||||
$this->drupalPost(NULL, $edit, t('Save field settings'));
|
||||
$this->drupalPost('admin/structure/types/manage/story/fields/field_' . strtolower($label), $edit, t('Save settings'));
|
||||
$this->assertText("Dates without hours granularity must not use any timezone handling.", "Dates without hours granularity required to use timezone handling of 'none.'");
|
||||
$this->deleteDateField();
|
||||
$this->deleteDateField($label);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,44 +69,23 @@ class DateUITestCase extends DrupalWebTestCase {
|
||||
$edit = array();
|
||||
$edit['title'] = $this->randomName(8);
|
||||
$edit['body[und][0][value]'] = $this->randomName(16);
|
||||
if ($options == 'select') {
|
||||
$edit['field_test[und][0][value][year]'] = '2010';
|
||||
$current_year = date('Y');
|
||||
|
||||
if ($options == 'date_select') {
|
||||
$edit['field_test[und][0][value][year]'] = $current_year;
|
||||
$edit['field_test[und][0][value][month]'] = '10';
|
||||
$edit['field_test[und][0][value][day]'] = '7';
|
||||
$edit['field_test[und][0][value][hour]'] = '10';
|
||||
$edit['field_test[und][0][value][minute]'] = '30';
|
||||
}
|
||||
elseif ($options == 'text') {
|
||||
$edit['field_test[und][0][value][date]'] = '10/07/2010 - 10:30';
|
||||
elseif ($options == 'date_text') {
|
||||
$edit['field_test[und][0][value][date]'] = format_string('10/07/!year - 10:30', array('!year' => $current_year));
|
||||
}
|
||||
elseif ($options == 'popup') {
|
||||
$edit['field_test[und][0][value][date]'] = '10/07/2010';
|
||||
elseif ($options == 'date_popup') {
|
||||
$edit['field_test[und][0][value][date]'] = format_string('10/07/!year', array('!year' => $current_year));
|
||||
$edit['field_test[und][0][value][time]'] = '10:30';
|
||||
}
|
||||
$this->drupalPost('node/add/story', $edit, t('Save'));
|
||||
$this->assertText($edit['body[und][0][value]'], 'Test node has been created');
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*/
|
||||
function createDateField($type, $widget) {
|
||||
$edit = array();
|
||||
$edit['fields[_add_new_field][label]'] = 'Test';
|
||||
$edit['fields[_add_new_field][field_name]'] = 'test';
|
||||
$edit['fields[_add_new_field][weight]'] = '-4';
|
||||
$edit['fields[_add_new_field][type]'] = $type;
|
||||
$edit['fields[_add_new_field][widget_type]'] = $widget;
|
||||
$this->drupalPost('admin/structure/types/manage/story/fields', $edit, t('Save'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*/
|
||||
function deleteDateField() {
|
||||
$this->drupalGet('admin/structure/types/manage/story/fields');
|
||||
$this->clickLink('delete');
|
||||
$this->drupalPost(NULL, NULL, t('Delete'));
|
||||
$this->assertText('The field Test has been deleted from the Story content type.', 'Removed date field.');
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test for using date fields with Migrate module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test date migration.
|
||||
*/
|
||||
class DateMigrateExampleUnitTest extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* Provides information about this test.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Date Migration',
|
||||
'description' => 'Test migration into date fields',
|
||||
'group' => 'Date',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Declars the module dependencies for the test.
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp('migrate', 'features', 'date', 'date_repeat',
|
||||
'date_repeat_field', 'date_migrate_example');
|
||||
// Make sure the migration is registered.
|
||||
if (function_exists('migrate_static_registration')) {
|
||||
// Migrate 2.6 and later
|
||||
migrate_static_registration();
|
||||
}
|
||||
else {
|
||||
// Migrate 2.5 and earlier
|
||||
migrate_get_module_apis(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that date fields are imported correctly. When no timezone is
|
||||
* explicitly provided with the source data, we want the displayed time on the
|
||||
* Drupal site to match that in the source data. To validate that, we make
|
||||
* sure we have set a consistent timezone at the PHP and Drupal levels, and
|
||||
* that the format used on the page is not locale-dependent (no day or month
|
||||
* names). Then, we can just look for the desired date/time strings in the
|
||||
* node page.
|
||||
*/
|
||||
function testDateImport() {
|
||||
date_default_timezone_set('America/Los_Angeles');
|
||||
variable_set('date_default_timezone', 'America/Los_Angeles');
|
||||
variable_set('date_format_medium', 'Y-m-d H:i');
|
||||
$migration = Migration::getInstance('DateExample');
|
||||
$result = $migration->processImport();
|
||||
$this->assertEqual($result, Migration::RESULT_COMPLETED, t('Variety term import returned RESULT_COMPLETED'));
|
||||
$rawnodes = node_load_multiple(FALSE, array('type' => 'date_migrate_example'), TRUE);
|
||||
$this->assertEqual(count($rawnodes), 2, t('Two sample nodes created'));
|
||||
$node = reset($rawnodes);
|
||||
$this->drupalGet('/node/' . $node->nid);
|
||||
$this->assertText('2011-05-12 19:43', t('Simple date field found'));
|
||||
$this->assertText('2011-06-13 18:32 to 2011-07-23 10:32', t('Date range field found'));
|
||||
$this->assertText('2011-07-22 12:13', t('Datestamp field found'));
|
||||
$this->assertText('2011-08-01 00:00 to 2011-09-01 00:00', t('Datestamp range field found'));
|
||||
$this->assertText('2011-11-18 15:00', t('Datetime field with +9 timezone found'));
|
||||
$this->assertText('2011-10-30 14:43 to 2011-12-31 17:59', t('Datetime range field with -5 timezone found'));
|
||||
$this->assertText('2011-11-25 09:01', t('First date repeat instance found'));
|
||||
$this->assertText('2011-12-09 09:01', t('Second date repeat instance found'));
|
||||
$this->assertNoText('2011-12-23 09:01', t('Skipped date repeat instance not found'));
|
||||
$this->assertText('2012-05-11 09:01', t('Last date repeat instance found'));
|
||||
$node = next($rawnodes);
|
||||
$this->drupalGet('/node/' . $node->nid);
|
||||
$this->assertText('2012-06-21 15:32', t('First date value found'));
|
||||
$this->assertText('2012-12-02 11:08', t('Second date value found'));
|
||||
$this->assertText('2004-02-03 01:15', t('Start for first date range found'));
|
||||
$this->assertText('2005-03-04 22:11', t('End for first date range found'));
|
||||
$this->assertText('2014-09-01 17:21', t('Start for second date range found'));
|
||||
$this->assertText('2015-12-23 00:01', t('End for first second range found'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user