File: any_errors.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 (55 lines) | stat: -rw-r--r-- 1,601 bytes parent folder | download | duplicates (6)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl

use strict;
use Test::More 'no_plan';

use Data::FormValidator;
my $dfv_standard_any_errors = Data::FormValidator->new({});
my $dfv_custom_any_errors   = Data::FormValidator->new({},{msgs => { any_errors => 'some_errors' }});

my %profile = (
    required => 'foo',
);

my %good_input = (
    'foo' => 1,
);
my %bad_input = (
    'bar' => 1,
);

my ($results, $msgs);

# standard 'any_errors', good input
$results = $dfv_standard_any_errors->check(\%good_input, \%profile);
$msgs    = $results->msgs;

ok($results,     "[standard any_errors] good input passed");
ok(!keys %$msgs, "[standard any_errors] no error messages");

# standard 'any_errors', bad input
$results = $dfv_standard_any_errors->check(\%bad_input, \%profile);
$msgs    = $results->msgs;

ok(!$results,    "[standard any_errors] bad input caught");
ok(keys %$msgs,  "[standard any_errors] error messages reported");


# custom 'any_errors', good input
$results = $dfv_custom_any_errors->check(\%good_input, \%profile);
$msgs    = $results->msgs;

ok($results,                "[custom any_errors] good input passed");
ok(!keys %$msgs,            "[custom any_errors] no error messages");
ok(!$msgs->{'some_errors'}, "[custom any_errors] 'some_errors' not reported");

# custom 'any_errors', bad input
$results = $dfv_custom_any_errors->check(\%bad_input, \%profile);
$msgs    = $results->msgs;

ok(!$results,               "[custom any_errors] bad input caught");
ok(keys %$msgs,             "[custom any_errors] error messages reported");
ok($msgs->{'some_errors'},  "[custom any_errors] 'some_errors' reported");