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

Last change on this file since 874 was 874, checked in by nick, 15 years ago

Add ping support

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