Bump two module versions after Haiku port
[p5sagit/p5-mst-13.2.git] / lib / CPANPLUS / t / 09_CPANPLUS-Internals-Search.t
1 ### make sure we can find our conf.pl file
2 BEGIN { 
3     use FindBin; 
4     require "$FindBin::Bin/inc/conf.pl";
5 }
6
7 use strict;
8 use Test::More 'no_plan';
9 use Data::Dumper;
10 use CPANPLUS::Backend;
11 use CPANPLUS::Internals::Constants;
12
13 my $Conf    = gimme_conf();
14 my $CB      = CPANPLUS::Backend->new($Conf);
15 my $ModName = TEST_CONF_MODULE;
16 my $Mod     = $CB->module_tree( $ModName );
17
18
19 ### search for modules ###
20 for my $type ( CPANPLUS::Module->accessors() ) {
21
22     ### don't muck around with references/objects
23     ### or private identifiers
24     next if ref $Mod->$type() or $type =~/^_/;
25
26     my @aref = $CB->search(
27                     type    => $type,
28                     allow   => [$Mod->$type()],
29                 );
30
31     ok( scalar @aref,       "Module found by '$type'" );
32     for( @aref ) {
33         ok( IS_MODOBJ->($_),"   Module isa module object" );
34     }
35 }
36
37 ### search for authors ###
38 my $auth = $Mod->author;
39 for my $type ( CPANPLUS::Module::Author->accessors() ) {
40     my @aref = $CB->search(
41                     type    => $type,
42                     allow   => [$auth->$type()],
43                 );
44
45     ok( @aref,                  "Author found by '$type'" );
46     for( @aref ) {
47         ok( IS_AUTHOBJ->($_),   "   Author isa author object" );
48     }
49 }
50
51
52 {   my $warning = '';
53     local $SIG{__WARN__} = sub { $warning .= "@_"; };
54
55     {   ### try search that will yield nothing ###
56         ### XXX SOURCEFILES FIX
57         my @list = $CB->search( type    => 'module',
58                                 allow   => [$ModName.$$] );
59
60         is( scalar(@list), 0,   "Valid search yields no results" );
61         is( $warning, '',       "   No warnings issued" );
62     }
63
64     {   ### try bogus arguments ###
65         my @list = $CB->search( type => '', allow => ['foo'] );
66
67         is( scalar(@list), 0,   "Broken search yields no results" );
68         like( $warning, qr/^Key 'type'.* is of invalid type for/,
69                                 "   Got a warning for wrong arguments" );
70     }
71 }
72
73 # Local variables:
74 # c-indentation-style: bsd
75 # c-basic-offset: 4
76 # indent-tabs-mode: nil
77 # End:
78 # vim: expandtab shiftwidth=4: