Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added more tests

  • Loading branch information...
commit b4b3737211db79c956657fce762c528ded2ccb7d 1 parent fcb69bc
Al Newkirk authored
7  CHANGES
@@ -6,6 +6,13 @@ TODO (TBD)
6 6
     ? write new POD about cooperating with existing OO systems
7 7
     ? added a "TODO" section of POD to the main module
8 8
 
  9
+7.69 (2012-06-24)
  10
+    * added more tests
  11
+
  12
+7.68 (2012-06-20)
  13
+    * updated some tests
  14
+    * fixed plugin function and POD -- works better (with discovery)
  15
+
9 16
 7.67 (2012-06-20)
10 17
     * misc POD changes
11 18
 
2  Makefile.PL
@@ -27,7 +27,7 @@ my %WriteMakefileArgs = (
27 27
     "Module::Runtime" => 0,
28 28
     "utf8" => 0
29 29
   },
30  
-  "VERSION" => "7.67",
  30
+  "VERSION" => "7.69",
31 31
   "test" => {
32 32
     "TESTS" => "t/*.t t/regression/*.t t/regression/filters/*.t t/regression/validators/*.t"
33 33
   }
2  README
@@ -3,7 +3,7 @@ NAME
3 3
     Framework
4 4
 
5 5
 VERSION
6  
-    version 7.67
  6
+    version 7.69
7 7
 
8 8
 SYNOPSIS
9 9
         package MyApp::User;
2  README.mkdn
Source Rendered
@@ -4,7 +4,7 @@ Validation::Class - Self-Validating Object System and Data Validation Framework
4 4
 
5 5
 # VERSION
6 6
 
7  
-version 7.67
  7
+version 7.69
8 8
 
9 9
 # SYNOPSIS
10 10
 
2  dist.ini
@@ -4,7 +4,7 @@ author              = Al Newkirk <anewkirk@ana.io>
4 4
 license             = Perl_5
5 5
 copyright_holder    = Al Newkirk
6 6
 copyright_year      = 2011
7  
-version             = 7.67
  7
+version             = 7.69
8 8
 
9 9
 [MetaResources]
10 10
 homepage            = https://github.com/alnewkirk/Validation-Class
4  lib/Validation/Class.pm
@@ -965,7 +965,7 @@ sub load {
965 965
                 
966 966
                 $plugin =~ s/^\+//;
967 967
                 
968  
-                use_module $plugin;
  968
+                eval { use_module $plugin };
969 969
                 
970 970
             }
971 971
             
@@ -994,7 +994,7 @@ sub load {
994 994
                 
995 995
                 foreach my $role (@roles) {
996 996
                     
997  
-                    use_module $role;
  997
+                    eval { use_module $role };
998 998
                     
999 999
                     no strict 'refs';
1000 1000
                     
40  lib/Validation/Class/Prototype.pm
@@ -3123,7 +3123,14 @@ class.
3123 3123
     # get object for Class::Plugin::Form::Elements;
3124 3124
     # note the leading character/delimiter
3125 3125
     
3126  
-    my $plugin = $input->plugin(':class:plugin:form:elements'); 
  3126
+    # automatically resolves to the first matching namespace for $self
  3127
+    # or Validation::Class::Plugin 
  3128
+    
  3129
+    my $plugin = $input->plugin('plugin:form:elements');
  3130
+    
  3131
+    # prefix with a special character to denote a fully-qualified namespace
  3132
+    
  3133
+    my $plugin = $input->plugin('+class:plugin:form:elements'); 
3127 3134
     
3128 3135
     # same as $input->proto->plugins->{'Class::Plugin::Form::Elements'};
3129 3136
     
@@ -3150,9 +3157,36 @@ sub plugin {
3150 3157
             
3151 3158
         }
3152 3159
         
3153  
-        ! $parts[0] ? shift @parts : push @parts, 'Validation::Class::Plugin';
  3160
+        if (!$parts[0]) {
  3161
+            
  3162
+            shift @parts;
  3163
+            
  3164
+            $class = join "::", @parts;
  3165
+            
  3166
+        }
3154 3167
         
3155  
-        $class = join "::", @parts;
  3168
+        else {
  3169
+            
  3170
+            my @rootspaces = (
  3171
+                
  3172
+                $self->{package},
  3173
+                'Validation::Class::Plugin'
  3174
+                
  3175
+            );
  3176
+            
  3177
+            my $matched = 0;
  3178
+            
  3179
+            foreach my $rootspace (@rootspaces) {
  3180
+            
  3181
+                $class = join "::", $rootspace, @parts;
  3182
+                
  3183
+                eval '$matched = $class->can("new") ? 1 : 0';
  3184
+                
  3185
+                last if $matched;
  3186
+            
  3187
+            }
  3188
+            
  3189
+        }
3156 3190
         
3157 3191
     }
3158 3192
     
214  t/00-load.t
@@ -6,6 +6,8 @@ BEGIN {
6 6
 }
7 7
 
8 8
 use Test::More;
  9
+use Validation::Class ();
  10
+use Validation::Class::Prototype ();
9 11
 
10 12
 {
11 13
     
@@ -41,57 +43,15 @@ use Test::More;
41 43
     "TestClass::Hack instantiated, via the setup hack";
42 44
     
43 45
     ok ! $class->can($_),
44  
-    "TestClass::Hack has NOT been injected with the $_ method" for qw/
45  
-        attribute
46  
-        bld
47  
-        build
48  
-        dir
49  
-        directive
50  
-        fld
51  
-        field
52  
-        flt
53  
-        filter
54  
-        has
55  
-        load
56  
-        mth
57  
-        method
58  
-        mxn
59  
-        mixin
60  
-        pro
61  
-        profile
62  
-        set
63  
-    /;
  46
+    "TestClass::Hack has NOT been injected with the $_ method"
  47
+    for @Validation::Class::EXPORT;
64 48
     
65 49
     ok $class->can($_),
66  
-    "TestClass::Hack has been injected with the $_ method" for qw/
67  
-        new
68  
-        proto
69  
-        prototype
70  
-        
71  
-        class
72  
-        clear_queue
73  
-        error
74  
-        error_count
75  
-        error_fields
76  
-        errors
77  
-        errors_to_string
78  
-        get_errors
79  
-        fields
80  
-        filtering
81  
-        ignore_failure
82  
-        ignore_unknown
83  
-        param
84  
-        params
85  
-        queue
86  
-        report_failure
87  
-        report_unknown
88  
-        reset_errors
89  
-        set_errors
90  
-        stash
91  
-        
92  
-        validate
93  
-        validate_profile
94  
-    /;
  50
+    "TestClass::Hack has been injected with the $_ method"
  51
+    for qw/new proto prototype/,
  52
+        @Validation::Class::Prototype::proxy_methods,
  53
+        @Validation::Class::Prototype::proxy_methods_wrapped
  54
+    ;
95 55
     
96 56
 }
97 57
 
@@ -110,57 +70,15 @@ use Test::More;
110 70
     "TestClass::Traditional instantiated, via the setup hack";
111 71
     
112 72
     ok $class->can($_),
113  
-    "TestClass::Traditional has been injected with the $_ method" for qw/
114  
-        attribute
115  
-        bld
116  
-        build
117  
-        dir
118  
-        directive
119  
-        fld
120  
-        field
121  
-        flt
122  
-        filter
123  
-        has
124  
-        load
125  
-        mth
126  
-        method
127  
-        mxn
128  
-        mixin
129  
-        pro
130  
-        profile
131  
-        set
132  
-    /;
  73
+    "TestClass::Traditional has been injected with the $_ method"
  74
+    for @Validation::Class::EXPORT;
133 75
     
134 76
     ok $class->can($_),
135  
-    "TestClass::Traditional has been injected with the $_ method" for qw/
136  
-        new
137  
-        proto
138  
-        prototype
139  
-        
140  
-        class
141  
-        clear_queue
142  
-        error
143  
-        error_count
144  
-        error_fields
145  
-        errors
146  
-        errors_to_string
147  
-        get_errors
148  
-        fields
149  
-        filtering
150  
-        ignore_failure
151  
-        ignore_unknown
152  
-        param
153  
-        params
154  
-        queue
155  
-        report_failure
156  
-        report_unknown
157  
-        reset_errors
158  
-        set_errors
159  
-        stash
160  
-        
161  
-        validate
162  
-        validate_profile
163  
-    /;
  77
+    "TestClass::Traditional has been injected with the $_ method"
  78
+    for qw/new proto prototype/,
  79
+        @Validation::Class::Prototype::proxy_methods,
  80
+        @Validation::Class::Prototype::proxy_methods_wrapped
  81
+    ;
164 82
     
165 83
 }
166 84
 
@@ -269,28 +187,30 @@ use Test::More;
269 187
     
270 188
     no warnings 'redefine';
271 189
     
272  
-    sub attribute       { 'noop' }
273  
-    sub bld             { 'noop' }
274  
-    sub build           { 'noop' }
275  
-    sub dir             { 'noop' }
276  
-    sub directive       { 'noop' }
277  
-    sub fld             { 'noop' }
278  
-    sub field           { 'noop' }
279  
-    sub flt             { 'noop' }
280  
-    sub filter          { 'noop' }
281  
-    sub has             { 'noop' }
282  
-    sub load            { 'noop' }
283  
-    sub mth             { 'noop' }
284  
-    sub method          { 'noop' }
285  
-    sub mxn             { 'noop' }
286  
-    sub mixin           { 'noop' }
287  
-    sub pro             { 'noop' }
288  
-    sub profile         { 'noop' }
289  
-    sub set             { 'noop' }
  190
+    sub attribute        { 'noop' }
  191
+    sub bld              { 'noop' }
  192
+    sub build            { 'noop' }
  193
+    sub dir              { 'noop' }
  194
+    sub directive        { 'noop' }
  195
+    sub fld              { 'noop' }
  196
+    sub field            { 'noop' }
  197
+    sub flt              { 'noop' }
  198
+    sub filter           { 'noop' }
  199
+    sub has              { 'noop' }
  200
+    sub load             { 'noop' }
  201
+    sub mth              { 'noop' }
  202
+    sub method           { 'noop' }
  203
+    sub mxn              { 'noop' }
  204
+    sub mixin            { 'noop' }
  205
+    sub obj              { 'noop' }
  206
+    sub object           { 'noop' }
  207
+    sub pro              { 'noop' }
  208
+    sub profile          { 'noop' }
  209
+    sub set              { 'noop' }
290 210
 
291  
-    sub new             { 'noop' }
292  
-    sub proto           { 'noop' }
293  
-    sub prototype       { 'noop' }
  211
+    sub new              { 'noop' }
  212
+    sub proto            { 'noop' }
  213
+    sub prototype        { 'noop' }
294 214
 
295 215
     sub class            { 'noop' }
296 216
     sub clear_queue      { 'noop' }
@@ -323,57 +243,15 @@ use Test::More;
323 243
     ok "TestClass::Overrider" eq ref $class, "TestClass::Overrider instantiated";
324 244
     
325 245
     ok 'noop' eq $class->$_,
326  
-    "TestClass::Overrider method $_ method was overriden" for qw/
327  
-        attribute
328  
-        bld
329  
-        build
330  
-        dir
331  
-        directive
332  
-        fld
333  
-        field
334  
-        flt
335  
-        filter
336  
-        has
337  
-        load
338  
-        mth
339  
-        method
340  
-        mxn
341  
-        mixin
342  
-        pro
343  
-        profile
344  
-        set
345  
-    /;
  246
+    "TestClass::Overrider method $_ method was overriden"
  247
+    for @Validation::Class::EXPORT;
346 248
     
347 249
     ok ! do { eval { 1 if 'noop' eq $class->$_ }; $@ },
348  
-    "TestClass::Overrider method $_ method was overriden" for qw/
349  
-        new
350  
-        proto
351  
-        prototype
352  
-        
353  
-        class
354  
-        clear_queue
355  
-        error
356  
-        error_count
357  
-        error_fields
358  
-        errors
359  
-        errors_to_string
360  
-        get_errors
361  
-        fields
362  
-        filtering
363  
-        ignore_failure
364  
-        ignore_unknown
365  
-        param
366  
-        params
367  
-        queue
368  
-        report_failure
369  
-        report_unknown
370  
-        reset_errors
371  
-        set_errors
372  
-        stash
373  
-        
374  
-        validate
375  
-        validate_profile
376  
-    /;
  250
+    "TestClass::Overrider method $_ method was overriden"
  251
+    for qw/new proto prototype/,
  252
+        @Validation::Class::Prototype::proxy_methods,
  253
+        @Validation::Class::Prototype::proxy_methods_wrapped
  254
+    ;
377 255
     
378 256
 }
379 257
 
3  t/01-access.t
@@ -159,8 +159,7 @@ use Test::More;
159 159
     ok $accessors[1] eq 'name_last',    "$class has the name_last accessor";
160 160
     ok $accessors[2] eq 'name_phone_0', "$class has the name_phone_0 accessor";
161 161
     ok $accessors[3] eq 'name_phone_1', "$class has the name_phone_1 accessor";
162  
-    ok $accessors[4] eq 'name_phone_2', "$class has the name_phone_2 accessor";
163  
-    
  162
+    ok $accessors[4] eq 'name_phone_2', "$class has the name_phone_2 accessor";    
164 163
     
165 164
 }
166 165
 
84  t/10-attribute-method.t
... ...
@@ -0,0 +1,84 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the attribute method
  14
+    # this method is designed to add accessors to the calling class
  15
+    # this method can also be referred to as has()
  16
+    
  17
+    package MyApp;
  18
+    
  19
+    use Validation::Class;
  20
+    
  21
+    attribute name => 'Thomas';
  22
+    attribute sex  => 'M';
  23
+    
  24
+    has age => 23;
  25
+    
  26
+    attribute type => sub {
  27
+        my ($self) = @_;
  28
+        if ($self->age > 21) {
  29
+            if ($self->sex eq 'M') {
  30
+                return 'Man'
  31
+            }
  32
+            if ($self->sex eq 'M') {
  33
+                return 'Woman'
  34
+            }
  35
+        }
  36
+        else {
  37
+            if ($self->sex eq 'M') {
  38
+                return 'Boy'
  39
+            }
  40
+            if ($self->sex eq 'M') {
  41
+                return 'Girl'
  42
+            }
  43
+        }
  44
+    };
  45
+    
  46
+    has slang_type => sub {
  47
+        my ($self) = @_;
  48
+        if ($self->age > 21) {
  49
+            if ($self->sex eq 'M') {
  50
+                return 'Oldhead'
  51
+            }
  52
+            if ($self->sex eq 'M') {
  53
+                return 'Oldjawn'
  54
+            }
  55
+        }
  56
+        else {
  57
+            if ($self->sex eq 'M') {
  58
+                return 'Youngbawl'
  59
+            }
  60
+            if ($self->sex eq 'M') {
  61
+                return 'Youngjawn'
  62
+            }
  63
+        }
  64
+    };
  65
+    
  66
+    __PACKAGE__->attribute(class => 'upper'); # override the existing class method
  67
+    
  68
+    package main;
  69
+    
  70
+    my $class = "MyApp";
  71
+    my $self  = $class->new;
  72
+    
  73
+    ok $class eq ref $self, "$class instantiated";
  74
+    
  75
+    ok 'Thomas' eq $self->name, 'The name attribute has the correct value';
  76
+    ok 'M' eq $self->sex, 'The sex attribute has the correct value';
  77
+    ok 23 eq $self->age, 'The age attribute has the correct value';
  78
+    ok 'Man' eq $self->type, 'The type attribute has the correct value';
  79
+    ok 'Oldhead' eq $self->slang_type, 'The slang_type attribute has the correct value';
  80
+    ok 'upper' eq $self->class, 'The class attribute has the correct value';
  81
+    
  82
+}
  83
+
  84
+done_testing;
45  t/10-build-method.t
... ...
@@ -0,0 +1,45 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the build method
  14
+    # this method is designed to hook into the class instantiation processs
  15
+    
  16
+    package MyApp;
  17
+    
  18
+    use Validation::Class;
  19
+    
  20
+    has number => 0;
  21
+    
  22
+    my $incrementer = sub {
  23
+    
  24
+        my ($self) = @_;
  25
+        
  26
+        $self->number($self->number + 1);
  27
+    
  28
+    };
  29
+    
  30
+    build $incrementer;
  31
+    
  32
+    __PACKAGE__->bld($incrementer);
  33
+    
  34
+    package main;
  35
+    
  36
+    my $class = "MyApp";
  37
+    my $self  = $class->new();
  38
+    
  39
+    ok $class eq ref $self, "$class instantiated";
  40
+    
  41
+    ok 2 == $self->number, 'the number attribute has been incremented on init';
  42
+    
  43
+}
  44
+
  45
+done_testing;
68  t/10-directive-method.t
... ...
@@ -0,0 +1,68 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the directive method
  14
+    # this method is designed to register field directives which V::C will make
  15
+    # available to all classes when instantiated
  16
+    
  17
+    package MyApp1;
  18
+    
  19
+    use Validation::Class;
  20
+    
  21
+    dir is_true => sub { 1 };
  22
+    fld name    => { is_true => 1, required => 1, };
  23
+    
  24
+    package MyApp2;
  25
+    
  26
+    use Validation::Class;
  27
+    
  28
+    directive is_true => sub { 1 };
  29
+    field name => { is_true => 1, required => 1, };
  30
+    
  31
+    package MyApp3;
  32
+    
  33
+    use Validation::Class;
  34
+    
  35
+    fld name => {
  36
+    
  37
+        is_true  => 1,
  38
+        required => 1,
  39
+    
  40
+    };
  41
+    
  42
+    package main;
  43
+    
  44
+    my ($class, $self);
  45
+    
  46
+    $class = "MyApp1";
  47
+    $self  = $class->new(name => "...");
  48
+    
  49
+    ok $class eq ref $self, "$class instantiated";
  50
+    
  51
+    $self  = undef;
  52
+    
  53
+    $class = "MyApp2";
  54
+    $self  = $class->new(name => "...");
  55
+    
  56
+    ok $class eq ref $self, "$class instantiated";
  57
+    
  58
+    $self  = undef;
  59
+    
  60
+    $class = "MyApp3";
  61
+    eval { $self  = $class->new(name => "...") };
  62
+    
  63
+    ok $@ =~ /directive.*not supported/,
  64
+        "$class NOT instantiated, bad directive";
  65
+    
  66
+}
  67
+
  68
+done_testing;
0  t/03-field-object.t → t/10-field-method.t
File renamed without changes
35  t/10-filter-method.t
... ...
@@ -0,0 +1,35 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the filter method
  14
+    # this method is designed to ....
  15
+    
  16
+    package MyApp;
  17
+    
  18
+    use Validation::Class;
  19
+    
  20
+    fld name => {
  21
+    
  22
+        required => 1
  23
+    
  24
+    };
  25
+    
  26
+    package main;
  27
+    
  28
+    my $class = "MyApp";
  29
+    my $self  = $class->new(name => "...");
  30
+    
  31
+    ok $class eq ref $self, "$class instantiated";
  32
+    
  33
+}
  34
+
  35
+done_testing;
57  t/10-initialize-method.t
... ...
@@ -0,0 +1,57 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the initialize method
  14
+    # this method is designed to allow the Validation::Class framework to wrap
  15
+    # an existing class configuration, most useful with OO systems like Moose, etc
  16
+    
  17
+    package MyApp;
  18
+    
  19
+    sub new {
  20
+        
  21
+        my ($class) = @_;
  22
+        
  23
+        my $self = bless {}, $class;
  24
+        
  25
+        return $self;
  26
+        
  27
+    }
  28
+    
  29
+    use Validation::Class 'field';
  30
+    
  31
+    field name => {
  32
+    
  33
+        required => 1
  34
+    
  35
+    };
  36
+    
  37
+    package main;
  38
+    
  39
+    my $class = "MyApp";
  40
+    
  41
+    my $self  = $class->new(name => "...");
  42
+    
  43
+    ok $class eq ref $self, "$class instantiated";
  44
+    
  45
+    eval { $self->name };
  46
+    
  47
+    ok $@, "$class has no name field";
  48
+    
  49
+    $self->initialize;
  50
+    
  51
+    eval { $self->name };
  52
+    
  53
+    ok !$@, "$class has a name field";
  54
+    
  55
+}
  56
+
  57
+done_testing;
6  t/03-keyword-load.t → t/10-load-method.t
@@ -18,9 +18,8 @@ use Test::More;
18 18
     
19 19
     use Validation::Class;
20 20
     
21  
-    set classes => 1;
22  
-    
23  
-    fld name => {
  21
+    load  classes   => 1;
  22
+    field name      => {
24 23
     
25 24
         required => 1
26 25
     
@@ -29,6 +28,7 @@ use Test::More;
29 28
     package main;
30 29
     
31 30
     my $class = "MyApp";
  31
+    
32 32
     my $self  = $class->new(name => "don johnson");
33 33
     
34 34
     ok $class eq ref $self, "$class instantiated";
48  t/10-method-method.t
... ...
@@ -0,0 +1,48 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the method method
  14
+    # this method is designed to ....
  15
+    
  16
+    package MyApp;
  17
+    
  18
+    use Validation::Class;
  19
+    
  20
+    fld name => {
  21
+    
  22
+        required => 1
  23
+    
  24
+    };
  25
+    
  26
+    mth print_name => {
  27
+        input => ['name'],
  28
+        using => sub {
  29
+            my ($self) = @_;
  30
+            return "my name is " . $self->name
  31
+        }
  32
+    };
  33
+    
  34
+    package main;
  35
+    
  36
+    my $class = "MyApp";
  37
+    my $self  = $class->new();
  38
+    
  39
+    ok $class eq ref $self, "$class instantiated";
  40
+    ok !$self->print_name, "no name printed because the name field is null";
  41
+    
  42
+    $self->name("echo");
  43
+    
  44
+    ok "my name is echo" eq $self->print_name, "name printed as intended";
  45
+    
  46
+}
  47
+
  48
+done_testing;
35  t/10-mixin-method.t
... ...
@@ -0,0 +1,35 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the mixin method
  14
+    # this method is designed to ....
  15
+    
  16
+    package MyApp;
  17
+    
  18
+    use Validation::Class;
  19
+    
  20
+    fld name => {
  21
+    
  22
+        required => 1
  23
+    
  24
+    };
  25
+    
  26
+    package main;
  27
+    
  28
+    my $class = "MyApp";
  29
+    my $self  = $class->new(name => "...");
  30
+    
  31
+    ok $class eq ref $self, "$class instantiated";
  32
+    
  33
+}
  34
+
  35
+done_testing;
35  t/10-object-method.t
... ...
@@ -0,0 +1,35 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the object method
  14
+    # this method is designed to ....
  15
+    
  16
+    package MyApp;
  17
+    
  18
+    use Validation::Class;
  19
+    
  20
+    fld name => {
  21
+    
  22
+        required => 1
  23
+    
  24
+    };
  25
+    
  26
+    package main;
  27
+    
  28
+    my $class = "MyApp";
  29
+    my $self  = $class->new(name => "...");
  30
+    
  31
+    ok $class eq ref $self, "$class instantiated";
  32
+    
  33
+}
  34
+
  35
+done_testing;
35  t/10-profile-method.t
... ...
@@ -0,0 +1,35 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the profile method
  14
+    # this method is designed to ....
  15
+    
  16
+    package MyApp;
  17
+    
  18
+    use Validation::Class;
  19
+    
  20
+    fld name => {
  21
+    
  22
+        required => 1
  23
+    
  24
+    };
  25
+    
  26
+    package main;
  27
+    
  28
+    my $class = "MyApp";
  29
+    my $self  = $class->new(name => "...");
  30
+    
  31
+    ok $class eq ref $self, "$class instantiated";
  32
+    
  33
+}
  34
+
  35
+done_testing;
35  t/10-prototype-method.t
... ...
@@ -0,0 +1,35 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use utf8;
  9
+use Test::More;
  10
+
  11
+{
  12
+    
  13
+    # testing the prototype method
  14
+    # this method is designed to ....
  15
+    
  16
+    package MyApp;
  17
+    
  18
+    use Validation::Class;
  19
+    
  20
+    fld name => {
  21
+    
  22
+        required => 1
  23
+    
  24
+    };
  25
+    
  26
+    package main;
  27
+    
  28
+    my $class = "MyApp";
  29
+    my $self  = $class->new(name => "...");
  30
+    
  31
+    ok $class eq ref $self, "$class instantiated";
  32
+    
  33
+}
  34
+
  35
+done_testing;
1  t/02-keyword-object.t → t/90-dbi-via-object.t
@@ -62,6 +62,7 @@ sub connect {
62 62
 
63 63
 }
64 64
 
  65
+1;
65 66
 CLASS
66 67
     
67 68
     package main;
0  t/09-modifiers.t → t/90-method-modifiers.t
File renamed without changes
55  t/90-plugin-access.t
... ...
@@ -0,0 +1,55 @@
  1
+BEGIN {
  2
+    
  3
+    use FindBin;
  4
+    use lib $FindBin::Bin . "/myapp/lib";
  5
+    
  6
+}
  7
+
  8
+use Test::More;
  9
+
  10
+SKIP: {
  11
+    
  12
+    eval { require 'Validation/Class/Plugin/FormFields.pm' };
  13
+    
  14
+    $@ ?
  15
+        plan skip_all => 'Validation::Class::Plugin::FormFields is not installed.' :
  16
+        eval <<'CLASS';
  17
+package TestClass::WithPlugins::Plugin::Test001;
  18
+
  19
+use Validation::Class 'has';
  20
+
  21
+has one => 1;
  22
+
  23
+package TestClass::WithPlugins;
  24
+
  25
+use Validation::Class;
  26
+set plugins => [
  27
+    'FormFields',
  28
+    '+TestClass::WithPlugins::Plugin::Test001'
  29
+];
  30
+
  31
+fld name => {
  32
+    required => 1
  33
+};
  34
+
  35
+1;
  36
+CLASS
  37
+
  38
+    package main;
  39
+    
  40
+    my $class = "TestClass::WithPlugins";
  41
+    my $self  = $class->new;
  42
+    
  43
+    ok $class eq ref $self, "$class instantiated";
  44
+    
  45
+    my $forms = $self->plugin('form_fields');
  46
+    
  47
+    ok $forms, 'plugin method returned a true value for form_fields';
  48
+    
  49
+    my $test1 = $self->plugin('plugin:test001');
  50
+    
  51
+    ok $test1, 'plugin method returned a true value for form_fields';
  52
+    
  53
+}
  54
+
  55
+done_testing;

0 notes on commit b4b3737

Please sign in to comment.
Something went wrong with that request. Please try again.