Changeset 361


Ignore:
Timestamp:
Jun 7, 2004, 9:39:35 PM (18 years ago)
Author:
kake
Message:

Test overhaul - no longer require database access info.

Location:
trunk
Files:
1 added
5 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/MANIFEST

    r360 r361  
    4848templates/userstats.tt
    4949templates/wanted_pages.tt
    50 t/00_setup.t
    51 t/01_add_test_data.t
     50t/01_load.t
    5251t/11_utils.t
    5352t/12_macros.t
    5453t/13_cookies.t
    5554t/15_template.t
    56 t/15_wiki.conf
    5755t/21_rdf.t
    58 t/21_wiki.conf
    5956t/22_rss_modwiki.t
    6057t/31_supersearch.t
    6158t/32_supersearch_simple_metadata.t
    6259t/41_deletion.t
    63 t/51_diff.t
    6460t/61_bug_textareas.t
    6561t/62_bug_os_coords.t
  • trunk/PREREQUISITES

    r360 r361  
    1 Modules required by OpenGuides 0.31
     1Modules required by OpenGuides 0.33
    22===================================
    33
  • trunk/lib/OpenGuides.pm

    r360 r361  
    44use vars qw( $VERSION );
    55
    6 $VERSION = '0.32';
     6$VERSION = '0.33_01';
    77
    88=head1 NAME
  • trunk/t/11_utils.t

    r360 r361  
    11use strict;
    22use 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 }
     3use OpenGuides::Utils;
     4use Test::More tests => 7;
    115
    126eval { my $wiki = OpenGuides::Utils->make_wiki_object; };
     
    1610ok( $@, "...and if config param isn't a Config::Tiny object" );
    1711
    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" );
     12eval { require DBD::SQLite; };
     13my $have_sqlite = $@ ? 0 : 1;
    2314
    24 ok( $wiki->store,      "...and store defined" );
    25 ok( $wiki->search_obj, "...and search defined" );
    26 ok( $wiki->formatter,  "...and formatter defined" );
     15SKIP: {
     16    skip "DBD::SQLite not installed - no database to test with", 5
     17      unless $have_sqlite;
    2718
    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

    r360 r361  
    44use Test::More tests => 2;
    55
    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;
     6eval { require DBD::SQLite; };
     7my $have_sqlite = $@ ? 0 : 1;
    108
    11 my $wikitext = <<WIKI;
     9SKIP: {
     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;
    1226
    1327\@INDEX_LINK [[Category Foo]]
     
    1731WIKI
    1832
    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

    r360 r361  
    11use strict;
    22use Config::Tiny;
    3 use Test::More tests => 16;
    4 
    5 use_ok( "OpenGuides::CGI" );
     3use OpenGuides::CGI;
     4use Test::More tests => 15;
    65
    76eval { OpenGuides::CGI->make_prefs_cookie; };
     
    1110ok( $@, "...or if config isn't a Config::Tiny" );
    1211
    13 my $config = Config::Tiny->read( "t/21_wiki.conf" );
     12my $config = Config::Tiny->new;
     13$config->{_} = {
     14                 site_name => "Test Site",
     15               };
    1416
    1517eval { OpenGuides::CGI->make_prefs_cookie( config => $config ); };
  • trunk/t/15_template.t

    r360 r361  
    11use strict;
    2 use Test::More tests => 28;
    32use Config::Tiny;
    43use Cwd;
    54use CGI::Cookie;
    65use CGI::Wiki::Formatter::UseMod;
     6use OpenGuides::Template;
    77use 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";
     8use Test::More tests => 27;
     9
     10my $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               };
    1323
    1424# White box testing - we know that OpenGuides::Template only actually uses
    1525# 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.
    1827my $fake_wiki = Test::MockObject->new;
    1928$fake_wiki->mock("formatter",
     
    103112
    104113# 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               };
    107120$output = OpenGuides::Template->output(
    108121    wiki     => $fake_wiki,
     
    115128# Test that full_cgi_url comes out right if the trailing '/' is
    116129# 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               };
    121136$output = OpenGuides::Template->output(
    122137    wiki     => $fake_wiki,
  • trunk/t/21_rdf.t

    r360 r361  
    1 use CGI::Wiki::TestConfig::Utilities;
    2 use CGI::Wiki;
    3 use CGI::Wiki::Formatter::UseMod;
     1use CGI::Wiki::Setup::SQLite;
    42use Config::Tiny;
     3use OpenGuides::RDF;
     4use OpenGuides::Utils;
    55use URI::Escape;
     6use Test::More tests => 22;
    67
    7 use Test::More tests =>
    8   (1 + 22 * $CGI::Wiki::TestConfig::Utilities::num_stores);
     8eval { require DBD::SQLite; };
     9my $have_sqlite = $@ ? 0 : 1;
    910
    10 use_ok( "OpenGuides::RDF" );
     11SKIP: {
     12    skip "DBD::SQLite not installed - no database to test with", 22
     13      unless $have_sqlite;
    1114
    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                   };
    1327
    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 );
    1929
    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    }
    2134
    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" );
    2740
    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    );
    3757
    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" );
    4059
    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" );
    4361
    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" );
    4866
    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" );
    5169
    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" );
    5472
    55       like( $rdfxml, qr|<homePage>test website</homePage>|,
    56             "picks up website" );
     73    like( $rdfxml, qr|<homePage>test website</homePage>|, "picks up website" );
    5774
    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" );
    6178
    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" );
    6481
    65       like( $rdfxml, qr|<wiki:version>1</wiki:version>|, "version picked up" );
     82    like( $rdfxml, qr|<wiki:version>1</wiki:version>|, "version picked up" );
    6683
    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" );
    6886
    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" );
    7189
    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" );
    8295
    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" );
    8598
     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" );
    86103
    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" );
    99106}
  • trunk/t/22_rss_modwiki.t

    r360 r361  
    11use strict;
    2 use CGI::Wiki::Formatter::UseMod;
    3 use CGI::Wiki::TestConfig::Utilities;
    4 use CGI::Wiki;
     2use CGI::Wiki::Setup::SQLite;
    53use Config::Tiny;
     4use OpenGuides::RDF;
     5use OpenGuides::Utils;
     6use Test::More tests => 1;
    67
    7 use Test::More tests =>
    8   (1 + 2 * $CGI::Wiki::TestConfig::Utilities::num_stores);
     8eval { require DBD::SQLite; };
     9my $have_sqlite = $@ ? 0 : 1;
    910
    10 use_ok( "OpenGuides::RDF" );
     11SKIP: {
     12    skip "DBD::SQLite not installed - no database to test with", 1
     13      unless $have_sqlite;
    1114
    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                   };
    1325
    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 );
    1927
    20       print "#\n##### TEST CONFIG: Store: $store_name\n#\n";
     28    my $rdf_writer = OpenGuides::RDF->new( wiki   => $wiki,
     29                                           config => $config );
    2130
    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" );
    3633}
    3734
  • trunk/t/31_supersearch.t

    r360 r361  
    1 local $^W = 1;
    21use strict;
    3 use vars qw( $sqlite_tests );
    4 BEGIN { $sqlite_tests = 16; }
    5 use Test::More tests => 1 + $sqlite_tests;
    6 
    72use CGI::Wiki::Setup::SQLite;
    83use Config::Tiny;
    9 
    10 use_ok( "OpenGuides::SuperSearch" );
     4use OpenGuides::SuperSearch;
     5use Test::More tests => 16;
    116
    127eval { require DBD::SQLite; };
    13 my $run_tests = $@ ? 0 : 1;
     8my $have_sqlite = $@ ? 0 : 1;
    149
    1510SKIP: {
    16     skip "DBD::SQLite needed to run these tests", $sqlite_tests
    17       unless $run_tests;
     11    skip "DBD::SQLite not installed - no database to test with", 16
     12      unless $have_sqlite;
    1813
    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" } );
    2215    my $config = Config::Tiny->new;
    2316    $config->{_} = {
    2417                     dbtype             => "sqlite",
    25                      dbname             => "t/sqlite.31.db",
    26                      indexing_directory => "t/index.31/",
     18                     dbname             => "t/node.db",
     19                     indexing_directory => "t/indexes",
    2720                     script_name        => "wiki.cgi",
    2821                     script_url         => "http://example.com/",
     
    3023                     template_path      => "./templates",
    3124                   };
     25
    3226    my $search = OpenGuides::SuperSearch->new( config => $config );
    3327    isa_ok( $search, "OpenGuides::SuperSearch" );
     
    151145          "second page of results starts with right numbering" );
    152146}
    153 
  • trunk/t/32_supersearch_simple_metadata.t

    r360 r361  
    1 local $^W = 1;
    21use strict;
    32use CGI::Wiki::Setup::SQLite;
    43use Config::Tiny;
    54use OpenGuides::SuperSearch;
    6 use Test::More;
     5use Test::More tests => 10;
    76
    87eval { require DBD::SQLite; };
     8my $have_sqlite = $@ ? 0 : 1;
    99
    10 if ( $@ ) {
    11     plan skip_all => "DBD::SQLite needed to run these tests";
    12 } else {
    13     plan tests => 10;
     10SKIP: {
     11    skip "DBD::SQLite not installed - no database to test with", 10
     12      unless $have_sqlite;
    1413
    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" } );
    1815    my $config = Config::Tiny->new;
    1916    $config->{_} = {
    2017                     dbtype             => "sqlite",
    21                      dbname             => "t/sqlite.32.db",
    22                      indexing_directory => "t/index.32/",
     18                     dbname             => "t/node.db",
     19                     indexing_directory => "t/indexes",
    2320                     script_name        => "wiki.cgi",
    2421                     script_url         => "http://example.com/",
     
    2623                     template_path      => "./templates",
    2724                   };
     25
    2826    my $search = OpenGuides::SuperSearch->new( config => $config );
    2927
  • trunk/t/41_deletion.t

    r360 r361  
    11use strict;
    2 use Test::More tests => 3;
    32use Config::Tiny;
    43use Cwd;
     
    65use OpenGuides::Template;
    76use Test::MockObject;
     7use Test::More tests => 3;
    88
    99my $config = Config::Tiny->new;
  • trunk/t/61_bug_textareas.t

    r360 r361  
    1 use strict;
     1use CGI::Wiki::Setup::SQLite;
    22use Config::Tiny;
    33use Cwd;
     
    66use Test::More tests => 1;
    77
    8 #####
    9 ##### IMPORTANT: Treat this wiki object as read-only or we may eat live data.
    10 #####
     8eval { require DBD::SQLite; };
     9my $have_sqlite = $@ ? 0 : 1;
    1110
    12 my $config = Config::Tiny->read( "wiki.conf" )
    13     or die "Couldn't read wiki.conf";
    14 my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
    15 $config->{_}{template_path} = cwd . "/templates";
     11SKIP: {
     12    skip "DBD::SQLite not installed - no database to test with", 1
     13      unless $have_sqlite;
    1614
    17 my $out = OpenGuides::Template->output(
    18     wiki     => $wiki,
    19     config   => $config,
    20     template => "edit_form.tt",
    21     vars     => {
    22                   locales  => [
    23                                 { name => "Barville" },
    24                                 { name => "Fooville" },
    25                               ],
    26                 },
    27 );
     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                     template_path      => cwd . "/templates",
     25                   };
    2826
    29 like( $out, qr/Barville\nFooville/, "locales properly separated in textarea" );
     27    my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
     28
     29    my $out = OpenGuides::Template->output(
     30        wiki     => $wiki,
     31        config   => $config,
     32        template => "edit_form.tt",
     33        vars     => {
     34                      locales  => [
     35                                    { name => "Barville" },
     36                                    { name => "Fooville" },
     37                                  ],
     38                    },
     39    );
     40
     41    like( $out, qr/Barville\nFooville/,
     42         "locales properly separated in textarea" );
     43}
    3044
    3145
  • trunk/t/62_bug_os_coords.t

    r360 r361  
    1 local $^W = 1;
    2 use strict;
    3 use vars qw( $num_tests );
    4 BEGIN { $num_tests = 2; }
    5 use Test::More tests => $num_tests;
    6 
    71use CGI::Wiki::Setup::SQLite;
    82use Config::Tiny;
     3use Cwd;
     4use OpenGuides::Template;
    95use OpenGuides::Utils;
    10 use OpenGuides::Template;
     6use Test::More tests => 2;
    117
    128eval { require DBD::SQLite; };
    13 my $run_tests = $@ ? 0 : 1;
     9my $have_sqlite = $@ ? 0 : 1;
    1410
    1511SKIP: {
    16     skip "DBD::SQLite needed to run these tests", $num_tests
    17       unless $run_tests;
     12    skip "DBD::SQLite not installed - no database to test with", 2
     13      unless $have_sqlite;
    1814
    19     # Ensure the test database is set up.
    20     CGI::Wiki::Setup::SQLite::setup( "t/sqlite.62.db" );
    21 
     15    CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } );
    2216    my $config = Config::Tiny->new;
    2317    $config->{_} = {
    2418                     dbtype             => "sqlite",
    25                      dbname             => "t/sqlite.62.db",
    26                      indexing_directory => "t/index.62/",
     19                     dbname             => "t/node.db",
     20                     indexing_directory => "t/indexes",
     21                     script_url         => "http://example.com/",
    2722                     script_name        => "wiki.cgi",
    28                      script_url         => "http://example.com/",
    2923                     site_name          => "Test Site",
    30                      template_path      => "./templates",
     24                     template_path      => cwd . "/templates",
    3125                   };
     26
    3227    my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
    3328
     
    3530    $q->param( -name => "os_x", -value => "123456 " );
    3631    $q->param( -name => "os_y", -value => "654321 " );
    37     $q->param( -name => "categories", -value => "" ); # avoid uninit val warning
    38     $q->param( -name => "locales", -value => "" );    # avoid uninit val warning
     32    $q->param( -name => "categories", -value => "" ); #avoid uninit val warning
     33    $q->param( -name => "locales", -value => "" );    #avoid uninit val warning
    3934
    4035    my %metadata_vars = OpenGuides::Template->extract_metadata_vars(
  • trunk/wiki.cgi

    r360 r361  
    55
    66use vars qw( $VERSION );
    7 $VERSION = '0.32';
     7$VERSION = '0.33_01';
    88
    99use CGI qw/:standard/;
Note: See TracChangeset for help on using the changeset viewer.