File: 28_defaults_for_new.t

package info (click to toggle)
libdata-formvalidator-perl 4.66-1%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 588 kB
  • ctags: 127
  • sloc: perl: 2,756; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 782 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# testing passing defaults to the new constructor. -mls 05/03/03 

use Test::More tests => 3;
use strict;

use Data::FormValidator; 

my %FORM = (
	bad_email  => 'oops',
	good_email => 'great@domain.com',

	'short_name' => 'tim',
);

my $dfv = Data::FormValidator->new({},{ missing_optional_valie => 1 });

eval {
	my $results = $dfv->check(\%FORM, {});
};
like($@,qr/Invalid input profile/, 'defaults are checked for syntax');


$dfv = Data::FormValidator->new({},{ missing_optional_valid=>1 });
my $results = $dfv->check(\%FORM, {});
ok ($results->{profile}->{missing_optional_valid}, 'testing defaults appearing in profile');

$results = $dfv->check(\%FORM, { missing_optional_valid=>0});

ok (!$results->{profile}->{missing_optional_valid}, 'testing overriding defaults');