Debian Codegraph @

t/legacy/regression/04-profile-usages.t

raw symbols SCIP
1 BEGIN {
2 use FindBinscip-perl cpan Validation-Class 7.900059 FindBin/;
3 use libscip-perl cpan Validation-Class 7.900059 lib/ $FindBin::Bin. "/modules/";
4 }
5
6 use Test::Morescip-perl cpan Validation-Class 7.900059 Test/More/ tests => 12;
7
8 package MyValAltscip-perl cpan Validation-Class 7.900059 MyValAlt/;
9
10 use Validation::Classscip-perl cpan Validation-Class 7.900059 Validation/Class/;
11
12 mixin ID => {
13 required => 1,
14 min_length => 1,
15 max_length => 11
16 };
17
18 mixin TEXT => {
19 required => 1,
20 min_length => 1,
21 max_length => 255,
22 filters => [qw/trim strip/]
23 };
24
25 mixin UTEXT => {
26 required => 1,
27 min_length => 1,
28 max_length => 255,
29 filters => 'uppercase'
30 };
31
32 fieldscip-perl cpan Validation-Class 7.900059 MyValAlt/field(). id => {
33 mixin => 'ID',
34 label => 'Object ID',
35 error => 'Object ID error'
36 };
37
38 fieldscip-perl cpan Validation-Class 7.900059 MyValAlt/field(). name => {
39 mixin => 'TEXT',
40 label => 'Object Name',
41 error => 'Object Name error',
42 filters => ['uppercase']
43 };
44
45 fieldscip-perl cpan Validation-Class 7.900059 MyValAlt/field(). handle => {
46 mixin => 'UTEXT',
47 label => 'Object Handle',
48 error => 'Object Handle error',
49 filters => [qw/trim strip/]
50 };
51
52 fieldscip-perl cpan Validation-Class 7.900059 MyValAlt/field(). email => {
53 mixin => 'TEXT',
54 label => 'Object Email',
55 error => 'Object Email error',
56 max_length => 500
57 };
58
59 fieldscip-perl cpan Validation-Class 7.900059 MyValAlt/field(). email_confirm => {
60 mixin_field => 'email',
61 label => 'Object Email Confirm',
62 error => 'Object Email confirmation error',
63 min_length => 5
64 };
65
66 profilescip-perl cpan Validation-Class 7.900059 MyValAlt/profile(). email_change => sub {
67
68 my ($self, $hash) = @_scip-perl cpan Validation-Class 7.900059 MyValAlt/`@_`.;
69
70 $self->validatescip-perl cpan Validation-Class 7.900059 MyValAlt/validate().('+email', '+email_confirm');
71
72 return $self->error_countscip-perl cpan Validation-Class 7.900059 MyValAlt/error_count(). && keysscip-perl cpan Validation-Class 7.900059 MyValAlt/keys(). %{$hash} ? 1 : 0;
73
74 };
75
76 package mainscip-perl cpan Validation-Class 7.900059 main/;
77
78 use MyValscip-perl cpan Validation-Class 7.900059 MyVal/;
79
80 my $v1 = MyValAlt->newscip-perl cpan Validation-Class 7.900059 MyValAlt/new().(params => {});
81
82 okscip-perl cpan Validation-Class 7.900059 main/ok(). $v1, 'initialization successful';
83 ok !$v1->validate_profilescip-perl cpan Validation-Class 7.900059 MyValAlt/validate_profile().('email_change'),
84 'email_change profile did not validate';
85 okscip-perl cpan Validation-Class 7.900059 main/ok(). $v1->error_countscip-perl cpan Validation-Class 7.900059 MyValAlt/error_count(). == 2, '2 errors encountered on failure';
86
87 $v1->paramsscip-perl cpan Validation-Class 7.900059 MyValAlt/params().->{email} = 'abc';
88 $v1->paramsscip-perl cpan Validation-Class 7.900059 MyValAlt/params().->{email_confirm} = 'abc';
89
90 ok !$v1->validate_profilescip-perl cpan Validation-Class 7.900059 MyValAlt/validate_profile().('email_change'),
91 'email_change profile did not validate';
92 okscip-perl cpan Validation-Class 7.900059 main/ok(). $v1->validate_profilescip-perl cpan Validation-Class 7.900059 MyValAlt/validate_profile().('email_change', {this => 'that'}),
93 'email_change profile validated OK';
94
95 my $v2 = MyVal->newscip-perl cpan Validation-Class 7.900059 MyVal/new().(params => {});
96
97 ok !$v2->validate_profilescip-perl cpan Validation-Class 7.900059 MyVal/validate_profile().('new_ticket'), 'new_ticket profile did not validate';
98 okscip-perl cpan Validation-Class 7.900059 main/ok(). $v2->error_countscip-perl cpan Validation-Class 7.900059 MyVal/error_count(). == 2, '2 errors encountered on failure';
99
100 $v2->paramscip-perl cpan Validation-Class 7.900059 MyVal/param().(name => 'the dude');
101
102 ok !$v2->validate_profilescip-perl cpan Validation-Class 7.900059 MyVal/validate_profile().('new_ticket'), 'new_ticket profile did not validate';
103 okscip-perl cpan Validation-Class 7.900059 main/ok(). $v2->error_countscip-perl cpan Validation-Class 7.900059 MyVal/error_count(). == 1, '1 errors encountered on failure';
104
105 $v2->paramscip-perl cpan Validation-Class 7.900059 MyVal/param().(description => 'the bomb dot com');
106
107 okscip-perl cpan Validation-Class 7.900059 main/ok(). $v2->validate_profilescip-perl cpan Validation-Class 7.900059 MyVal/validate_profile().('new_ticket'), 'new_ticket profile validated OK';
108 okscip-perl cpan Validation-Class 7.900059 main/ok(). $v2->error_countscip-perl cpan Validation-Class 7.900059 MyVal/error_count(). == 0, 'NO errors set';
109
110 my $v3 = MyVal->newscip-perl cpan Validation-Class 7.900059 MyVal/new().(
111 params => {
112 'person.name' => 'the dude',
113 'ticket.description' => 'hot diggidy dog'
114 }
115 );
116
117 okscip-perl cpan Validation-Class 7.900059 main/ok(). $v3->validate_profilescip-perl cpan Validation-Class 7.900059 MyVal/validate_profile().('new_ticket'), 'new_ticket profile validated OK';