CGI::Wiki::TestConfig::Utilities - Utilities for testing CGI::Wiki things.
When 'perl Makefile.PL' is run on a CGI::Wiki distribution, information will be gathered about test databases etc that can be used for running tests. CGI::Wiki::TestConfig::Utilities gives you convenient access to this information, so you can easily write and run tests for your own CGI::Wiki plugins.
# Reinitialise every configured storage backend. use strict; use CGI::Wiki; use CGI::Wiki::TestConfig::Utilities; CGI::Wiki::TestConfig::Utilities->reinitialise_stores; # Run all our tests for every possible storage backend. use strict; use CGI::Wiki; use CGI::Wiki::TestConfig::Utilities; use Test::More tests => (8 * $CGI::Wiki::TestConfig::Utilities::num_stores); my %stores = CGI::Wiki::TestConfig::Utilities->stores; my ($store_name, $store); while ( ($store_name, $store) = each %stores ) { SKIP: { skip "$store_name storage backend not configured for testing", 8 unless $store; # PUT YOUR TESTS HERE } } # Or maybe we want to run tests for every combination of store # and search. use strict; use CGI::Wiki::TestConfig::Utilities; use Test::More tests => (1 + 11 * $CGI::Wiki::TestConfig::Utilities::num_combinations); use_ok( "CGI::Wiki::Plugin::Location" ); # Test for each configured pair: $store, $search. my @tests = CGI::Wiki::TestConfig::Utilities->combinations; foreach my $configref (@tests) { my %testconfig = %$configref; my ( $store_name, $store, $search_name, $search, $configured ) = @testconfig{qw(store_name store search_name search configured)}; SKIP: { skip "Store $store_name and search $search_name" . " not configured for testing", 11 unless $configured; # PUT YOUR TESTS HERE } }
# Reinitialise every configured storage backend. use strict; use CGI::Wiki; use CGI::Wiki::TestConfig::Utilities; CGI::Wiki::TestConfig::Utilities->reinitialise_stores;
Clears out all of the configured storage backends.
my %stores = CGI::Wiki::TestConfig::Utilities->stores;
Returns a hash whose keys are the names of all possible storage backends (eg, MySQL, Pg, SQLite) and whose values are either a corresponding CGI::Wiki::Store::* object, if one has been configured, or undef, if no corresponding store has been configured.
MySQL
Pg
SQLite
undef
You can find out at BEGIN time how many of these to expect; it's stored in $CGI::Wiki::TestConfig::Utilities::num_stores
$CGI::Wiki::TestConfig::Utilities::num_stores
my @combs = CGI::Wiki::TestConfig::Utilities->combinations;
Returns an array of references to hashes, one each for every possible combination of storage and search backends.
The hash entries are as follows:
store_name
DBIxFTSMySQL
SIIMySQL
SII
search_name
You can find out at BEGIN time how many of these to expect; it's stored in $CGI::Wiki::TestConfig::Utilities::num_combinations
$CGI::Wiki::TestConfig::Utilities::num_combinations
CGI::Wiki
Kake Pugh (kake@earth.li).
Copyright (C) 2003 Kake Pugh. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
If you have the Search::InvertedIndex backend configured (see CGI::Wiki::Search::SII) then your tests will raise warnings like
(in cleanup) Search::InvertedIndex::DB::Mysql::lock() - testdb is not open. Can't lock. at /usr/local/share/perl/5.6.1/Search/InvertedIndex.pm line 1348
or
(in cleanup) Can't call method "sync" on an undefined value at /usr/local/share/perl/5.6.1/Tie/DB_File/SplitHash.pm line 331 during global destruction.
in unexpected places. I don't know whether this is a bug in me or in Search::InvertedIndex.
To install CGI::Wiki, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Wiki
CPAN shell
perl -MCPAN -e shell install CGI::Wiki
For more information on module installation, please visit the detailed CPAN module installation guide.