public function DateRestrictionsHostEntityMinMaxTestCase::_testIntervalGreaterThanMax in Date Restrictions 7
File
- modules/
minmax/ tests/ date_restrictions_minmax_host_entity.test, line 169 - Tests for date_restrictions_minmax.module.
Class
- DateRestrictionsHostEntityMinMaxTestCase
- Tests for host_entity based relative/fixed minmax restrictions.
Code
public function _testIntervalGreaterThanMax($context) {
$now = $this
->newDateObject('now', NULL, FALSE);
$date = clone $now;
$date
->modify('+ 2 days');
$start = array(
'year' => $date
->format('Y'),
'month' => $date
->format('n'),
'day' => $date
->format('d'),
);
// Prepare the value for the host entity interval field.
$edit = array();
$interval = array(
'interval' => 1,
'period' => 'day',
);
$edit['field_host_entity_interval[und][0][interval]'] = $interval['interval'];
$edit['field_host_entity_interval[und][0][period]'] = $interval['period'];
$this
->postNode($context['field_name'], $context['field_type'], $context['widget_type'], $start, NULL, $edit);
$date = clone $now;
interval_apply_interval($date, $interval);
$message = t('Dates after @date are not allowed', array(
'@date' => $date
->format($this->date_input_format),
));
$this
->assertText($message, 'Dates after max interval are not allowed (host entity).');
}