source: wiki-toolkit/trunk/t/004_write_and_retrieve.t @ 209

Last change on this file since 209 was 209, checked in by Dominic Hargreaves, 16 years ago

Rename contents (note this is two-part commit - we don't want to mix
modifications and file renames)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1use strict;
2use Wiki::Toolkit::TestLib;
3use Test::More;
4
5if ( scalar @Wiki::Toolkit::TestLib::wiki_info == 0 ) {
6    plan skip_all => "no backends configured";
7} else {
8    plan tests => ( 11 * scalar @Wiki::Toolkit::TestLib::wiki_info );
9}
10
11my $iterator = Wiki::Toolkit::TestLib->new_wiki_maker;
12
13while ( my $wiki = $iterator->new_wiki ) {
14    # Test a simple write and retrieve.
15    ok( $wiki->write_node("A Node", "Node content."),
16        "write_node can create a node" );
17    is( $wiki->retrieve_node("A Node"), "Node content.",
18        "retrieve_node can retrieve it" );
19
20    # Test calling syntax of ->retrieve_node.
21    eval { $wiki->retrieve_node; };
22    ok( $@, "retrieve_node dies if we don't tell it a node parameter" );
23    is( $wiki->retrieve_node(name => "A Node"), "Node content.",
24        "retrieve_node still works if we supply params as a hash" );
25    is( $wiki->retrieve_node(name => "A Node", version => 1), "Node content.",
26        "...still works if we supply a version param" );
27    my %node_data = $wiki->retrieve_node("A Node");
28    is( $node_data{content}, "Node content.",
29        "...still works when called in list context" );
30    foreach (qw( last_modified version checksum )) {
31        ok( defined $node_data{$_}, "...and $_ is defined" );
32    }
33
34    # Test ->node_exists.
35    ok( $wiki->node_exists("A Node"),
36        "node_exists returns true for an existing node" );
37    ok( ! $wiki->node_exists("This Is A Nonexistent Node"),
38            "...and false for a nonexistent one" );
39
40}
Note: See TracBrowser for help on using the repository browser.