Changeset 179


Ignore:
Timestamp:
Dec 15, 2004, 11:48:15 AM (16 years ago)
Author:
kake
Message:

Modernised tests.

Location:
cgi-wiki-plugin-categoriser/trunk
Files:
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • cgi-wiki-plugin-categoriser/trunk/Changes

    r178 r179  
     10.03
     2        Updated tests.
     3
    140.02    23 June 2003
    25        Made a start at subcategory support.
  • cgi-wiki-plugin-categoriser/trunk/MANIFEST

    r178 r179  
    44README
    55lib/CGI/Wiki/Plugin/Categoriser.pm
    6 t/00_setup.t
    7 t/01_add_test_data.t
    86t/categoriser.t
    97t/nested_categories.t
  • cgi-wiki-plugin-categoriser/trunk/Makefile.PL

    r174 r179  
    22WriteMakefile( NAME         => "CGI::Wiki::Plugin::Categoriser",
    33               VERSION_FROM => "lib/CGI/Wiki/Plugin/Categoriser.pm",
    4                PREREQ_PM    => { 'CGI::Wiki' => 0.36, # for Plugin base class
     4               PREREQ_PM    => { 'CGI::Wiki' => 0.53, # for testlib fixes
    55                                 'Test::More' => 0,
    66                                 'Carp' => 0
  • cgi-wiki-plugin-categoriser/trunk/lib/CGI/Wiki/Plugin/Categoriser.pm

    r178 r179  
    44
    55use vars qw( $VERSION @ISA );
    6 $VERSION = '0.02';
     6$VERSION = '0.03';
    77@ISA = qw( CGI::Wiki::Plugin );
    88
  • cgi-wiki-plugin-categoriser/trunk/t/categoriser.t

    r178 r179  
    11use strict;
    2 use CGI::Wiki;
    3 use CGI::Wiki::TestConfig::Utilities;
    4 use Test::More tests =>
    5   (1 + 6 * $CGI::Wiki::TestConfig::Utilities::num_stores);
     2use CGI::Wiki::TestLib;
     3use Test::More;
     4
     5my $iterator = CGI::Wiki::TestLib->new_wiki_maker;
     6plan tests => ( 1 + $iterator->number * 6 );
    67
    78use_ok( "CGI::Wiki::Plugin::Categoriser" );
    89
    9 my %stores = CGI::Wiki::TestConfig::Utilities->stores;
     10while ( my $wiki = $iterator->new_wiki ) {
     11    print "#\n##### TEST CONFIG: Store: " . (ref $wiki->store) . "\n";
    1012
    11 my ($store_name, $store);
    12 while ( ($store_name, $store) = each %stores ) {
    13     SKIP: {
    14       skip "$store_name storage backend not configured for testing", 6
    15           unless $store;
     13    my $categoriser = eval { CGI::Wiki::Plugin::Categoriser->new; };
     14    is( $@, "", "'new' doesn't croak" );
     15    isa_ok( $categoriser, "CGI::Wiki::Plugin::Categoriser" );
     16    $wiki->register_plugin( plugin => $categoriser );
    1617
    17       print "#\n##### TEST CONFIG: Store: $store_name\n#\n";
     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";
    1827
    19       my $wiki = CGI::Wiki->new( store => $store );
    20       my $categoriser = eval { CGI::Wiki::Plugin::Categoriser->new; };
    21       is( $@, "", "'new' doesn't croak" );
    22       isa_ok( $categoriser, "CGI::Wiki::Plugin::Categoriser" );
    23       $wiki->register_plugin( plugin => $categoriser );
     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" );
    2435
    25       # Test ->in_category
    26       my $isa_pub = $categoriser->in_category( category => "Pubs",
    27                                                node     => "Albion" );
    28       ok( $isa_pub, "in_category returns true for things in the category" );
    29       $isa_pub = $categoriser->in_category( category => "Pubs",
    30                                             node     => "Ken Livingstone" );
    31       ok( !$isa_pub, "...and false for things not in the category" );
     36    $isa_pub = $categoriser->in_category( category => "pubs",
     37                                          node     => "Albion" );
     38    ok( $isa_pub, "...and is case-insensitive" );
    3239
    33       $isa_pub = $categoriser->in_category( category => "pubs",
    34                                             node     => "Albion" );
    35       ok( $isa_pub, "...and is case-insensitive" );
    36 
    37       # Test ->categories
    38       my @categories = $categoriser->categories( node => "Calthorpe Arms" );
    39       is_deeply( [ sort @categories ], [ "Pub Food", "Pubs" ],
    40                  "...->categories returns all categories" );
    41 
    42     } # end of SKIP
     40    # Test ->categories
     41    my @categories = $categoriser->categories( node => "Calthorpe Arms" );
     42    is_deeply( [ sort @categories ], [ "Pub Food", "Pubs" ],
     43               "...->categories returns all categories" );
    4344}
  • cgi-wiki-plugin-categoriser/trunk/t/nested_categories.t

    r178 r179  
    11use strict;
    2 use CGI::Wiki;
    3 use CGI::Wiki::TestConfig::Utilities;
    42use CGI::Wiki::Plugin::Categoriser;
    5 use Test::More tests =>
    6   (1 * $CGI::Wiki::TestConfig::Utilities::num_stores);
     3use CGI::Wiki::TestLib;
     4use Test::More;
    75
    8 my %stores = CGI::Wiki::TestConfig::Utilities->stores;
     6my $iterator = CGI::Wiki::TestLib->new_wiki_maker;
     7plan tests => ( $iterator->number * 1 );
    98
    10 my ($store_name, $store);
    11 while ( ($store_name, $store) = each %stores ) {
    12     SKIP: {
    13       skip "$store_name storage backend not configured for testing", 1
    14           unless $store;
     9while ( my $wiki = $iterator->new_wiki ) {
     10    print "#\n##### TEST CONFIG: Store: " . (ref $wiki->store) . "\n";
    1511
    16       print "#\n##### TEST CONFIG: Store: $store_name\n#\n";
     12    my $categoriser = CGI::Wiki::Plugin::Categoriser->new;
     13    $wiki->register_plugin( plugin => $categoriser );
    1714
    18       my $wiki = CGI::Wiki->new( store => $store );
    19       my $categoriser = CGI::Wiki::Plugin::Categoriser->new;
    20       $wiki->register_plugin( plugin => $categoriser );
     15    $wiki->write_node( "Category Pub Food", "pubs that serve food", undef,
     16                        { category => [ "Pubs", "Food", "Category" ] } )
     17      or die "Can't write node";
    2118
    22       my @subcategories = $categoriser->subcategories( category => "Pubs" );
    23       is_deeply( \@subcategories, [ "Pub Food" ], "->subcategories works" );
    24 
    25     } # end of SKIP
     19    my @subcategories = $categoriser->subcategories( category => "Pubs" );
     20    is_deeply( \@subcategories, [ "Pub Food" ], "->subcategories works" );
    2621}
Note: See TracChangeset for help on using the changeset viewer.