The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
use strict;
use warnings;
use Test::RequiresInternet 'test.wikipedia.org' => 80;
use Test::More tests => 6;
use Test::Warn;

use MediaWiki::Bot;
my $t = __FILE__;

my $bot = MediaWiki::Bot->new({
    agent   => "MediaWiki::Bot tests (https://metacpan.org/MediaWiki::Bot; $t)",
    host    => 'test.wikipedia.org',
});

{
    # Jimbo is almost certainly not blocked right now
    my $result = $bot->is_blocked('Jimbo Wales');
    my $bc;
    warning_is(
        sub { $bc = $bot->test_blocked('User:Jimbo Wales'); },
        'test_blocked is an alias of is_blocked; please use the new name. This alias might be removed in a future release',
        'test_blocked is deprecated'
    );
    ok(!$result,     'current blocks');
    is($result, $bc,    'BC method returned the same as the current method');
}

{
    # A random old account I chose - it will probably be blocked forever
    # (del/undel) 21:48, July 26, 2008 Cometstyles (talk | contribs | block) blocked Hiwhispees (talk | contribs) with an expiry time of infinite (account creation disabled, e-mail blocked) ‎ (bye grawp) (unblock | change block)
    my $result = $bot->is_blocked('User:Hiwhispees~testwiki');
    my $bc;
    warning_is(
        sub { $bc = $bot->test_blocked('Hiwhispees~testwiki'); },
        'test_blocked is an alias of is_blocked; please use the new name. This alias might be removed in a future release',
        'test_blocked is deprecated'
    );
    ok($result,         'current blocks');
    is($result, $bc,    'BC method returned the same as the current method');
}