File: 21_disable_fields.t

package info (click to toggle)
libhtml-fillinform-perl 2.22-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 356 kB
  • sloc: perl: 649; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 967 bytes parent folder | download | duplicates (4)
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
#!/usr/local/bin/perl

# contributed by Trevor Schellhorn

use strict;
use warnings FATAL => 'all';

use Test::More tests => 5;

use_ok('HTML::FillInForm');

my $html = qq[
<form>
<input type="text" name="one" value="not disturbed">
<input type="text" name="two" value="not disturbed">
</form>
];

my $result = HTML::FillInForm->new->fill(
					 scalarref => \$html,
					 fdat => {
					   two => "new val 2",
					 },
					 disable_fields => [qw(two)],
					 );

ok($result =~ /not disturbed/ && $result =~ /\bone/,'don\'t disable 1');
ok($result =~ /new val 2/ && $result =~ /\btwo/ && $result =~ /disabled="disabled"/,'disable 2');
$result = HTML::FillInForm->new->fill(
					 scalarref => \$html,
					 fdat => {
					   two => "new val 2",
					 },
					 disable_fields => 'two',
					 );

ok($result =~ /not disturbed/ && $result =~ /\bone/,'don\'t disable 1');
ok($result =~ /new val 2/ && $result =~ /\btwo/ && $result =~ /disabled="disabled"/,'disable 2');