2
2
3
3
use warnings;
4
4
use strict;
5
- use Test::More tests => 14;
5
+ use Test::More;
6
+ use Test::Warn qw( warning_like ) ;
6
7
use URI::file ();
7
8
8
9
BEGIN {
@@ -32,19 +33,23 @@ $form = $mech->current_form();
32
33
# Multi-select
33
34
34
35
# pass multiple values to a multi select
36
+ $form -> param(' multilist' , undef );
35
37
$mech -> select(' multilist' , \@sendmulti );
36
38
@return = $form -> param(' multilist' );
37
39
is_deeply(\@return , \@sendmulti , ' multi->multi value is ' . join (' ' , @return ));
38
40
41
+ $form -> param(' multilist' , undef );
39
42
$mech -> select(' multilist' , \%sendmulti );
40
43
@return = $form -> param(' multilist' );
41
44
is_deeply(\@return , \@sendmulti , ' multi->multi value is ' . join (' ' , @return ));
42
45
43
46
# pass a single value to a multi select
47
+ $form -> param(' multilist' , undef );
44
48
$mech -> select(' multilist' , $sendsingle );
45
49
$return = $form -> param(' multilist' );
46
50
is($return , $sendsingle , " single->multi value is '$return '" );
47
51
52
+ $form -> param(' multilist' , undef );
48
53
$mech -> select(' multilist' , \%sendsingle );
49
54
$return = $form -> param(' multilist' );
50
55
is($return , $sendsingle , " single->multi value is '$return '" );
@@ -53,29 +58,33 @@ is($return, $sendsingle, "single->multi value is '$return'");
53
58
# Single select
54
59
55
60
# pass multiple values to a single select (only the _first_ should be set)
61
+ $form -> param(' singlelist' , undef );
56
62
$mech -> select(' singlelist' , \@sendmulti );
57
63
@return = $form -> param(' singlelist' );
58
64
is_deeply(\@return , \@singlereturn , ' multi->single value is ' . join (' ' , @return ));
59
65
66
+ $form -> param(' singlelist' , undef );
60
67
$mech -> select(' singlelist' , \%sendmulti );
61
68
@return = $form -> param(' singlelist' );
62
69
is_deeply(\@return , \@singlereturn , ' multi->single value is ' . join (' ' , @return ));
63
70
64
71
65
72
# pass a single value to a single select
73
+ $form -> param(' singlelist' , undef );
66
74
$rv = $mech -> select(' singlelist' , $sendsingle );
67
75
$return = $form -> param(' singlelist' );
68
76
is($return , $sendsingle , " single->single value is '$return '" );
69
77
78
+ $form -> param(' singlelist' , undef );
70
79
$rv = $mech -> select(' singlelist' , \%sendsingle );
71
80
$return = $form -> param(' singlelist' );
72
81
is($return , $sendsingle , " single->single value is '$return '" );
73
82
74
83
# test return value from $mech->select
75
84
is($rv , 1, ' return 1 after successful select' );
76
85
77
- EAT_THE_WARNING: { # Mech complains about the non-existent field
78
- local $SIG { __WARN__ } = sub {} ;
79
- $rv = $mech -> select( ' missing_list ' , 1 );
80
- }
81
- is( $rv , undef , ' return undef after failed select ' ) ;
86
+ warning_like { $rv = $mech -> select( ' missing_list ' , 1 ) } qr / not found / ,
87
+ ' warning when field is not found ' ;
88
+ is( $rv , undef , ' return undef after failed select' );
89
+
90
+ done_testing ;
0 commit comments