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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
### make sure we can find our conf.pl file
BEGIN {
use FindBin;
require "$FindBin::Bin/inc/conf.pl";
}
use strict;
use Test::More 'no_plan';
use Data::Dumper;
use CPANPLUS::Backend;
use CPANPLUS::Internals::Constants;
my $Conf = gimme_conf();
my $CB = CPANPLUS::Backend->new($Conf);
my $ModName = TEST_CONF_MODULE;
my $Mod = $CB->module_tree( $ModName );
### search for modules ###
for my $type ( CPANPLUS::Module->accessors() ) {
### don't muck around with references/objects
### or private identifiers
next if ref $Mod->$type() or $type =~/^_/;
my @aref = $CB->search(
type => $type,
allow => [$Mod->$type()],
);
ok( scalar @aref, "Module found by '$type'" );
for( @aref ) {
ok( IS_MODOBJ->($_)," Module isa module object" );
}
}
### search for authors ###
my $auth = $Mod->author;
for my $type ( CPANPLUS::Module::Author->accessors() ) {
### don't muck around with references/objects
### or private identifiers
next if ref $auth->$type() or $type =~/^_/;
my @aref = $CB->search(
type => $type,
allow => [$auth->$type()],
);
ok( @aref, "Author found by '$type'" );
for( @aref ) {
ok( IS_AUTHOBJ->($_), " Author isa author object" );
}
}
{ my $warning = '';
local $SIG{__WARN__} = sub { $warning .= "@_"; };
{ ### try search that will yield nothing ###
### XXX SOURCEFILES FIX
my @list = $CB->search( type => 'module',
allow => [$ModName.$$] );
is( scalar(@list), 0, "Valid search yields no results" );
is( $warning, '', " No warnings issued" );
}
{ ### try bogus arguments ###
my @list = $CB->search( type => '', allow => ['foo'] );
is( scalar(@list), 0, "Broken search yields no results" );
like( $warning, qr/^Key 'type'.* is of invalid type for/,
" Got a warning for wrong arguments" );
}
}
# Local variables:
# c-indentation-style: bsd
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
# vim: expandtab shiftwidth=4:
|