[Bast-commits] r8190 - in
branches/DBIx-Class-Schema-Loader/deprecate_CDA: . t
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed Dec 30 21:28:54 GMT 2009
Author: caelum
Date: 2009-12-30 21:28:53 +0000 (Wed, 30 Dec 2009)
New Revision: 8190
Modified:
branches/DBIx-Class-Schema-Loader/deprecate_CDA/
branches/DBIx-Class-Schema-Loader/deprecate_CDA/t/25backcompat_v4.t
Log:
r22316 at hlagh (orig r8189): caelum | 2009-12-30 16:27:49 -0500
rearrange some test code
Property changes on: branches/DBIx-Class-Schema-Loader/deprecate_CDA
___________________________________________________________________
Name: svk:merge
- 46bc3436-8211-0410-8564-d96f7a728040:/local/DBIx-Class-Schema-Loader/branches/common-dump:37173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/back-compat:8172
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/current:8186
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/mssql_tweaks:7407
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/odbc-mssql:6439
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class-Schema-Loader:5726
+ 46bc3436-8211-0410-8564-d96f7a728040:/local/DBIx-Class-Schema-Loader/branches/common-dump:37173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/back-compat:8172
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/current:8189
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/mssql_tweaks:7407
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/odbc-mssql:6439
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class-Schema-Loader:5726
Modified: branches/DBIx-Class-Schema-Loader/deprecate_CDA/t/25backcompat_v4.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/deprecate_CDA/t/25backcompat_v4.t 2009-12-30 21:27:49 UTC (rev 8189)
+++ branches/DBIx-Class-Schema-Loader/deprecate_CDA/t/25backcompat_v4.t 2009-12-30 21:28:53 UTC (rev 8190)
@@ -12,87 +12,6 @@
rmtree $DUMP_DIR;
my $SCHEMA_CLASS = 'DBIXCSL_Test::Schema';
-sub run_loader {
- my %loader_opts = @_;
-
- eval {
- foreach my $source_name ($SCHEMA_CLASS->clone->sources) {
- Class::Unload->unload("${SCHEMA_CLASS}::${source_name}");
- }
-
- Class::Unload->unload($SCHEMA_CLASS);
- };
- undef $@;
-
- my @connect_info = $make_dbictest_db2::dsn;
- my @loader_warnings;
- local $SIG{__WARN__} = sub { push(@loader_warnings, $_[0]); };
- eval qq{
- package $SCHEMA_CLASS;
- use base qw/DBIx::Class::Schema::Loader/;
-
- __PACKAGE__->loader_options(\%loader_opts);
- __PACKAGE__->connection(\@connect_info);
- };
-
- ok(!$@, "Loader initialization") or diag $@;
-
- my $schema = $SCHEMA_CLASS->clone;
- my (%monikers, %classes);
- foreach my $source_name ($schema->sources) {
- my $table_name = $schema->source($source_name)->from;
- $monikers{$table_name} = $source_name;
- $classes{$table_name} = "${SCHEMA_CLASS}::${source_name}";
- }
-
- return {
- schema => $schema,
- warnings => \@loader_warnings,
- monikers => \%monikers,
- classes => \%classes,
- };
-}
-
-sub run_v4_tests {
- my $res = shift;
- my $schema = $res->{schema};
-
- is_deeply [ @{ $res->{monikers} }{qw/foos bar bazs quuxs/} ],
- [qw/Foos Bar Bazs Quuxs/],
- 'correct monikers in 0.04006 mode';
-
- isa_ok ((my $bar = eval { $schema->resultset('Bar')->find(1) }),
- $res->{classes}{bar},
- 'found a bar');
-
- isa_ok eval { $bar->foo_id }, $res->{classes}{foos},
- 'correct rel name in 0.04006 mode';
-
- ok my $baz = eval { $schema->resultset('Bazs')->find(1) };
-
- isa_ok eval { $baz->quux }, 'DBIx::Class::ResultSet',
- 'correct rel type and name for UNIQUE FK in 0.04006 mode';
-}
-
-sub run_v5_tests {
- my $res = shift;
- my $schema = $res->{schema};
-
- is_deeply [ @{ $res->{monikers} }{qw/foos bar bazs quuxs/} ],
- [qw/Foo Bar Baz Quux/],
- 'correct monikers in current mode';
-
- ok my $bar = eval { $schema->resultset('Bar')->find(1) };
-
- isa_ok eval { $bar->foo }, $res->{classes}{foos},
- 'correct rel name in current mode';
-
- ok my $baz = eval { $schema->resultset('Baz')->find(1) };
-
- isa_ok eval { $baz->quux }, $res->{classes}{quuxs},
- 'correct rel type and name for UNIQUE FK in current mode';
-}
-
# test dynamic schema in 0.04006 mode
{
my $res = run_loader();
@@ -247,6 +166,87 @@
rmtree $DUMP_DIR unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};
}
+sub run_loader {
+ my %loader_opts = @_;
+
+ eval {
+ foreach my $source_name ($SCHEMA_CLASS->clone->sources) {
+ Class::Unload->unload("${SCHEMA_CLASS}::${source_name}");
+ }
+
+ Class::Unload->unload($SCHEMA_CLASS);
+ };
+ undef $@;
+
+ my @connect_info = $make_dbictest_db2::dsn;
+ my @loader_warnings;
+ local $SIG{__WARN__} = sub { push(@loader_warnings, $_[0]); };
+ eval qq{
+ package $SCHEMA_CLASS;
+ use base qw/DBIx::Class::Schema::Loader/;
+
+ __PACKAGE__->loader_options(\%loader_opts);
+ __PACKAGE__->connection(\@connect_info);
+ };
+
+ ok(!$@, "Loader initialization") or diag $@;
+
+ my $schema = $SCHEMA_CLASS->clone;
+ my (%monikers, %classes);
+ foreach my $source_name ($schema->sources) {
+ my $table_name = $schema->source($source_name)->from;
+ $monikers{$table_name} = $source_name;
+ $classes{$table_name} = "${SCHEMA_CLASS}::${source_name}";
+ }
+
+ return {
+ schema => $schema,
+ warnings => \@loader_warnings,
+ monikers => \%monikers,
+ classes => \%classes,
+ };
+}
+
+sub run_v4_tests {
+ my $res = shift;
+ my $schema = $res->{schema};
+
+ is_deeply [ @{ $res->{monikers} }{qw/foos bar bazs quuxs/} ],
+ [qw/Foos Bar Bazs Quuxs/],
+ 'correct monikers in 0.04006 mode';
+
+ isa_ok ((my $bar = eval { $schema->resultset('Bar')->find(1) }),
+ $res->{classes}{bar},
+ 'found a bar');
+
+ isa_ok eval { $bar->foo_id }, $res->{classes}{foos},
+ 'correct rel name in 0.04006 mode';
+
+ ok my $baz = eval { $schema->resultset('Bazs')->find(1) };
+
+ isa_ok eval { $baz->quux }, 'DBIx::Class::ResultSet',
+ 'correct rel type and name for UNIQUE FK in 0.04006 mode';
+}
+
+sub run_v5_tests {
+ my $res = shift;
+ my $schema = $res->{schema};
+
+ is_deeply [ @{ $res->{monikers} }{qw/foos bar bazs quuxs/} ],
+ [qw/Foo Bar Baz Quux/],
+ 'correct monikers in current mode';
+
+ ok my $bar = eval { $schema->resultset('Bar')->find(1) };
+
+ isa_ok eval { $bar->foo }, $res->{classes}{foos},
+ 'correct rel name in current mode';
+
+ ok my $baz = eval { $schema->resultset('Baz')->find(1) };
+
+ isa_ok eval { $baz->quux }, $res->{classes}{quuxs},
+ 'correct rel type and name for UNIQUE FK in current mode';
+}
+
# a Schema.pm made with 0.04006
__DATA__
More information about the Bast-commits
mailing list