1 | use strict; |
---|
2 | use Wiki::Toolkit::Plugin::Categoriser; |
---|
3 | use Wiki::Toolkit::TestLib; |
---|
4 | use Test::More; |
---|
5 | |
---|
6 | my $iterator = Wiki::Toolkit::TestLib->new_wiki_maker; |
---|
7 | if ( $iterator->number ) { |
---|
8 | plan tests => ( $iterator->number * 1 ); |
---|
9 | } else { |
---|
10 | plan skip_all => "No backends configured."; |
---|
11 | } |
---|
12 | |
---|
13 | while ( my $wiki = $iterator->new_wiki ) { |
---|
14 | print "#\n##### TEST CONFIG: Store: " . (ref $wiki->store) . "\n"; |
---|
15 | |
---|
16 | my $categoriser = Wiki::Toolkit::Plugin::Categoriser->new; |
---|
17 | $wiki->register_plugin( plugin => $categoriser ); |
---|
18 | |
---|
19 | $wiki->write_node( "Pub Food", "pubs that serve food", undef, |
---|
20 | { category => [ "Pubs", "Food", "Category" ] } ) |
---|
21 | or die "Can't write node"; |
---|
22 | |
---|
23 | $wiki->write_node( "Restaurants", "places that serve food", undef, |
---|
24 | { category => [ "Food", "Category" ] } ) |
---|
25 | or die "Can't write node"; |
---|
26 | |
---|
27 | my @subcategories = $categoriser->subcategories( category => "Pubs" ); |
---|
28 | is_deeply( \@subcategories, [ "Pub Food" ], |
---|
29 | "->subcategories returns things that belong, and not things that don't" ); |
---|
30 | } |
---|