Add a has method to Session/Setting, so that it's easy to check if a setting

already exists.  Very handy for upgrade scripts.
This commit is contained in:
Colin Kuskie 2009-05-13 17:32:49 +00:00
parent 385d35c13b
commit b19279a13d
2 changed files with 29 additions and 1 deletions

View file

@ -15,7 +15,7 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 7; # increment this value for each test you create
use Test::More tests => 10; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -27,6 +27,10 @@ $session->setting->set("inmate","37927");
my ($value) = $session->db->quickArray("select value from settings where name='inmate'");
is($value, '37927', "set()");
is($session->setting->get("inmate"), '37927', 'set() also updates object cache');
is($session->setting->has('inmate'), 1, 'has checks for existance');
$session->setting->set('inmate', 0);
is($session->setting->get('inmate'), 0, 'get will get 0 values');
is($session->setting->has('inmate'), 1, 'has checks for existance, regardless of value');
$session->setting->remove("inmate");
my ($value) = $session->db->quickArray("select value from settings where name='inmate'");
is($value, undef, "delete()");