/tags/3.2/t/41_test_image_exists.t

http://perlwikipedia.googlecode.com/ · Raku · 28 lines · 16 code · 8 blank · 4 comment · 0 complexity · 03ae1d29749437aa2f2908ae8af7b5a2 MD5 · raw file

  1. # Before `make install' is performed this script should be runnable with
  2. # `make test'. After `make install' it should work as `perl MediaWiki::Bot.t'
  3. #########################
  4. use strict;
  5. use warnings;
  6. use Test::More tests => 4;
  7. #########################
  8. use MediaWiki::Bot;
  9. my $bot = MediaWiki::Bot->new({
  10. agent => 'MediaWiki::Bot tests (41_test_image_exists.t)',
  11. });
  12. my @images = ( 'File:D2c6ac30964d4348d1a2b3ff7e97fa08.png',
  13. 'File:Windows 7.png',
  14. 'File:Albert Einstein Head.jpg', );
  15. is($bot->test_image_exists($images[0]), 0, 'Nonexistent image not found');
  16. is($bot->test_image_exists($images[1]), 1, 'Image is local');
  17. is($bot->test_image_exists($images[2]), 2, 'Image is on Commons');
  18. my $is = $bot->test_image_exists(\@images);
  19. my $ought = [0, 1, 2];
  20. is_deeply($is, $ought, 'Multiple images checked OK');