File: 20.search.t

package info (click to toggle)
libwww-wikipedia-perl 2.05-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 248 kB
  • sloc: perl: 1,577; makefile: 4
file content (38 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use strict;
use warnings;

use Test::More tests => 7;

use WWW::Wikipedia;

my ( $wiki, $testexception );

BEGIN {
    eval "use Test::Exception";
    $testexception = $@ ? 0 : 1;
}

# test default language
$wiki = WWW::Wikipedia->new();
isa_ok( $wiki, 'WWW::Wikipedia' );

SKIP: {
    skip 'Test::Exception not installed', 1 unless $testexception;

    throws_ok { $wiki->search(); }
    qr/search\(\) requires you pass in a string/, 'search()';
}

my $entry = $wiki->search( 'perl' );
isa_ok( $entry, 'WWW::Wikipedia::Entry' );
ok( length( $entry->text() ) > 0, 'text()' );

# test language 'es'
$wiki = WWW::Wikipedia->new( language => 'es' );
isa_ok( $wiki, 'WWW::Wikipedia' );

$entry = $wiki->search( 'perl' );
isa_ok( $entry, 'WWW::Wikipedia::Entry' );

ok( length( $entry->fulltext() ) > 0, 'fulltext()' );