Debian Codegraph @

t/10-what_links_here.t

raw symbols SCIP
1 use strictscip-perl cpan MediaWiki-Bot 5.007000 strict/;
2 use warningsscip-perl cpan MediaWiki-Bot 5.007000 warnings/;
3 use Test::RequiresInternetscip-perl cpan MediaWiki-Bot 5.007000 Test/RequiresInternet/ 'test.wikipedia.org' => 80;
4 use Test::Morescip-perl cpan MediaWiki-Bot 5.007000 Test/More/ tests => 7;
5
6 use MediaWiki::Botscip-perl cpan MediaWiki-Bot 5.007000 MediaWiki/Bot/;
7 my $t = __FILE__scip-perl cpan MediaWiki-Bot 5.007000 main/__FILE__().;
8
9 my $bot = MediaWiki::Bot->newscip-perl cpan MediaWiki-Bot 5.007000 MediaWiki/Bot/new().({
10 agent => "MediaWiki::Bot tests (https://metacpan.org/MediaWiki::Bot; $t)",
11 host => 'test.wikipedia.org',
12 });
13
14 my @pages = $bot->what_links_herescip-perl cpan MediaWiki-Bot 5.007000 MediaWiki/Bot/what_links_here().('Main Page', 'redirects', undef, {max=>1});
15
16 okscip-perl cpan MediaWiki-Bot 5.007000 main/ok().( definedscip-perl cpan MediaWiki-Bot 5.007000 main/defined(). $pages[0], 'Something was returned');
17 isa_okscip-perl cpan MediaWiki-Bot 5.007000 main/isa_ok().( $pages[0], 'HASH', 'A hash was returned');
18 okscip-perl cpan MediaWiki-Bot 5.007000 main/ok().( definedscip-perl cpan MediaWiki-Bot 5.007000 main/defined(). $pages[0]->{'title'}, 'The hash contains a title');
19 likescip-perl cpan MediaWiki-Bot 5.007000 main/like().( $pages[0]->{'title'}, qr/\w+/, 'The title looks valid');
20 okscip-perl cpan MediaWiki-Bot 5.007000 main/ok().( definedscip-perl cpan MediaWiki-Bot 5.007000 main/defined(). $pages[0]->{'redirect'}, 'Redirect status is defined');
21 okscip-perl cpan MediaWiki-Bot 5.007000 main/ok().( definedscip-perl cpan MediaWiki-Bot 5.007000 main/defined().($pages[0]->{'redirect'}), 'We got a redirect when we asked for it');
22
23 $bot->what_links_herescip-perl cpan MediaWiki-Bot 5.007000 MediaWiki/Bot/what_links_here().('Project:Sandbox', 'nonredirects', 0, {max => 1, hook => \&mysubscip-perl cpan MediaWiki-Bot 5.007000 main/mysub().});
24 my $is_redir;
25 sub mysubscip-perl cpan MediaWiki-Bot 5.007000 main/mysub(). {
26 my ($res) = @_scip-perl cpan MediaWiki-Bot 5.007000 main/`@_`.;
27 my $hash = $res->[0];
28 $is_redir = $hash->{'redirect'};
29 }
30 isntscip-perl cpan MediaWiki-Bot 5.007000 main/isnt().( $is_redir, 'We got a normal link when we asked for no redirects');