source: trunk/t/74_ping_plugin.t @ 924

Last change on this file since 924 was 924, checked in by kake, 15 years ago

If we haven't got DBD::SQLite, skip all tests from the start, rather than using a big SKIP block and hardcoding the number of tests in twice.

File size: 2.2 KB
Line 
1use strict;
2use Wiki::Toolkit::Setup::SQLite;
3use OpenGuides;
4use OpenGuides::Test;
5use Test::More;
6
7eval { require DBD::SQLite; };
8if ( $@ ) {
9  plan skip_all => "DBD::SQLite not installed - no database to test with";
10} else {
11  plan tests => 9;
12}
13
14Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
15my $config = OpenGuides::Config->new(
16    vars => {
17                dbtype             => "sqlite",
18                dbname             => "t/node.db",
19                indexing_directory => "t/indexes",
20                script_url         => "http://wiki.example.com/",
21                script_name        => "mywiki.cgi",
22                site_name          => "Wiki::Toolkit Test Site",
23                default_city       => "London",
24                default_country    => "United Kingdom",
25                ping_services      => ""
26            }
27);
28my $guide = OpenGuides->new( config => $config );
29
30ok($guide, "Made the guide OK");
31
32# Check for the plugin
33my @plugins = @{ $guide->wiki->{_registered_plugins} };
34is( scalar @plugins, 2, "Two plugins to start" );
35
36
37# Now with the plugin
38$config = OpenGuides::Config->new(
39    vars => {
40                dbtype             => "sqlite",
41                dbname             => "t/node.db",
42                indexing_directory => "t/indexes",
43                script_url         => "http://wiki.example.com/",
44                script_name        => "mywiki.cgi",
45                site_name          => "Wiki::Toolkit Test Site",
46                default_city       => "London",
47                default_country    => "United Kingdom",
48                ping_services      => "pingerati,geourl,FOOOO"
49            }
50);
51$guide = OpenGuides->new( config => $config );
52
53ok($guide, "Made the guide OK");
54
55@plugins = @{ $guide->wiki->{_registered_plugins} };
56is( scalar @plugins, 3, "Has plugin now" );
57ok( $plugins[2]->isa( "Wiki::Toolkit::Plugin" ), "Right plugin" );
58ok( $plugins[2]->isa( "Wiki::Toolkit::Plugin::Ping" ), "Right plugin" );
59
60# Check it has the right services registered
61my %services = $plugins[2]->services;
62my @snames = sort keys %services;
63is( scalar @snames, 2, "Has 2 services as expected" );
64is( $snames[0], "geourl", "Right service" );
65is( $snames[1], "pingerati", "Right service" );
66
Note: See TracBrowser for help on using the repository browser.