public function BlockedIpsExpireBulkAssign::testBulkAssignPage in Blocked IPs Expire 7
Tests that the bulk assign page works.
File
- tests/
blocked_ips_expire.bulk_assign.test, line 104 - Contains \BlockedIpsExpireBulkAssign.
Class
- BlockedIpsExpireBulkAssign
- Tests that IPs without expiry dates can be fixed.
Code
public function testBulkAssignPage() {
// Create an admin and log in.
$admin_user = $this
->drupalCreateUser(array(
'block IP addresses',
));
$this
->drupalLogin($admin_user);
// Test the bulk-assignment page correctly reports when no IP addresses need
// expiry dates.
$this
->drupalGet('admin/config/people/blocked_ips_expire/bulk_assign');
$this
->assertText(t('No IP addresses need expiry dates.'), 'Bulk-assignment page correctly reports when no IP addresses need expiry dates.');
// Add two IP addresses, one with an expiry date, and one without.
BlockedIpsExpireBulkAssign::addIpWithoutExpiryTime($this->ipWithoutExpiry);
_blocked_ips_expire_add_ip($this->ipWithExpiry, $this->ipWithExpiryExpiryDate);
// Test the form correctly reports there are IPs needing expiry dates.
$this
->drupalGet('admin/config/people/blocked_ips_expire/bulk_assign');
$this
->assertText(t('The following IP addresses have not been assigned expiry dates'), 'Bulk-assignment page correctly reports that there are IP addresses without expiry dates.');
$this
->assertText($this->ipWithoutExpiry, 'Bulk-assignment page correctly lists the IP that is missing an expiry date.');
$this
->assertNoText($this->ipWithExpiry, 'Bulk-assignment page does not list the IP that does have an expiry date.');
}