[Bast-commits] r3235 - in trunk/DBIx-Class-Validation: .
lib/DBIx/Class t t/lib t/lib/DBIC t/lib/DBIC/Test
t/lib/DBIC/Test/Schema t/sql
claco at dev.catalyst.perl.org
claco at dev.catalyst.perl.org
Sat May 5 17:23:10 GMT 2007
Author: claco
Date: 2007-05-05 17:23:08 +0100 (Sat, 05 May 2007)
New Revision: 3235
Added:
trunk/DBIx-Class-Validation/t/basic.t
trunk/DBIx-Class-Validation/t/dfv.t
trunk/DBIx-Class-Validation/t/fvs.t
trunk/DBIx-Class-Validation/t/lib/DBIC/
trunk/DBIx-Class-Validation/t/lib/DBIC/Test.pm
trunk/DBIx-Class-Validation/t/lib/DBIC/Test/
trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema.pm
trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema/
trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema/Test.pm
trunk/DBIx-Class-Validation/t/lib/Validator.pm
trunk/DBIx-Class-Validation/t/lib/ValidatorWithoutCheck.pm
trunk/DBIx-Class-Validation/t/manifest.t
trunk/DBIx-Class-Validation/t/pod_coverage.t
trunk/DBIx-Class-Validation/t/pod_spelling.t
trunk/DBIx-Class-Validation/t/pod_syntax.t
trunk/DBIx-Class-Validation/t/sql/
trunk/DBIx-Class-Validation/t/sql/test.sqlite.sql
trunk/DBIx-Class-Validation/t/strict.t
trunk/DBIx-Class-Validation/t/style_no_tabs.t
trunk/DBIx-Class-Validation/t/warnings.t
Removed:
trunk/DBIx-Class-Validation/MANIFEST
trunk/DBIx-Class-Validation/META.yml
trunk/DBIx-Class-Validation/t/02pod.t
trunk/DBIx-Class-Validation/t/03podcoverage.t
trunk/DBIx-Class-Validation/t/04basic.t
trunk/DBIx-Class-Validation/t/05fvs.t
trunk/DBIx-Class-Validation/t/06dfv.t
trunk/DBIx-Class-Validation/t/lib/ValidationTest.pm
trunk/DBIx-Class-Validation/t/lib/ValidationTest/
trunk/DBIx-Class-Validation/t/var/
Modified:
trunk/DBIx-Class-Validation/Build.PL
trunk/DBIx-Class-Validation/Changes
trunk/DBIx-Class-Validation/MANIFEST.SKIP
trunk/DBIx-Class-Validation/Makefile.PL
trunk/DBIx-Class-Validation/README
trunk/DBIx-Class-Validation/lib/DBIx/Class/Validation.pm
Log:
Converted to Module::Install
RT#25356 (bokutin): validation now sets filter
Converted tests away from deprecated compose_connection
Jockey cargo tests, TEST_AUTHOR, DBICTest
Much improved test coverage
Build/test no longer requires SQL::Translator
Modified: trunk/DBIx-Class-Validation/Build.PL
===================================================================
--- trunk/DBIx-Class-Validation/Build.PL 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/Build.PL 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,25 +1,2 @@
-use strict;
-use Module::Build;
-
-my %arguments = (
- create_makefile_pl => 'passthrough',
- license => 'perl',
- module_name => 'DBIx::Class::Validation',
- requires => {
- 'DBIx::Class' => 0.06002,
- 'FormValidator::Simple' => 0.17,
- },
- build_requires => {
- 'DBD::SQLite' => 1.11,
- 'SQL::Translator' => 0.07
- },
- recommends => {
- 'Data::FormValidator' => 0,
- },
- create_makefile_pl => 'passthrough',
- create_readme => 1,
- test_files => [ glob('t/*.t')],
- add_to_cleanup => ['t/var/*']
-);
-
-Module::Build->new(%arguments)->create_build_script;
+# $Id$
+require 'Makefile.PL';
Modified: trunk/DBIx-Class-Validation/Changes
===================================================================
--- trunk/DBIx-Class-Validation/Changes 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/Changes 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,5 +1,13 @@
Revision history for DBIx::Class::Validation
+0.01002 Sat May 05 11:38:16 2007
+ - Converted to Module::Install
+ - RT#25356 (bokutin): validation now sets filter
+ - Converted tests away from deprecated compose_connection
+ - Jockey cargo tests, TEST_AUTHOR, DBICTest
+ - Much improved test coverage
+ - Build/test no longer requires SQL::Translator
+
0.01001 Tue Sep 05 17:54:13 2006
- FormValidator::Simple 0.17 is now required to fix profile destruction
on first use
Deleted: trunk/DBIx-Class-Validation/MANIFEST
===================================================================
--- trunk/DBIx-Class-Validation/MANIFEST 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/MANIFEST 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,16 +0,0 @@
-Build.PL
-Changes
-lib/DBIx/Class/Validation.pm
-Makefile.PL
-MANIFEST This list of files
-MANIFEST.SKIP
-META.yml
-README
-t/02pod.t
-t/03podcoverage.t
-t/04basic.t
-t/05fvs.t
-t/06dfv.t
-t/lib/ValidationTest.pm
-t/lib/ValidationTest/Schema.pm
-t/lib/ValidationTest/Schema/Test.pm
Modified: trunk/DBIx-Class-Validation/MANIFEST.SKIP
===================================================================
--- trunk/DBIx-Class-Validation/MANIFEST.SKIP 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/MANIFEST.SKIP 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,51 +1,17 @@
-# Avoid version control files.
-\bRCS\b
-\bCVS\b
-,v$
-\B\.svn\b
-\B\.cvsignore$
-
-# Avoid Makemaker generated and utility files.
-\bMakefile$
-\bblib
-\bMakeMaker-\d
-\bpm_to_blib$
-\bblibdirs$
-^MANIFEST\.SKIP$
-
-# Avoid Module::Build generated and utility files.
-\bBuild$
-\bBuild.bat$
-\b_build
-
-# Avoid Devel::Cover generated files
-\bcover_db
-
-# Avoid temp and backup files.
-~$
-\.tmp$
-\.old$
-\.bak$
-\#$
-\.#
-\.rej$
-
-# Avoid OS-specific files/dirs
-# Mac OSX metadata
-\B\.DS_Store
-# Mac OSX SMB mount metadata files
-\B\._
-# Avoid archives of this distribution
-\bDBIx-Class-Validation-[\d\.\_]+
-
-# avoid OS X finder files
-\.DS_Store$
-
-# Don't ship the test db
-^t/var
-
-# Don't ship the last dist we built :)
-\.tar\.gz$
-
-# Skip coverage output
-^cover_db/
\ No newline at end of file
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+t/var
+^blib/
+^pm_to_blib
+^MakeMaker-\d
+Makefile$
+Makefile.old$
+Build.PL
+Build.bat
+\.db
+t/TEST$
+t/SMOKE$
+^blibdirs\.ts
+\.gz
\ No newline at end of file
Deleted: trunk/DBIx-Class-Validation/META.yml
===================================================================
--- trunk/DBIx-Class-Validation/META.yml 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/META.yml 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,25 +0,0 @@
----
-name: DBIx-Class-Validation
-version: 0.01001
-author:
- - 'Aran C. Deltac <bluefeet at cpan.org>'
-abstract: Validate all data before submitting to your database.
-license: perl
-resources:
- license: http://dev.perl.org/licenses/
-requires:
- DBIx::Class: 0.06002
- FormValidator::Simple: 0.17
-build_requires:
- DBD::SQLite: 1.11
- SQL::Translator: 0.07
-recommends:
- Data::FormValidator: 0
-provides:
- DBIx::Class::Validation:
- file: lib/DBIx/Class/Validation.pm
- version: 0.01001
-generated_by: Module::Build version 0.2805
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.2.html
- version: 1.2
Modified: trunk/DBIx-Class-Validation/Makefile.PL
===================================================================
--- trunk/DBIx-Class-Validation/Makefile.PL 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/Makefile.PL 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,31 +1,28 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.03
-
- unless (eval "use Module::Build::Compat 0.02; 1" ) {
- print "This module requires Module::Build to install itself.\n";
-
- require ExtUtils::MakeMaker;
- my $yn = ExtUtils::MakeMaker::prompt
- (' Install Module::Build now from CPAN?', 'y');
-
- unless ($yn =~ /^y/i) {
- die " *** Cannot install without Module::Build. Exiting ...\n";
- }
-
- require Cwd;
- require File::Spec;
- require CPAN;
-
- # Save this 'cause CPAN will chdir all over the place.
- my $cwd = Cwd::cwd();
-
- CPAN::Shell->install('Module::Build::Compat');
- CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
- or die "Couldn't install Module::Build, giving up.\n";
-
- chdir $cwd or die "Cannot chdir() back to $cwd: $!";
- }
- eval "use Module::Build::Compat 0.02; 1" or die $@;
-
- Module::Build::Compat->run_build_pl(args => \@ARGV);
- require Module::Build;
- Module::Build::Compat->write_makefile(build_class => 'Module::Build');
+# $Id$
+use strict;
+use warnings;
+use inc::Module::Install 0.65;
+
+name 'DBIx-Class-Validation';
+license 'perl';
+perl_version '5.006001';
+all_from 'lib/DBIx/Class/Validation.pm';
+
+requires 'DBIx::Class' => '0.07005';
+requires 'FormValidator::Simple' => '0.17';
+
+build_requires 'DBD::SQLite' => '1.11';
+
+feature 'Data::FormValidator support',
+ recommends
+ 'Data::FormValidator';
+
+tests "t/*.t t/*/*.t";
+clean_files "DBIx-Class-Validation-* t/var";
+
+eval {
+ system 'pod2text lib/DBIx/Class/Validation.pm > README';
+};
+
+auto_install;
+WriteAll;
Modified: trunk/DBIx-Class-Validation/README
===================================================================
--- trunk/DBIx-Class-Validation/README 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/README 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,101 +1,101 @@
-NAME
- DBIx::Class::Validation - Validate all data before submitting to your
- database.
-
-SYNOPSIS
- In your base "DBIx::Class" package:
-
- __PACKAGE__->load_components(qw/... Validation/);
-
- And in your subclasses:
-
- __PACKAGE__->validation(
- module => 'FormValidator::Simple',
- profile => { ... },
- filters => 0,
- auto => 1,
- );
-
- And then somewhere else:
-
- eval{ $obj->validate() };
- if( my $results = $EVAL_ERROR ){
- ...
- }
-
-METHODS
- validation
- __PACKAGE__->validation(
- module => 'FormValidator::Simple',
- profile => { ... },
- filters => 0,
- auto => 1,
- );
-
- Calls "validation_module", "validation_profile" and "validation_auto" if
- the corresponding argument is defined.
-
- validation_module
- __PACKAGE__->validation_module('Data::FormValidator');
-
- Sets the validation module to use. Any module that supports a check()
- method just like "Data::FormValidator"'s can be used here, such as
- "FormValidator::Simple".
-
- Defaults to FormValidator::Simple.
-
- validation_profile
- __PACKAGE__->validation_profile(
- { ... }
- );
-
- Sets the profile that will be passed to the validation module.
-
- validation_auto
- __PACKAGE__->validation_auto( 1 );
-
- Turns on and off auto-validation. This feature makes all UPDATEs and
- INSERTs call the "validate" method before doing anything.
-
- The default is for validation_auto is to be on.
-
- validation_filter
- __PACKAGE__->validation_filter( 1 );
-
- Turns on and off validation filters. When on, this feature will make all
- UPDATEs and INSERTs modify your data to that of the values returned by
- your validation modules "check" method. This is primarily meant for use
- with "Data::FormValidator" but may be used with any validation module
- that returns a results object that supports a "valid()" method just like
- "Data::FormValidator::Results".
-
- Filters modify your data, so use them carefully.
-
- The default is for validation_filter is to be off.
-
- validate
- $obj->validate();
-
- Validates all the data in the object against the pre-defined validation
- module and profile. If there is a problem then a hard error will be
- thrown. If you put the validation in an eval you can capture whatever
- the module's check() method returned.
-
-EXTENDED METHODS
- The following "DBIx::Class::Row" methods are extended by this module:-
-
- insert
- update
-
-SEE ALSO
- "DBIx::Class", "FormValidator::Simple", "Data::FormValidator"
-
-AUTHOR
- Aran C. Deltac <bluefeet at cpan.org>
-
-CONTRIBUTERS
- Tom Kirkpatrick <tkp at cpan.org>
-
-LICENSE
- You may distribute this code under the same terms as Perl itself.
-
+NAME
+ DBIx::Class::Validation - Validate all data before submitting to your
+ database.
+
+SYNOPSIS
+ In your base "DBIx::Class" package:
+
+ __PACKAGE__->load_components(qw/... Validation/);
+
+ And in your subclasses:
+
+ __PACKAGE__->validation(
+ module => 'FormValidator::Simple',
+ profile => { ... },
+ filters => 0,
+ auto => 1,
+ );
+
+ And then somewhere else:
+
+ eval{ $obj->validate() };
+ if( my $results = $EVAL_ERROR ){
+ ...
+ }
+
+METHODS
+ validation
+ __PACKAGE__->validation(
+ module => 'FormValidator::Simple',
+ profile => { ... },
+ filters => 0,
+ auto => 1,
+ );
+
+ Calls "validation_module", "validation_profile" and "validation_auto" if
+ the corresponding argument is defined.
+
+ validation_module
+ __PACKAGE__->validation_module('Data::FormValidator');
+
+ Sets the validation module to use. Any module that supports a check()
+ method just like "Data::FormValidator"'s can be used here, such as
+ "FormValidator::Simple".
+
+ Defaults to FormValidator::Simple.
+
+ validation_profile
+ __PACKAGE__->validation_profile(
+ { ... }
+ );
+
+ Sets the profile that will be passed to the validation module.
+
+ validation_auto
+ __PACKAGE__->validation_auto( 1 );
+
+ Turns on and off auto-validation. This feature makes all UPDATEs and
+ INSERTs call the "validate" method before doing anything.
+
+ The default is for validation_auto is to be on.
+
+ validation_filter
+ __PACKAGE__->validation_filter( 1 );
+
+ Turns on and off validation filters. When on, this feature will make all
+ UPDATEs and INSERTs modify your data to that of the values returned by
+ your validation modules "check" method. This is primarily meant for use
+ with "Data::FormValidator" but may be used with any validation module
+ that returns a results object that supports a "valid()" method just like
+ "Data::FormValidator::Results".
+
+ Filters modify your data, so use them carefully.
+
+ The default is for validation_filter is to be off.
+
+ validate
+ $obj->validate();
+
+ Validates all the data in the object against the pre-defined validation
+ module and profile. If there is a problem then a hard error will be
+ thrown. If you put the validation in an eval you can capture whatever
+ the module's check() method returned.
+
+EXTENDED METHODS
+ The following "DBIx::Class::Row" methods are extended by this module:-
+
+ insert
+ update
+
+SEE ALSO
+ "DBIx::Class", "FormValidator::Simple", "Data::FormValidator"
+
+AUTHOR
+ Aran C. Deltac <bluefeet at cpan.org>
+
+CONTRIBUTERS
+ Tom Kirkpatrick <tkp at cpan.org> Christopher Laco <claco at cpan.org>
+
+LICENSE
+ You may distribute this code under the same terms as Perl itself.
+
Modified: trunk/DBIx-Class-Validation/lib/DBIx/Class/Validation.pm
===================================================================
--- trunk/DBIx-Class-Validation/lib/DBIx/Class/Validation.pm 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/lib/DBIx/Class/Validation.pm 2007-05-05 16:23:08 UTC (rev 3235)
@@ -10,7 +10,7 @@
#local $^W = 0; # Silence C:D:I redefined sub errors.
# Switched to C::D::Accessor which doesn't do this. Hate hate hate hate.
-our $VERSION = '0.01001';
+our $VERSION = '0.01002';
__PACKAGE__->mk_classdata( 'validation_profile' );
__PACKAGE__->mk_classdata( 'validation_auto' => 1 );
@@ -69,6 +69,7 @@
$self->validation_module( $args{module} ) if exists $args{module};
$self->validation_profile( $args{profile} ) if exists $args{profile};
$self->validation_auto( $args{auto} ) if exists $args{auto};
+ $self->validation_filter( $args{filter} ) if exists $args{filter};
}
=head2 validation_module
@@ -150,9 +151,9 @@
my $result = $module->check( \%data => $profile );
if ($result->success) {
- if ($self->validation_filter && $result->can('valid')) {
- $self->set_column($_, $result->valid($_)) for ($result->valid);
- }
+ if ($self->validation_filter && $result->can('valid')) {
+ $self->set_column($_, $result->valid($_)) for ($result->valid);
+ }
return $result;
} else {
$self->throw_exception($result);
@@ -201,6 +202,7 @@
=head1 CONTRIBUTERS
Tom Kirkpatrick <tkp at cpan.org>
+Christopher Laco <claco at cpan.org>
=head1 LICENSE
Deleted: trunk/DBIx-Class-Validation/t/02pod.t
===================================================================
--- trunk/DBIx-Class-Validation/t/02pod.t 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/t/02pod.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,6 +0,0 @@
-use Test::More;
-
-eval "use Test::Pod 1.14";
-plan skip_all => 'Test::Pod 1.14 required' if $@;
-
-all_pod_files_ok();
Deleted: trunk/DBIx-Class-Validation/t/03podcoverage.t
===================================================================
--- trunk/DBIx-Class-Validation/t/03podcoverage.t 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/t/03podcoverage.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,7 +0,0 @@
-use Test::More;
-
-eval "use Test::Pod::Coverage 1.04";
-plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
-plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-
-all_pod_coverage_ok();
Deleted: trunk/DBIx-Class-Validation/t/04basic.t
===================================================================
--- trunk/DBIx-Class-Validation/t/04basic.t 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/t/04basic.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,14 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-
-BEGIN {
- eval "use DBD::SQLite";
- plan $@
- ? ( skip_all => 'needs DBD::SQLite for testing' )
- : ( tests => 1 );
-}
-
-use lib qw(t/lib);
-
-use_ok('DBIx::Class::Validation');
\ No newline at end of file
Deleted: trunk/DBIx-Class-Validation/t/05fvs.t
===================================================================
--- trunk/DBIx-Class-Validation/t/05fvs.t 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/t/05fvs.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,37 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-
-BEGIN {
- plan skip_all => 'needs FormValidator::Simple for testing'
- unless eval 'require FormValidator::Simple';
-
- plan skip_all => 'needs SQL::Translator for testing'
- unless eval 'require SQL::Translator';
-
- plan tests => 3;
-}
-
-use lib qw(t/lib);
-
-use ValidationTest;
-my $schema = ValidationTest->init_schema;
-my $row;
-
-my $profile = [
- name => [ 'NOT_BLANK', ['LENGTH', 4, 10] ],
-];
-
-ValidationTest::Schema::Test->validation_profile($profile);
-Class::C3->reinitialize();
-
-$row = eval{ $schema->resultset('Test')->create({name => ''}) };
-isa_ok $@, 'FormValidator::Simple::Results', 'blank value not accepted';
-
-$row = eval{ $schema->resultset('Test')->create({name => 'qwertyqwerty'}) };
-isa_ok $@, 'FormValidator::Simple::Results', 'long string not accepted';
-
-$row = eval{ $schema->resultset('Test')->create({name => 'qwerty'}) };
-is $row->name, 'qwerty', 'valid data accepted';
-
-1;
Deleted: trunk/DBIx-Class-Validation/t/06dfv.t
===================================================================
--- trunk/DBIx-Class-Validation/t/06dfv.t 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/t/06dfv.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,58 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-
-BEGIN {
- plan skip_all => 'needs Data::FormValidator for testing'
- unless eval 'require Data::FormValidator';
-
- plan skip_all => 'needs SQL::Translator for testing'
- unless eval 'require SQL::Translator';
-
- plan tests => 5;
-}
-
-use lib qw(t/lib);
-
-use ValidationTest;
-use Data::FormValidator::Constraints qw(:closures);
-
-my $schema = ValidationTest->init_schema;
-my $row;
-
-my $profile = {
- field_filters => {
- name => [qw/ ucfirst /],
- },
- required => [qw/ name /],
- optional => [qw/ email /],
- constraint_methods => {
- email => email(),
- },
-};
-
-ValidationTest::Schema::Test->validation_module("Data::FormValidator");
-ValidationTest::Schema::Test->validation_profile($profile);
-Class::C3->reinitialize();
-
-$row = eval{ $schema->resultset('Test')->create({email => 'test at test.org'}) };
-isa_ok $@, 'Data::FormValidator::Results', 'required fields missing';
-
-$row = eval{ $schema->resultset('Test')->create({name => 'test', email => 'qwerty'}) };
-isa_ok $@, 'Data::FormValidator::Results', 'invalid email address not accepted';
-
-$row = eval{ $schema->resultset('Test')->create({name => 'test', email => 'test at test.org'}) };
-is $row->email, 'test at test.org', 'valid data accepted';
-
-ValidationTest::Schema::Test->validation_filter(1);
-Class::C3->reinitialize();
-$row = eval{ $schema->resultset('Test')->create({name => 'test', email => 'test at test.org'}) };
-is $row->name, 'Test', 'filters applied';
-
-ValidationTest::Schema::Test->validation_filter(0);
-Class::C3->reinitialize();
-$row = eval{ $schema->resultset('Test')->create({name => 'test', email => 'test at test.org'}) };
-is $row->name, 'test', 'no filters applied';
-
-
-1;
Added: trunk/DBIx-Class-Validation/t/basic.t
===================================================================
--- trunk/DBIx-Class-Validation/t/basic.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/basic.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,11 @@
+#!perl -wT
+# $Id$
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test tests => 1;
+
+ use_ok('DBIx::Class::Validation');
+};
Property changes on: trunk/DBIx-Class-Validation/t/basic.t
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: trunk/DBIx-Class-Validation/t/dfv.t (from rev 3234, trunk/DBIx-Class-Validation/t/06dfv.t)
===================================================================
--- trunk/DBIx-Class-Validation/t/dfv.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/dfv.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,52 @@
+#!perl -wT
+# $Id$
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test;
+
+ plan skip_all => 'Data::FormValidator not installed'
+ unless eval 'require Data::FormValidator';
+
+ plan tests => 5;
+};
+
+use Data::FormValidator::Constraints qw(:closures);
+my $schema = DBIC::Test->init_schema;
+my $row;
+
+my $profile = {
+ field_filters => {
+ name => [qw/ ucfirst /],
+ },
+ required => [qw/ name /],
+ optional => [qw/ email /],
+ constraint_methods => {
+ email => email(),
+ },
+};
+
+DBIC::Test::Schema::Test->validation_module("Data::FormValidator");
+DBIC::Test::Schema::Test->validation_profile($profile);
+Class::C3->reinitialize();
+
+$row = eval{ $schema->resultset('Test')->create({email => 'test at test.org'}) };
+isa_ok $@, 'Data::FormValidator::Results', 'required fields missing';
+
+$row = eval{ $schema->resultset('Test')->create({name => 'test', email => 'qwerty'}) };
+isa_ok $@, 'Data::FormValidator::Results', 'invalid email address not accepted';
+
+$row = eval{ $schema->resultset('Test')->create({name => 'test', email => 'test at test.org'}) };
+is $row->email, 'test at test.org', 'valid data accepted';
+
+DBIC::Test::Schema::Test->validation_filter(1);
+Class::C3->reinitialize();
+$row = eval{ $schema->resultset('Test')->create({name => 'test', email => 'test at test.org'}) };
+is $row->name, 'Test', 'filters applied';
+
+DBIC::Test::Schema::Test->validation_filter(0);
+Class::C3->reinitialize();
+$row = eval{ $schema->resultset('Test')->create({name => 'test', email => 'test at test.org'}) };
+is $row->name, 'test', 'no filters applied';
Property changes on: trunk/DBIx-Class-Validation/t/dfv.t
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Copied: trunk/DBIx-Class-Validation/t/fvs.t (from rev 3234, trunk/DBIx-Class-Validation/t/05fvs.t)
===================================================================
--- trunk/DBIx-Class-Validation/t/fvs.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/fvs.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,82 @@
+#!perl -wT
+# $Id: basic.t 3096 2007-02-09 20:58:19Z claco $
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test tests => 16;
+}
+
+my $schema = DBIC::Test->init_schema;
+my $row;
+
+my $profile = [
+ name => [ 'NOT_BLANK', ['LENGTH', 4, 10] ],
+];
+
+DBIC::Test::Schema::Test->validation_profile($profile);
+Class::C3->reinitialize();
+
+$row = eval{ $schema->resultset('Test')->create({name => ''}) };
+isa_ok $@, 'FormValidator::Simple::Results', 'blank value not accepted';
+
+$row = eval{ $schema->resultset('Test')->create({name => 'qwertyqwerty'}) };
+isa_ok $@, 'FormValidator::Simple::Results', 'long string not accepted';
+
+$row = eval{ $schema->resultset('Test')->create({name => 'qwerty'}) };
+is $row->name, 'qwerty', 'valid data accepted';
+
+# updates too
+$row->name('food');
+$row->update;
+is $row->name, 'food', 'valid data accepted';
+
+# without auto on update
+$row->validation_auto(0);
+$row->name('yo');
+$row->update;
+is $row->name, 'yo', 'validation is off';
+
+## without auto on create
+DBIC::Test::Schema::Test->validation_auto(0);
+Class::C3->reinitialize();
+$row = eval{ $schema->resultset('Test')->create({name => 'qwertyqwerty'}) };
+is $row->name, 'qwertyqwerty', 'validation is off';
+
+# validation changes all
+DBIC::Test::Schema::Test->validation(
+ module => 'Validator',
+ auto => 2,
+ filter => 3,
+ profile => {name => 'NOT_BLANK'}
+);
+is(DBIC::Test::Schema::Test->validation_module, 'Validator');
+is(DBIC::Test::Schema::Test->validation_auto, 2);
+is(DBIC::Test::Schema::Test->validation_filter, 3);
+is_deeply(DBIC::Test::Schema::Test->validation_profile, {name => 'NOT_BLANK'}),
+
+## things should stay the same
+DBIC::Test::Schema::Test->validation();
+is(DBIC::Test::Schema::Test->validation_module, 'Validator');
+is(DBIC::Test::Schema::Test->validation_auto, 2);
+is(DBIC::Test::Schema::Test->validation_filter, 3);
+is_deeply(DBIC::Test::Schema::Test->validation_profile, {name => 'NOT_BLANK'}),
+
+eval {
+ DBIC::Test::Schema::Test->validation_module('JunkFoo');
+};
+if ($@ && $@ =~ /unable to load the validation module/i) {
+ pass;
+} else {
+ fail('throw exception when module fails to load');
+};
+
+eval {
+ DBIC::Test::Schema::Test->validation_module('ValidatorWithoutCheck');
+};
+if ($@ && $@ =~ /does not support the check\(\) method/i) {
+ pass;
+} else {
+ fail('throw exceptionb when module does not support check');
+};
\ No newline at end of file
Added: trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema/Test.pm
===================================================================
--- trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema/Test.pm (rev 0)
+++ trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema/Test.pm 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,32 @@
+# $Id: Items.pm 3112 2007-03-05 23:04:49Z claco $
+package DBIC::Test::Schema::Test;
+use strict;
+use warnings;
+
+BEGIN {
+ use base qw/DBIx::Class::Core/;
+};
+
+__PACKAGE__->load_components(qw/Validation PK::Auto Core/);
+__PACKAGE__->table('test');
+__PACKAGE__->add_columns(
+ 'id' => {
+ data_type => 'int',
+ is_nullable => 0,
+ is_auto_increment => 1,
+ },
+ 'name' => {
+ data_type => 'varchar',
+ size => 100,
+ is_nullable => 1,
+ },
+ 'email' => {
+ data_type => 'varchar',
+ size => 100,
+ is_nullable => 1,
+ }
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
Added: trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema.pm
===================================================================
--- trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema.pm (rev 0)
+++ trunk/DBIx-Class-Validation/t/lib/DBIC/Test/Schema.pm 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,15 @@
+# $Id: Schema.pm 3096 2007-02-09 20:58:19Z claco $
+package DBIC::Test::Schema;
+use strict;
+use warnings;
+
+BEGIN {
+ use base qw/DBIx::Class::Schema/;
+};
+__PACKAGE__->load_classes;
+
+sub dsn {
+ return shift->storage->connect_info->[0];
+};
+
+1;
Added: trunk/DBIx-Class-Validation/t/lib/DBIC/Test.pm
===================================================================
--- trunk/DBIx-Class-Validation/t/lib/DBIC/Test.pm (rev 0)
+++ trunk/DBIx-Class-Validation/t/lib/DBIC/Test.pm 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,101 @@
+# $Id$
+package DBIC::Test;
+use strict;
+use warnings;
+
+BEGIN {
+ # little trick by Ovid to pretend to subclass+exporter Test::More
+ use base qw/Test::Builder::Module Class::Accessor::Grouped/;
+ use Test::More;
+ use File::Spec::Functions qw/catfile catdir/;
+
+ @DBIC::Test::EXPORT = @Test::More::EXPORT;
+
+ __PACKAGE__->mk_group_accessors('inherited', qw/db_dir db_file/);
+};
+
+__PACKAGE__->db_dir(catdir('t', 'var'));
+__PACKAGE__->db_file('test.db');
+
+## cribbed and modified from DBICTest in DBIx::Class tests
+sub init_schema {
+ my ($self, %args) = @_;
+ my $db_dir = $args{'db_dir'} || $self->db_dir;
+ my $db_file = $args{'db_file'} || $self->db_file;
+ my $namespace = $args{'namespace'} || 'DBIC::TestSchema';
+ my $db = catfile($db_dir, $db_file);
+
+ eval 'use DBD::SQLite';
+ if ($@) {
+ BAIL_OUT('DBD::SQLite not installed');
+
+ return;
+ };
+
+ eval 'use DBIC::Test::Schema';
+ if ($@) {
+ BAIL_OUT("Could not load DBIC::Test::Schema: $@");
+
+ return;
+ };
+
+ unlink($db) if -e $db;
+ unlink($db . '-journal') if -e $db . '-journal';
+ mkdir($db_dir) unless -d $db_dir;
+
+ my $dsn = 'dbi:SQLite:' . $db;
+ my $schema = DBIC::Test::Schema->compose_namespace($namespace)->connect($dsn);
+ $schema->storage->on_connect_do([
+ 'PRAGMA synchronous = OFF',
+ 'PRAGMA temp_store = MEMORY'
+ ]);
+
+ __PACKAGE__->deploy_schema($schema, %args);
+ __PACKAGE__->populate_schema($schema, %args) unless $args{'no_populate'};
+
+ return $schema;
+};
+
+sub deploy_schema {
+ my ($self, $schema, %options) = @_;
+ my $eval = $options{'eval_deploy'};
+
+ eval 'use SdddQL::Translator';
+ if (!$@ && !$options{'no_deploy'}) {
+ eval {
+ $schema->deploy();
+ };
+ if ($@ && !$eval) {
+ die $@;
+ };
+ } else {
+ open IN, catfile('t', 'sql', 'test.sqlite.sql');
+ my $sql;
+ { local $/ = undef; $sql = <IN>; }
+ close IN;
+ eval {
+ ($schema->storage->dbh->do($_) || print "Error on SQL: $_\n") for split(/;\n/, $sql);
+ };
+ if ($@ && !$eval) {
+ die $@;
+ };
+ };
+};
+
+sub clear_schema {
+ my ($self, $schema, %options) = @_;
+
+ foreach my $source ($schema->sources) {
+ $schema->resultset($source)->delete_all;
+ };
+};
+
+sub populate_schema {
+ my ($self, $schema, %options) = @_;
+
+ if ($options{'clear'}) {
+ $self->clear_schema($schema, %options);
+ };
+};
+
+1;
Deleted: trunk/DBIx-Class-Validation/t/lib/ValidationTest.pm
===================================================================
--- trunk/DBIx-Class-Validation/t/lib/ValidationTest.pm 2007-05-05 02:29:41 UTC (rev 3234)
+++ trunk/DBIx-Class-Validation/t/lib/ValidationTest.pm 2007-05-05 16:23:08 UTC (rev 3235)
@@ -1,24 +0,0 @@
-package # hide from PAUSE
- ValidationTest;
-
-use strict;
-use warnings;
-use ValidationTest::Schema;
-
-sub init_schema {
- my $self = shift;
- my $db_file = "t/var/ValidationTest.db";
-
- unlink($db_file) if -e $db_file;
- unlink($db_file . "-journal") if -e $db_file . "-journal";
- mkdir("t/var") unless -d "t/var";
-
- my $dsn = "dbi:SQLite:${db_file}";
-
- my $schema = ValidationTest::Schema->compose_connection('ValidationTest' => $dsn);
- $schema->deploy();
-
- return $schema;
-}
-
-1;
Added: trunk/DBIx-Class-Validation/t/lib/Validator.pm
===================================================================
--- trunk/DBIx-Class-Validation/t/lib/Validator.pm (rev 0)
+++ trunk/DBIx-Class-Validation/t/lib/Validator.pm 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,13 @@
+package Validator;
+use strict;
+use warnings;
+
+sub new {
+ return bless {}, shift;
+};
+
+sub check {
+
+};
+
+1;
Added: trunk/DBIx-Class-Validation/t/lib/ValidatorWithoutCheck.pm
===================================================================
--- trunk/DBIx-Class-Validation/t/lib/ValidatorWithoutCheck.pm (rev 0)
+++ trunk/DBIx-Class-Validation/t/lib/ValidatorWithoutCheck.pm 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,5 @@
+package ValidatorWithoutCheck;
+use strict;
+use warnings;
+
+1;
Added: trunk/DBIx-Class-Validation/t/manifest.t
===================================================================
--- trunk/DBIx-Class-Validation/t/manifest.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/manifest.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,22 @@
+#!perl -wT
+# $Id: manifest.t 3230 2007-05-05 02:09:49Z claco $
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test;
+
+ plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+ eval 'use Test::CheckManifest 0.09';
+ if($@) {
+ plan skip_all => 'Test::CheckManifest 0.09 not installed';
+ };
+};
+
+ok_manifest({
+ exclude => ['/t/var', '/cover_db'],
+ filter => [qr/\.svn/, qr/cover/, qr/Build(.(PL|bat))?/, qr/_build/],
+ bool => 'or'
+});
Added: trunk/DBIx-Class-Validation/t/pod_coverage.t
===================================================================
--- trunk/DBIx-Class-Validation/t/pod_coverage.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/pod_coverage.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,23 @@
+#!perl -wT
+# $Id: pod_coverage.t 3230 2007-05-05 02:09:49Z claco $
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test;
+
+ plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+ eval 'use Test::Pod::Coverage 1.04';
+ plan skip_all => 'Test::Pod::Coverage 1.04' if $@;
+
+ eval 'use Pod::Coverage 0.14';
+ plan skip_all => 'Pod::Coverage 0.14 not installed' if $@;
+};
+
+my $trustme = {
+ trustme => [qr/^(g|s)et_component_class$/]
+};
+
+all_pod_coverage_ok($trustme);
Added: trunk/DBIx-Class-Validation/t/pod_spelling.t
===================================================================
--- trunk/DBIx-Class-Validation/t/pod_spelling.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/pod_spelling.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,28 @@
+#!perl -w
+# $Id$
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test;
+
+ plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+ eval 'use Test::Spelling 0.11';
+ plan skip_all => 'Test::Spelling 0.11 not installed' if $@;
+};
+
+set_spell_cmd('aspell list');
+
+add_stopwords(<DATA>);
+
+all_pod_files_spelling_ok();
+
+__DATA__
+Aran
+Deltac
+Laco
+INSERTs
+UPDATEs
+pre
Property changes on: trunk/DBIx-Class-Validation/t/pod_spelling.t
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/DBIx-Class-Validation/t/pod_syntax.t
===================================================================
--- trunk/DBIx-Class-Validation/t/pod_syntax.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/pod_syntax.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,16 @@
+#!perl -wT
+# $Id: pod_syntax.t 3230 2007-05-05 02:09:49Z claco $
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test;
+
+ plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+ eval 'use Test::Pod 1.00';
+ plan skip_all => 'Test::Pod 1.00 not installed' if $@;
+};
+
+all_pod_files_ok();
Added: trunk/DBIx-Class-Validation/t/sql/test.sqlite.sql
===================================================================
--- trunk/DBIx-Class-Validation/t/sql/test.sqlite.sql (rev 0)
+++ trunk/DBIx-Class-Validation/t/sql/test.sqlite.sql 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,5 @@
+CREATE TABLE test (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ name VARCHAR(100) NULL,
+ email VARCHAR(100) NULL
+);
Added: trunk/DBIx-Class-Validation/t/strict.t
===================================================================
--- trunk/DBIx-Class-Validation/t/strict.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/strict.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,53 @@
+#!perl -wT
+# $Id: strict.t 3230 2007-05-05 02:09:49Z claco $
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test;
+ use File::Find;
+ use File::Basename;
+
+ plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+ eval 'use Test::Strict';
+ plan skip_all => 'Test::Strict not installed' if $@;
+ plan skip_all => 'Need untaint in newer File::Find' if $] <= 5.006;
+};
+
+## I hope this can go away if Test::Strict or File::Find::Rule
+## finally run under -T. Until then, I'm on my own here. ;-)
+my @files;
+my %trusted = (
+
+);
+
+find({ wanted => \&wanted,
+ untaint => 1,
+ untaint_pattern => qr|^([-+@\w./]+)$|,
+ untaint_skip => 1,
+ no_chdir => 1
+}, qw(lib t));
+
+sub wanted {
+ my $name = $File::Find::name;
+ my $file = fileparse($name);
+
+ return if $name =~ /TestApp/;
+
+ if ($name =~ /\.(pm|pl|t)$/i && !exists($trusted{$file})) {
+ push @files, $name;
+ };
+};
+
+if (scalar @files) {
+ plan tests => scalar @files;
+} else {
+ plan tests => 1;
+ fail 'No perl files found for Test::Strict checks!';
+};
+
+foreach (@files) {
+ strict_ok($_);
+};
Added: trunk/DBIx-Class-Validation/t/style_no_tabs.t
===================================================================
--- trunk/DBIx-Class-Validation/t/style_no_tabs.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/style_no_tabs.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,16 @@
+#!perl -wT
+# $Id: style_no_tabs.t 3230 2007-05-05 02:09:49Z claco $
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test;
+
+ plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+ eval 'use Test::NoTabs 0.03';
+ plan skip_all => 'Test::NoTabs 0.03 not installed' if $@;
+};
+
+all_perl_files_ok('lib');
Added: trunk/DBIx-Class-Validation/t/warnings.t
===================================================================
--- trunk/DBIx-Class-Validation/t/warnings.t (rev 0)
+++ trunk/DBIx-Class-Validation/t/warnings.t 2007-05-05 16:23:08 UTC (rev 3235)
@@ -0,0 +1,53 @@
+#!perl -wT
+# $Id: warnings.t 3230 2007-05-05 02:09:49Z claco $
+use strict;
+use warnings;
+
+BEGIN {
+ use lib 't/lib';
+ use DBIC::Test;
+ use File::Find;
+ use File::Basename;
+
+ plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+ eval 'use Test::Strict 0.05';
+ plan skip_all => 'Test::Strict 0.05 not installed' if $@;
+ plan skip_all => 'Need untaint in newer File::Find' if $] <= 5.006;
+};
+
+## I hope this can go away if Test::Strict or File::Find::Rule
+## finally run under -T. Until then, I'm on my own here. ;-)
+my @files;
+my %trusted = (
+
+);
+
+find({ wanted => \&wanted,
+ untaint => 1,
+ untaint_pattern => qr|^([-+@\w./]+)$|,
+ untaint_skip => 1,
+ no_chdir => 1
+}, qw(lib t));
+
+sub wanted {
+ my $name = $File::Find::name;
+ my $file = fileparse($name);
+
+ return if $name =~ /TestApp/;
+
+ if ($name =~ /\.(pm|pl|t)$/i && !exists($trusted{$file})) {
+ push @files, $name;
+ };
+};
+
+if (scalar @files) {
+ plan tests => scalar @files;
+} else {
+ plan tests => 1;
+ fail 'No perl files found for Test::Strict checks!';
+};
+
+foreach (@files) {
+ warnings_ok($_);
+};
More information about the Bast-commits
mailing list