source: wiki-toolkit-plugin-categoriser/trunk/t/categoriser.t @ 261

Last change on this file since 261 was 261, checked in by Dominic Hargreaves, 15 years ago

More renames.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1use strict;
2use Wiki::Toolkit::TestLib;
3use Test::More;
4
5my $iterator = Wiki::Toolkit::TestLib->new_wiki_maker;
6plan tests => ( 1 + $iterator->number * 6 );
7
8use_ok( "Wiki::Toolkit::Plugin::Categoriser" );
9
10while ( my $wiki = $iterator->new_wiki ) {
11    print "#\n##### TEST CONFIG: Store: " . (ref $wiki->store) . "\n";
12
13    my $categoriser = eval { Wiki::Toolkit::Plugin::Categoriser->new; };
14    is( $@, "", "'new' doesn't croak" );
15    isa_ok( $categoriser, "Wiki::Toolkit::Plugin::Categoriser" );
16    $wiki->register_plugin( plugin => $categoriser );
17
18    $wiki->write_node( "Calthorpe Arms", "beer", undef,
19                         { category => [ "Pubs", "Pub Food" ] } )
20      or die "Can't write node";
21    $wiki->write_node( "Albion", "pub", undef,
22                         { category => [ "Pubs", "Pub Food" ] } )
23      or die "Can't write node";
24    $wiki->write_node( "Ken Livingstone", "Congestion charge hero", undef,
25                       { category => [ "People" ] } )
26      or die "Can't write node";
27
28    # Test ->in_category
29    my $isa_pub = $categoriser->in_category( category => "Pubs",
30                                             node     => "Albion" );
31    ok( $isa_pub, "in_category returns true for things in the category" );
32    $isa_pub = $categoriser->in_category( category => "Pubs",
33                                          node     => "Ken Livingstone" );
34    ok( !$isa_pub, "...and false for things not in the category" );
35
36    $isa_pub = $categoriser->in_category( category => "pubs",
37                                          node     => "Albion" );
38    ok( $isa_pub, "...and is case-insensitive" );
39
40    # Test ->categories
41    my @categories = $categoriser->categories( node => "Calthorpe Arms" );
42    is_deeply( [ sort @categories ], [ "Pub Food", "Pubs" ],
43               "...->categories returns all categories" );
44}
Note: See TracBrowser for help on using the repository browser.