Changeset 503


Ignore:
Timestamp:
09/05/09 13:53:12 (5 years ago)
Author:
dom
Message:

add more recent changes tests (references #41)

Location:
wiki-toolkit/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/Changes

    r497 r503  
    110.78 
    22        Fix various POD errors and add POD testing (#45) 
     3        More recent changes tests (for #41) 
    34 
    450.77    24 December 2008 
  • wiki-toolkit/trunk/t/011_recent_changes.t

    r420 r503  
    66    plan skip_all => "no backends configured"; 
    77} else { 
    8     plan tests => ( 25 * scalar @Wiki::Toolkit::TestLib::wiki_info ); 
     8    plan tests => ( 28 * scalar @Wiki::Toolkit::TestLib::wiki_info ); 
    99} 
    1010 
     
    2525    my $node = "Node1"; 
    2626    my %node_data = $wiki->retrieve_node( $node ); 
    27     $wiki->write_node( $node, @node_data{ qw( content checksum ) }, 
     27    $wiki->write_node( $node, "data", @node_data{checksum} , 
    2828                       { 
    2929                         username  => "Kake", 
     
    3535    $node = "Everyone's Favourite Hobby"; 
    3636    %node_data = $wiki->retrieve_node( $node ); 
    37     $wiki->write_node( $node, @node_data{ qw( content checksum ) }, 
     37    $wiki->write_node( $node, "hobby data", @node_data{checksum}, 
    3838                       { 
    3939                         comment   => "Test", 
     40                         edit_type => "Normal edit", 
    4041                       } 
    4142                     ); 
     
    4344    $node = "Another Node"; 
    4445    %node_data = $wiki->retrieve_node( $node ); 
    45     $wiki->write_node( $node, @node_data{ qw( content checksum ) }, 
     46    $wiki->write_node( $node, "another node 1", @node_data{checksum}, 
    4647                       { 
    4748                         username  => "nou", 
    4849                         comment   => "Test", 
     50                         edit_type => "Normal edit", 
    4951                       } 
    5052                     ); 
     
    9799        metadata_is    => { username => "Kake" } 
    98100    ); 
     101 
     102    @nodenames = map { $_->{name} } @nodes; 
     103    print "# Found nodes: " . join(" ", @nodenames) . "\n"; 
    99104    is( scalar @nodes, 1, "metadata_is does constrain the search" ); 
    100105    is( $nodes[0]{name}, "Node1", "...correctly" ); 
     
    113118        metadata_isnt  => { edit_type => "Minor tidying" } 
    114119    ); 
     120    @nodenames = map { $_->{name} } @nodes; 
     121    print "# Found nodes: " . join(" ", @nodenames) . "\n"; 
    115122    is( scalar @nodes, 1, 
    116123       "metadata_isnt includes nodes where this metadata type isn't set" ); 
     
    133140    $node = "Another Node"; 
    134141    %node_data = $wiki->retrieve_node( $node ); 
    135     $wiki->write_node( $node, @node_data{ qw( content checksum ) }, 
     142    $wiki->write_node( $node, "another node 2", @node_data{checksum}, 
    136143                       { 
    137144                         username  => "Kake", 
     
    142149 
    143150    @nodes = $wiki->list_recent_changes( days => 1 ); 
     151    @nodenames = map { $_->{name} } @nodes; 
     152    print "# Found nodes: " . join(" ", @nodenames) . "\n"; 
    144153    is( scalar @nodes, 3, 
    145154        "By default each node returned only once however many times changed" ); 
     
    153162        metadata_was => { username => "nou" } 
    154163    ); 
     164    @nodenames = map { $_->{name} } @nodes; 
     165    print "# Found nodes: " . join(" ", @nodenames) . "\n"; 
    155166    is( scalar @nodes, 1, 
    156167       "metadata_was returns nodes whose current version doesn't match" ); 
     
    169180                          }, 
    170181    ); 
     182    @nodenames = map { $_->{name} } @nodes; 
     183    print "# Found nodes: " . join(" ", @nodenames) . "\n"; 
    171184    is( scalar @nodes, 2, 
    172185        "metadata_wasnt returns nodes whose current version matches" ); 
     186 
     187    # lets add yet another normal edit to check proper display of multple normal edits 
     188    do_sleep(); 
     189    $node = "Another Node"; 
     190    %node_data = $wiki->retrieve_node( $node ); 
     191    $wiki->write_node( $node, "another node 3", @node_data{checksum}, 
     192                       { 
     193                         username  => "bob", 
     194                         comment  => "bob writes the node that nou and Kake aready wrote", 
     195                         edit_type => "Normal edit", 
     196                       } 
     197                     ); 
     198 
     199    @nodenames = map { $_->{name} } @nodes; 
     200    print "# Found nodes: " . join(" ", @nodenames) . "\n"; 
     201    @nodes = $wiki->list_recent_changes( days => 1 ); 
     202    is( scalar @nodes, 3, 
     203        "By default each node returned only once however many times changed" ); 
     204    @nodes = $wiki->list_recent_changes( days => 1, include_all_changes => 1 ); 
     205    is( scalar @nodes, 5, 
     206        "...returned more than once when 'include_all_changes' set" ); 
     207    @nodes = $wiki->list_recent_changes( 
     208        days => 1, 
     209        metadata_was => { 
     210                            edit_type => "Normal edit", 
     211                          }, 
     212    ); 
     213    @nodenames = map { $_->{name} } @nodes; 
     214    print "# Found nodes: " . join(" ", @nodenames) . "\n"; 
     215     
     216    TODO: { 
     217        local $TODO = 'http://www.wiki-toolkit.org/ticket/41'; 
     218        is( scalar @nodes, 2, 
     219            "metadata_was returns nodes whose current version matches" ); 
     220    } 
    173221} 
    174222 
Note: See TracChangeset for help on using the changeset viewer.