public function BlockedIpsExpireUi::testModifiedSystemBlockedIpsUi in Blocked IPs Expire 7
Test that the module modified the blocked IPs output as expected.
File
- tests/
blocked_ips_expire.ui.test, line 65 - Contains \BlockedIpsExpireUi.
Class
- BlockedIpsExpireUi
- Tests that the module correctly modifies the system module blocking UI.
Code
public function testModifiedSystemBlockedIpsUi() {
// Add an IP address without an expiry date and test that the UI displays
// "Not set".
$ip_without_expiry = BlockedIpsExpireBulkAssign::addIpWithoutExpiryTime(BlockedIpsExpireBulkAssign::generateIpAddress());
$this
->drupalGet('admin/config/people/ip-blocking');
$this
->assertText('Expiry dates', 'System blocked IPs page displays the Expiry dates column.');
$this
->assertText('Not set', 'System blocked IPs page displays "Not set" when there is a blocked IP without an expiry date.');
_blocked_ips_expire_delete_ip($ip_without_expiry);
$this
->assertText('The total number of blocked IPs is: 1', 'System blocked IPs page successfully displays the number of blocked IPs.');
// Add an IP address with an expiry date.
$expiry_date = BlockedIpsExpireBulkAssign::randomDatetimeInFuture();
_blocked_ips_expire_add_ip(BlockedIpsExpireBulkAssign::generateIpAddress(), $expiry_date);
$this
->drupalGet('admin/config/people/ip-blocking');
$this
->assertText('Expiry dates', 'System blocked IPs page displays the Expiry dates column.');
$this
->assertText(format_date($expiry_date), 'System blocked IPs page displays the expiry date when there is a blocked IP with an expiry date.');
$this
->assertText('The total number of blocked IPs is: 1', 'System blocked IPs page successfully displays the number of blocked IPs.');
}