Changeset 361
- Timestamp:
- 06/07/04 21:39:35 (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 removed
- 15 modified
-
MANIFEST (modified) (1 diff)
-
PREREQUISITES (modified) (1 diff)
-
lib/OpenGuides.pm (modified) (1 diff)
-
t/00_setup.t (deleted)
-
t/01_add_test_data.t (deleted)
-
t/01_load.t (added)
-
t/11_utils.t (modified) (2 diffs)
-
t/12_macros.t (modified) (2 diffs)
-
t/13_cookies.t (modified) (2 diffs)
-
t/15_template.t (modified) (3 diffs)
-
t/15_wiki.conf (deleted)
-
t/21_rdf.t (modified) (1 diff)
-
t/21_wiki.conf (deleted)
-
t/22_rss_modwiki.t (modified) (1 diff)
-
t/31_supersearch.t (modified) (3 diffs)
-
t/32_supersearch_simple_metadata.t (modified) (2 diffs)
-
t/41_deletion.t (modified) (2 diffs)
-
t/51_diff.t (deleted)
-
t/61_bug_textareas.t (modified) (2 diffs)
-
t/62_bug_os_coords.t (modified) (2 diffs)
-
wiki.cgi (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/MANIFEST
r349 r361 48 48 templates/userstats.tt 49 49 templates/wanted_pages.tt 50 t/00_setup.t 51 t/01_add_test_data.t 50 t/01_load.t 52 51 t/11_utils.t 53 52 t/12_macros.t 54 53 t/13_cookies.t 55 54 t/15_template.t 56 t/15_wiki.conf57 55 t/21_rdf.t 58 t/21_wiki.conf59 56 t/22_rss_modwiki.t 60 57 t/31_supersearch.t 61 58 t/32_supersearch_simple_metadata.t 62 59 t/41_deletion.t 63 t/51_diff.t64 60 t/61_bug_textareas.t 65 61 t/62_bug_os_coords.t -
trunk/PREREQUISITES
r354 r361 1 Modules required by OpenGuides 0.3 11 Modules required by OpenGuides 0.33 2 2 =================================== 3 3 -
trunk/lib/OpenGuides.pm
r357 r361 4 4 use vars qw( $VERSION ); 5 5 6 $VERSION = '0.3 2';6 $VERSION = '0.33_01'; 7 7 8 8 =head1 NAME -
trunk/t/11_utils.t
r174 r361 1 1 use strict; 2 2 use Config::Tiny; 3 use Test::More tests => 9; 4 5 # Need to use a BEGIN block for the test or we get "Too late to run INIT block" 6 # from Class::Delegation 7 8 BEGIN { 9 use_ok( "OpenGuides::Utils" ); 10 } 3 use OpenGuides::Utils; 4 use Test::More tests => 7; 11 5 12 6 eval { my $wiki = OpenGuides::Utils->make_wiki_object; }; … … 16 10 ok( $@, "...and if config param isn't a Config::Tiny object" ); 17 11 18 my $config = Config::Tiny->read( "wiki.conf" ) 19 or die "Couldn't read wiki.conf"; 20 my $wiki = eval { OpenGuides::Utils->make_wiki_object( config => $config ); }; 21 is( $@, "", "...but not if a Config::Tiny object is supplied" ); 22 isa_ok( $wiki, "CGI::Wiki" ); 12 eval { require DBD::SQLite; }; 13 my $have_sqlite = $@ ? 0 : 1; 23 14 24 ok( $wiki->store, "...and store defined" ); 25 ok( $wiki->search_obj, "...and search defined" ); 26 ok( $wiki->formatter, "...and formatter defined" );15 SKIP: { 16 skip "DBD::SQLite not installed - no database to test with", 5 17 unless $have_sqlite; 27 18 28 # Ensure that we take note of any defined dbhost - note that this test 29 # is only useful if we've defined a dbhost during perl Build.PL 30 is( $wiki->store->dbhost, $config->{_}->{dbhost}, "dbhost taken note of" ); 19 my $config = Config::Tiny->new; 20 $config->{_} = { 21 dbtype => "sqlite", 22 dbname => "t/node.db", 23 indexing_directory => "t/indexes", 24 script_url => "", 25 script_name => "", 26 }; 27 28 my $wiki = eval { 29 OpenGuides::Utils->make_wiki_object( config => $config ); 30 }; 31 is( $@, "", 32 "...but not if a Config::Tiny object with suitable data is supplied" ); 33 isa_ok( $wiki, "CGI::Wiki" ); 34 35 ok( $wiki->store, "...and store defined" ); 36 ok( $wiki->search_obj, "...and search defined" ); 37 ok( $wiki->formatter, "...and formatter defined" ); 38 } -
trunk/t/12_macros.t
r180 r361 4 4 use Test::More tests => 2; 5 5 6 my $config = Config::Tiny->read( "wiki.conf" ) 7 or die "Couldn't read wiki.conf"; 8 my $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 9 my $formatter = $wiki->formatter; 6 eval { require DBD::SQLite; }; 7 my $have_sqlite = $@ ? 0 : 1; 10 8 11 my $wikitext = <<WIKI; 9 SKIP: { 10 skip "DBD::SQLite not installed - no database to test with", 2 11 unless $have_sqlite; 12 13 my $config = Config::Tiny->new; 14 $config->{_} = { 15 dbtype => "sqlite", 16 dbname => "t/node.db", 17 indexing_directory => "t/indexes", 18 script_url => "", 19 script_name => "", 20 }; 21 22 my $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 23 my $formatter = $wiki->formatter; 24 25 my $wikitext = <<WIKI; 12 26 13 27 \@INDEX_LINK [[Category Foo]] … … 17 31 WIKI 18 32 19 my $html = $formatter->format($wikitext); 20 like( $html, qr/View all pages in Category Foo/, 21 "\@INDEX_LINK has right default link text" ); 22 like( $html, qr/>Bars<\/a>/, "...and can be overridden" ); 33 my $html = $formatter->format($wikitext); 34 like( $html, qr/View all pages in Category Foo/, 35 "\@INDEX_LINK has right default link text" ); 36 like( $html, qr/>Bars<\/a>/, "...and can be overridden" ); 37 } -
trunk/t/13_cookies.t
r302 r361 1 1 use strict; 2 2 use Config::Tiny; 3 use Test::More tests => 16; 4 5 use_ok( "OpenGuides::CGI" ); 3 use OpenGuides::CGI; 4 use Test::More tests => 15; 6 5 7 6 eval { OpenGuides::CGI->make_prefs_cookie; }; … … 11 10 ok( $@, "...or if config isn't a Config::Tiny" ); 12 11 13 my $config = Config::Tiny->read( "t/21_wiki.conf" ); 12 my $config = Config::Tiny->new; 13 $config->{_} = { 14 site_name => "Test Site", 15 }; 14 16 15 17 eval { OpenGuides::CGI->make_prefs_cookie( config => $config ); }; -
trunk/t/15_template.t
r311 r361 1 1 use strict; 2 use Test::More tests => 28;3 2 use Config::Tiny; 4 3 use Cwd; 5 4 use CGI::Cookie; 6 5 use CGI::Wiki::Formatter::UseMod; 6 use OpenGuides::Template; 7 7 use Test::MockObject; 8 9 use_ok( "OpenGuides::Template" ); 10 11 my $config = Config::Tiny->read( "t/21_wiki.conf" ); 12 $config->{_}->{template_path} = cwd . "/t/templates"; 8 use Test::More tests => 27; 9 10 my $config = Config::Tiny->new; 11 $config->{_} = { 12 template_path => cwd . '/t/templates', 13 site_name => 'CGI::Wiki Test Site', 14 script_url => 'http://wiki.example.com/', 15 script_name => 'mywiki.cgi', 16 default_country => 'United Kingdom', 17 default_city => 'London', 18 contact_email => 'wiki@example.com', 19 stylesheet_url => 'http://wiki.example.com/styles.css', 20 home_name => 'Home Page', 21 formatting_rules_node => 'Rules', 22 }; 13 23 14 24 # White box testing - we know that OpenGuides::Template only actually uses 15 25 # the node_name_to_node_param method of the formatter component of the wiki 16 # object passed in, and I CBA to faff about with picking out the test DB 17 # info to make a proper wiki object here. 26 # object passed in, and I CBA to make a proper wiki object here. 18 27 my $fake_wiki = Test::MockObject->new; 19 28 $fake_wiki->mock("formatter", … … 103 112 104 113 # Test that home_link is set correctly when script_name is blank. 105 $config = Config::Tiny->read( "t/15_wiki.conf" ); 106 $config->{_}->{template_path} = cwd . "/t/templates"; 114 $config->{_} = { 115 template_path => cwd . '/t/templates', 116 site_name => 'CGI::Wiki Test Site', 117 script_url => 'http://wiki.example.com/', 118 script_name => '', 119 }; 107 120 $output = OpenGuides::Template->output( 108 121 wiki => $fake_wiki, … … 115 128 # Test that full_cgi_url comes out right if the trailing '/' is 116 129 # missing from script_url in the config file. 117 $config = Config::Tiny->read( "t/15_wiki.conf" ); 118 $config->{_}->{template_path} = cwd . "/t/templates"; 119 $config->{_}->{script_url} = "http://wiki.example.com"; 120 $config->{_}->{script_name} = "wiki.cgi"; 130 $config->{_} = { 131 template_path => cwd . '/t/templates', 132 site_name => 'CGI::Wiki Test Site', 133 script_url => 'http://wiki.example.com', 134 script_name => 'wiki.cgi', 135 }; 121 136 $output = OpenGuides::Template->output( 122 137 wiki => $fake_wiki, -
trunk/t/21_rdf.t
r324 r361 1 use CGI::Wiki::TestConfig::Utilities; 2 use CGI::Wiki; 3 use CGI::Wiki::Formatter::UseMod; 1 use CGI::Wiki::Setup::SQLite; 4 2 use Config::Tiny; 3 use OpenGuides::RDF; 4 use OpenGuides::Utils; 5 5 use URI::Escape; 6 use Test::More tests => 22; 6 7 7 use Test::More tests => 8 (1 + 22 * $CGI::Wiki::TestConfig::Utilities::num_stores);8 eval { require DBD::SQLite; }; 9 my $have_sqlite = $@ ? 0 : 1; 9 10 10 use_ok( "OpenGuides::RDF" ); 11 SKIP: { 12 skip "DBD::SQLite not installed - no database to test with", 22 13 unless $have_sqlite; 11 14 12 my %stores = CGI::Wiki::TestConfig::Utilities->stores; 15 CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 16 my $config = Config::Tiny->new; 17 $config->{_} = { 18 dbtype => "sqlite", 19 dbname => "t/node.db", 20 indexing_directory => "t/indexes", 21 script_url => "http://wiki.example.com/", 22 script_name => "mywiki.cgi", 23 site_name => "CGI::Wiki Test Site", 24 default_city => "London", 25 default_country => "United Kingdom", 26 }; 13 27 14 my ($store_name, $store); 15 while ( ($store_name, $store) = each %stores ) { 16 SKIP: { 17 skip "$store_name storage backend not configured for testing", 22 18 unless $store; 28 my $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 19 29 20 print "#\n##### TEST CONFIG: Store: $store_name\n#\n"; 30 # Clear out the database from any previous runs. 31 foreach my $del_node ( $wiki->list_all_nodes ) { 32 $wiki->delete_node( $del_node ) or die "Can't delete $del_node"; 33 } 21 34 22 my $wiki = CGI::Wiki->new(23 store => $store,24 formatter => CGI::Wiki::Formatter::UseMod->new( munge_urls => 1 ),25 );26 my $config = Config::Tiny->read( "t/21_wiki.conf" );35 my $rdf_writer = eval { 36 OpenGuides::RDF->new( wiki => $wiki, config => $config ); 37 }; 38 is( $@, "", "'new' doesn't croak if wiki and config objects supplied" ); 39 isa_ok( $rdf_writer, "OpenGuides::RDF" ); 27 40 28 my $rdf_writer = eval { 29 OpenGuides::RDF->new( wiki => $wiki, 30 config => $config 31 ); 32 }; 33 is( $@, "", 34 "'new' doesn't croak if wiki and config objects supplied" 35 ); 36 isa_ok( $rdf_writer, "OpenGuides::RDF" ); 41 # Test the data for a node that exists. 42 $wiki->write_node( "Calthorpe Arms", 43 "CAMRA-approved pub near King's Cross", 44 undef, 45 { 46 comment => "Stub page, please update!", 47 username => "Kake", 48 postcode => "WC1X 8JR", 49 locale => [ "Bloomsbury", "St Pancras" ], 50 phone => "test phone number", 51 website => "test website", 52 opening_hours_text => "test hours", 53 latitude => "51.524193", 54 longitude => "-0.114436" 55 } 56 ); 37 57 38 # Test the data for a node that exists. 39 my $rdfxml = $rdf_writer->emit_rdfxml( node => "Calthorpe Arms" ); 58 my $rdfxml = $rdf_writer->emit_rdfxml( node => "Calthorpe Arms" ); 40 59 41 like( $rdfxml, qr|<\?xml version="1.0"\?>|, 42 "RDF is encoding-neutral" ); 60 like( $rdfxml, qr|<\?xml version="1.0"\?>|, "RDF is encoding-neutral" ); 43 61 44 like( $rdfxml, qr|<wn:Neighborhood>Bloomsbury</wn:Neighborhood>|,45 "finds the first locale" );46 like( $rdfxml, qr|<wn:Neighborhood>St Pancras</wn:Neighborhood>|,47 "finds the second locale" );62 like( $rdfxml, qr|<wn:Neighborhood>Bloomsbury</wn:Neighborhood>|, 63 "finds the first locale" ); 64 like( $rdfxml, qr|<wn:Neighborhood>St Pancras</wn:Neighborhood>|, 65 "finds the second locale" ); 48 66 49 like( $rdfxml, qr|<phone>test phone number</phone>|,50 "picks up phone number" );67 like( $rdfxml, qr|<phone>test phone number</phone>|, 68 "picks up phone number" ); 51 69 52 like( $rdfxml, qr|<chefmoz:Hours>test hours</chefmoz:Hours>|,53 "picks up opening hours text" );70 like( $rdfxml, qr|<chefmoz:Hours>test hours</chefmoz:Hours>|, 71 "picks up opening hours text" ); 54 72 55 like( $rdfxml, qr|<homePage>test website</homePage>|, 56 "picks up website" ); 73 like( $rdfxml, qr|<homePage>test website</homePage>|, "picks up website" ); 57 74 58 like( $rdfxml,59 qr|<dc:title>CGI::Wiki Test Site: Calthorpe Arms</dc:title>|,60 "sets the title correctly" );75 like( $rdfxml, 76 qr|<dc:title>CGI::Wiki Test Site: Calthorpe Arms</dc:title>|, 77 "sets the title correctly" ); 61 78 62 like( $rdfxml, qr|<dc:contributor>Kake</dc:contributor>|,63 "last username to edit used as contributor" );79 like( $rdfxml, qr|<dc:contributor>Kake</dc:contributor>|, 80 "last username to edit used as contributor" ); 64 81 65 like( $rdfxml, qr|<wiki:version>1</wiki:version>|, "version picked up" );82 like( $rdfxml, qr|<wiki:version>1</wiki:version>|, "version picked up" ); 66 83 67 like( $rdfxml, qr|<rdf:Description rdf:about="">|, "sets the 'about' correctly" ); 84 like( $rdfxml, qr|<rdf:Description rdf:about="">|, 85 "sets the 'about' correctly" ); 68 86 69 like( $rdfxml, qr|<dc:source rdf:resource="http://wiki.example.com/mywiki.cgi\?id=Calthorpe_Arms" />|,70 "set the dc:source with the version-independent uri" );87 like( $rdfxml, qr|<dc:source rdf:resource="http://wiki.example.com/mywiki.cgi\?id=Calthorpe_Arms" />|, 88 "set the dc:source with the version-independent uri" ); 71 89 72 like( $rdfxml, qr|<country>United Kingdom</country>|, 73 "default country picked up" ). 74 like( $rdfxml, qr|<city>London</city>|, 75 "default city picked up" ). 76 like( $rdfxml, qr|<postalCode>WC1X 8JR</postalCode>|, 77 "postcode picked up" ); 78 like( $rdfxml, qr|<geo:lat>51.524193</geo:lat>|, 79 "latitude picked up" ); 80 like( $rdfxml, qr|<geo:long>-0.114436</geo:long>|, 81 "longitude picked up" ); 90 like( $rdfxml, qr|<country>United Kingdom</country>|, "country" ). 91 like( $rdfxml, qr|<city>London</city>|, "city" ). 92 like( $rdfxml, qr|<postalCode>WC1X 8JR</postalCode>|, "postcode" ); 93 like( $rdfxml, qr|<geo:lat>51.524193</geo:lat>|, "latitude" ); 94 like( $rdfxml, qr|<geo:long>-0.114436</geo:long>|, "longitude" ); 82 95 83 like( $rdfxml, qr|<dc:date>|, "date element included" );84 unlike( $rdfxml, qr|<dc:date>1970|, "hasn't defaulted to the epoch" );96 like( $rdfxml, qr|<dc:date>|, "date element included" ); 97 unlike( $rdfxml, qr|<dc:date>1970|, "hasn't defaulted to the epoch" ); 85 98 99 # Now test that there's a nice failsafe where a node doesn't exist. 100 $rdfxml = eval { $rdf_writer->emit_rdfxml( node => "I Do Not Exist" ); }; 101 is( $@, "", 102 "->emit_rdfxml doesn't die when called on a nonexistent node" ); 86 103 87 # Now test that there's a nice failsafe where a node doesn't exist. 88 $rdfxml = eval { 89 $rdf_writer->emit_rdfxml( node => "I Do Not Exist" ); 90 }; 91 is( $@, "", 92 "->emit_rdfxml doesn't die when called on a nonexistent node" ); 93 94 like( $rdfxml, qr|<wiki:version>0</wiki:version>|, 95 "...and wiki:version is 0" ); 96 97 #print $rdfxml; 98 } 104 like( $rdfxml, qr|<wiki:version>0</wiki:version>|, 105 "...and wiki:version is 0" ); 99 106 } -
trunk/t/22_rss_modwiki.t
r126 r361 1 1 use strict; 2 use CGI::Wiki::Formatter::UseMod; 3 use CGI::Wiki::TestConfig::Utilities; 4 use CGI::Wiki; 2 use CGI::Wiki::Setup::SQLite; 5 3 use Config::Tiny; 4 use OpenGuides::RDF; 5 use OpenGuides::Utils; 6 use Test::More tests => 1; 6 7 7 use Test::More tests => 8 (1 + 2 * $CGI::Wiki::TestConfig::Utilities::num_stores);8 eval { require DBD::SQLite; }; 9 my $have_sqlite = $@ ? 0 : 1; 9 10 10 use_ok( "OpenGuides::RDF" ); 11 SKIP: { 12 skip "DBD::SQLite not installed - no database to test with", 1 13 unless $have_sqlite; 11 14 12 my %stores = CGI::Wiki::TestConfig::Utilities->stores; 15 CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 16 my $config = Config::Tiny->new; 17 $config->{_} = { 18 dbtype => "sqlite", 19 dbname => "t/node.db", 20 indexing_directory => "t/indexes", 21 script_url => "http://wiki.example.com/", 22 script_name => "mywiki.cgi", 23 site_name => "CGI::Wiki Test Site", 24 }; 13 25 14 my ($store_name, $store); 15 while ( ($store_name, $store) = each %stores ) { 16 SKIP: { 17 skip "$store_name storage backend not configured for testing", 2 18 unless $store; 26 my $wiki = OpenGuides::Utils->make_wiki_object( config => $config ); 19 27 20 print "#\n##### TEST CONFIG: Store: $store_name\n#\n"; 28 my $rdf_writer = OpenGuides::RDF->new( wiki => $wiki, 29 config => $config ); 21 30 22 my $wiki = CGI::Wiki->new( 23 store => $store, 24 formatter => CGI::Wiki::Formatter::UseMod->new ); 25 my $config = Config::Tiny->read( "t/21_wiki.conf" ); 26 my $rdf_writer = OpenGuides::RDF->new( wiki => $wiki, 27 config => $config ); 28 isa_ok( $rdf_writer, "OpenGuides::RDF" ); 29 30 my $rss = eval { $rdf_writer->make_recentchanges_rss; }; 31 is( $@, "", "->make_recentchanges_rss doesn't croak" ); 32 33 # print $rss; 34 35 } # end of SKIP 31 my $rss = eval { $rdf_writer->make_recentchanges_rss; }; 32 is( $@, "", "->make_recentchanges_rss doesn't croak" ); 36 33 } 37 34 -
trunk/t/31_supersearch.t
r274 r361 1 local $^W = 1;2 1 use strict; 3 use vars qw( $sqlite_tests );4 BEGIN { $sqlite_tests = 16; }5 use Test::More tests => 1 + $sqlite_tests;6 7 2 use CGI::Wiki::Setup::SQLite; 8 3 use Config::Tiny; 9 10 use _ok( "OpenGuides::SuperSearch" );4 use OpenGuides::SuperSearch; 5 use Test::More tests => 16; 11 6 12 7 eval { require DBD::SQLite; }; 13 my $ run_tests= $@ ? 0 : 1;8 my $have_sqlite = $@ ? 0 : 1; 14 9 15 10 SKIP: { 16 skip "DBD::SQLite n eeded to run these tests", $sqlite_tests17 unless $ run_tests;11 skip "DBD::SQLite not installed - no database to test with", 16 12 unless $have_sqlite; 18 13 19 # Ensure the test database is set up. 20 CGI::Wiki::Setup::SQLite::setup( "t/sqlite.31.db" ); 21 14 CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 22 15 my $config = Config::Tiny->new; 23 16 $config->{_} = { 24 17 dbtype => "sqlite", 25 dbname => "t/ sqlite.31.db",26 indexing_directory => "t/index .31/",18 dbname => "t/node.db", 19 indexing_directory => "t/indexes", 27 20 script_name => "wiki.cgi", 28 21 script_url => "http://example.com/", … … 30 23 template_path => "./templates", 31 24 }; 25 32 26 my $search = OpenGuides::SuperSearch->new( config => $config ); 33 27 isa_ok( $search, "OpenGuides::SuperSearch" ); … … 151 145 "second page of results starts with right numbering" ); 152 146 } 153 -
trunk/t/32_supersearch_simple_metadata.t
r267 r361 1 local $^W = 1;2 1 use strict; 3 2 use CGI::Wiki::Setup::SQLite; 4 3 use Config::Tiny; 5 4 use OpenGuides::SuperSearch; 6 use Test::More ;5 use Test::More tests => 10; 7 6 8 7 eval { require DBD::SQLite; }; 8 my $have_sqlite = $@ ? 0 : 1; 9 9 10 if ( $@ ) { 11 plan skip_all => "DBD::SQLite needed to run these tests"; 12 } else { 13 plan tests => 10; 10 SKIP: { 11 skip "DBD::SQLite not installed - no database to test with", 10 12 unless $have_sqlite; 14 13 15 # Ensure the test database is set up. 16 CGI::Wiki::Setup::SQLite::setup( "t/sqlite.32.db" ); 17 14 CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } ); 18 15 my $config = Config::Tiny->new; 19 16 $config->{_} = { 20 17 dbtype => "sqlite", 21 dbname => "t/ sqlite.32.db",22 indexing_directory => "t/index .32/",18 dbname => "t/node.db", 19 indexing_directory => "t/indexes", 23 20 script_name => "wiki.cgi", 24 21 script_url => "http://example.com/", … … 26 23 template_path => "./templates", 27 24 }; 25 28 26 my $search = OpenGuides::SuperSearch->new( config => $config ); 29 27 -
trunk/t/41_deletion.t
r311 r361 1 1 use strict; 2 use Test::More tests => 3;3 2 use Config::Tiny; 4 3 use Cwd; … … 6 5 use OpenGuides::Template; 7 6 use Test::MockObject; 7 use Test::More tests => 3; 8 8 9 9 my $config = Config::Tiny->new; -
trunk/t/61_bug_textareas.t
