You are here

public function BlockedIpsExpireBulkAssign::testBulkAssignSetsUserSpecifiedExpiryDates in Blocked IPs Expire 7

Tests that the bulk assign form sets expiry dates as-specified by the user.

File

tests/blocked_ips_expire.bulk_assign.test, line 136
Contains \BlockedIpsExpireBulkAssign.

Class

BlockedIpsExpireBulkAssign
Tests that IPs without expiry dates can be fixed.

Code

public function testBulkAssignSetsUserSpecifiedExpiryDates() {
  $specific_date = '2014-09-27 13:41:13 +0000';

  // Create an admin and log in.
  $admin_user = $this
    ->drupalCreateUser(array(
    'block IP addresses',
  ));
  $this
    ->drupalLogin($admin_user);

  // Enter a specific date on the bulk-assignment page and try to run it.
  $iid = BlockedIpsExpireBulkAssign::addIpWithoutExpiryTime($this->ipWithoutExpiry);
  $this
    ->drupalPost('admin/config/people/blocked_ips_expire/bulk_assign', array(
    'bulk_assign_new_date' => $specific_date,
  ), t('Assign new expiry date to all IP addresses without one already'));
  $this
    ->assertText(t('Assigned the date @date to', array(
    '@date' => format_date(strtotime($specific_date)),
  )));

  // Test the IP we added has the new date.
  $ip_info = _blocked_ips_expire_get_one($iid);
  $this
    ->assertEqual($ip_info->expiry_date, strtotime($specific_date), 'Specific date assigned correctly.');
}