[siesta-commit] siesta/t 09plugin_order.t,NONE,1.1

[prev] [thread] [next] [lurker] [Date index for 2002/09/11]

From: muttley
Subject: [siesta-commit] siesta/t 09plugin_order.t,NONE,1.1
Date: 12:13 on 11 Sep 2002
Update of /cvsroot/siesta/siesta/t
In directory usw-pr-cvs1:/tmp/cvs-serv13259/t

Added Files:
	09plugin_order.t 
Log Message:
Tests for plugin order.


--- NEW FILE: 09plugin_order.t ---
#!perl -w
use strict;
use Test::More tests => 18;
use Test::MockObject;
use Siesta;
use Siesta::User;
use Siesta::Plugin::ReplyTo;

Siesta->connect( DBI=> "dbi:SQLite:t/test.db" );


# create a new, virgin list
my $list = Siesta::List->new_from_hash (  
						id=>'pluginorder',
						'owner' => 'foo',
					 );


$list->save();

##
# First we do it all via the storage interface
##

# the list of plugins should be empty
is(Siesta->storage->list_plugins($list), 0, "empty list");

my @plugins = qw(Bounce ReplyTo);


# set the list of plugins
ok(Siesta->storage->set_plugins($list, @plugins));

my @new = Siesta->storage->list_plugins($list->id());

my $flag = 1;
foreach my $p (@new)
{
	$flag &&= ($p eq shift @plugins);
}

is ($flag, 1, "set the plugins");

# add one at the end 
ok(Siesta->storage->add_plugin_to_list($list, 'Send'));

@plugins = Siesta->storage->list_plugins($list->id());

my $last = pop @plugins;
is ($last, 'Send', "Add on the end");

# add at the start
ok(Siesta->storage->add_plugin_to_list($list, 'First', 1));

@plugins = Siesta->storage->list_plugins($list->id());
my $first = shift @plugins;
is ($first, 'First', "Add at the start");

# now delete them all
ok(Siesta->storage->set_plugins($list, qw()));

# the list of plugins should be empty
is(Siesta->storage->list_plugins($list), 0, "empty list again");


##
# now do it all again but with the list interface
##

# the list of plugins should be empty
is($list->plugins(), 0, "empty list");

@plugins = qw(Bounce ReplyTo);


# set the list of plugins
ok($list->set_plugins(@plugins));

@new = $list->plugins();

$flag = 1;
foreach my $p (@new)
{
        $flag &&= ($p eq shift @plugins);
}

is ($flag, 1, "set the plugins");

# add one at the end
ok($list->add_plugin('Send'));

@plugins = $list->plugins();

$last = pop @plugins;
is ($last, 'Send', "Add on the end");

# add at the start
ok($list->add_plugin('First', 1));


@plugins = $list->plugins();
$first = shift @plugins;
is ($first, 'First', "Add at the start");

# now delete them all
ok($list->set_plugins(qw()));

# the list of plugins should be empty
is($list->plugins(), 0, "empty list again");





Generated at 13:57 on 01 Jul 2004 by mariachi 0.52