NAME

Labyrinth::Test::Harness - Test Harness for Labyrinth Plugin modules

SYNOPSIS

my $harness = Labyrinth::Test::Harness->new();
$harness->new();

my $res = $harness->prep('file1.sql',;file2.sql');

$res = $harness->labyrinth(@plugins);

$res = $harness->action('Base::Admin');

$harness->refresh( \@plugins );
$harness->refresh(
    \@plugins,
    { test1 => 1 },
    { test2 => 2 } );

$harness->cleanup;

$harness->clear();
my $vars   = $harness->vars;
my $params = $harness->params;
$harness->set_params( name => 'Test', test => 1 );
$harness->set_vars( name => 'Test', test => 1 );

my $error = $harness->error;

my $config    = $harness->config;
my $directory = $harness->directory;
$harness->copy_files($source,$target);

DESCRIPTION

Contains all the harness code around Labyrinth, to enable plugin testing.

METHODS

The Constructor

new( %options )

Harness object constructor.

Defines a default config file and directory, unless otherwise provided.

Options available are:

config    => $config
directory => $directory

Public Methods

prep( @sql )

Prepares the environment. Copies files from the current vhost directory, creates a database, and runs the necessary SQL to create the required tables and add the appropriate data. Saves the configuration settings to the designated config file.

labyrinth( @plugins )

Loads an instance of Labyrinth. Will also pre-load the list of given plugins.

action( $action )

Runs the named plugin action.

refresh( \@plugins, $vars_hash, $params_hash )

Refreshes the current instance by reloading the Labyrinth instances, together with the name plugins, and adding the variables and parameters to the current internal hashes.

Essentially a short cut to calling labyrinth(), set_vars() and set_params() separately.

cleanup

Clean up the instance, removes the current directory and deletes the test database.

Internal Variables

clear

Clear the internal variables and parameters hashes.

params

returns the current parameters hash.

set_params( %hash )

Adds the given parameters to the current paraments hash.

vars

returns the current variables hash.

set_vars( %hash )

Adds the given variables to the current variables hash.

error

Returns the last error recorded.

Internal Methods

copy_files( $source, $target )

Copies files between the source and target directories.

create_config( $db_config )

Creates a configuration file.

create_mysql_databases( @files )

Creates the test database. The @files array, lists the SQL files containing SQL statements to run on the test database.

dosql

Runs an SQL command.

SEE ALSO

Labyrinth

http://labyrinth.missbarbell.co.uk

AUTHOR

Barbie, <barbie@missbarbell.co.uk> for Miss Barbell Productions, http://www.missbarbell.co.uk/

COPYRIGHT & LICENSE

Copyright (C) 2014 Barbie for Miss Barbell Productions
All Rights Reserved.

This module is free software; you can redistribute it and/or
modify it under the Artistic License 2.0.