my $RESULT_COUNT = 7;
-sub class_content_like;
+sub class_content_contains;
+sub contains;
# test dynamic schema in 0.04006 mode
{
my $res = run_loader();
my $warning = $res->{warnings}[0];
- like $warning, qr/dynamic schema/i,
+ contains $warning, 'Dynamic schema',
'dynamic schema in backcompat mode detected';
- like $warning, qr/run in 0\.04006 mode/i,
+ contains $warning, 'run in 0.04006 mode',
'dynamic schema in 0.04006 mode warning';
- like $warning, qr/DBIx::Class::Schema::Loader::Manual::UpgradingFromV4/,
+ contains $warning, 'DBIx::Class::Schema::Loader::Manual::UpgradingFromV4',
'warning refers to upgrading doc';
run_v4_tests($res);
'content for unsingularized Result.';
my $warning = $res->{warnings}[0];
- like $warning, qr/Detected external content/i,
+ contains $warning, 'Detected external content',
'detected external content warning';
lives_and { is $schema->resultset('Quux')->find(1)->a_method, 'hlagh' }
'content for unsingularized Result with use_namespaces.';
my $warning = $res->{warnings}[0];
- like $warning, qr/Detected external content/i,
+ contains $warning, "Detected external content",
'detected external content warning';
lives_and { is $schema->resultset('Quux')->find(1)->a_method, 'hlagh' }
'unsingularized class names in external content from unchanged Result class ' .
'names are translated in static schema';
- class_content_like $schema, $res->{classes}{quuxs}, qr/package ${SCHEMA_CLASS}::Quux;/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "package ${SCHEMA_CLASS}::Quux;",
'package line translated correctly from external custom content in static dump';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub a_method { 'hlagh' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub a_method { 'hlagh' }",
'external custom content loaded into static dump correctly';
}
my $res = run_loader(static => 1);
my $warning = $res->{warnings}[1];
- like $warning, qr/static schema/i,
+ contains $warning, "static schema",
'static schema in backcompat mode detected';
- like $warning, qr/0.04006/,
+ contains $warning, "0.04006",
'correct version detected';
- like $warning, qr/DBIx::Class::Schema::Loader::Manual::UpgradingFromV4/,
+ contains $warning, "DBIx::Class::Schema::Loader::Manual::UpgradingFromV4",
'refers to upgrading doc';
is scalar @{ $res->{warnings} }, 4,
);
my $schema = $res->{schema};
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on upgrading static schema (with "naming" set)';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on upgrading static schema (with "naming" set)';
is scalar @{ $res->{warnings} }, 2,
$res->{classes}{bazs} }
'unsingularized class names in custom content are translated';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub b_method { 'dongs' }",
'custom content from unsingularized Result loaded into static dump correctly';
}
my $res = run_loader(static => 1);
my $warning = $res->{warnings}[1];
- like $warning, qr/static schema/i,
+ contains $warning, "static schema",
'static schema in backcompat mode detected';
- like $warning, qr/0.04006/,
+ contains $warning, "0.04006",
'correct version detected';
- like $warning, qr/DBIx::Class::Schema::Loader::Manual::UpgradingFromV4/,
+ contains $warning, "DBIx::Class::Schema::Loader::Manual::UpgradingFromV4",
'refers to upgrading doc';
is scalar @{ $res->{warnings} }, 4,
);
my $schema = $res->{schema};
- like $res->{warnings}[0], qr/load_classes/i,
+ contains $res->{warnings}[0], "load_classes",
'correct warnings on upgrading static schema (with "naming" set and ' .
'use_namespaces not set)';
- like $res->{warnings}[1], qr/Dumping manual schema/i,
+ contains $res->{warnings}[1], "Dumping manual schema",
'correct warnings on upgrading static schema (with "naming" set and ' .
'use_namespaces not set)';
- like $res->{warnings}[2], qr/dump completed/i,
+ contains $res->{warnings}[2], "dump completed",
'correct warnings on upgrading static schema (with "naming" set and ' .
'use_namespaces not set)';
$res->{classes}{bazs} }
'unsingularized class names in custom content are translated';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub b_method { 'dongs' }",
'custom content from unsingularized Result loaded into static dump correctly';
}
my $res = run_loader(static => 1);
my $warning = $res->{warnings}[0];
- like $warning, qr/static schema/i,
+ contains $warning, "static schema",
'static schema in backcompat mode detected';
- like $warning, qr/0.04006/,
+ contains $warning, "0.04006",
'correct version detected';
- like $warning, qr/DBIx::Class::Schema::Loader::Manual::UpgradingFromV4/,
+ contains $warning, "DBIx::Class::Schema::Loader::Manual::UpgradingFromV4",
'refers to upgrading doc';
is scalar @{ $res->{warnings} }, 3,
);
my $schema = $res->{schema};
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on upgrading static schema (with "naming" set and ' .
'use_namespaces => 0)';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on upgrading static schema (with "naming" set and ' .
'use_namespaces => 0)';
'unsingularized class names in external content from unchanged Result class ' .
'names are translated in static schema';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub a_method { 'hlagh' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub a_method { 'hlagh' }",
'external content from unsingularized Result loaded into static dump correctly';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub b_method { 'dongs' }",
'custom content from unsingularized Result loaded into static dump correctly';
}
naming => 'current',
);
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on dumping static schema with use_namespaces => 0';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on dumping static schema with use_namespaces => 0';
is scalar @{ $res->{warnings} }, 2,
# load_classes is preserved
$res = run_loader(static => 1, naming => 'current');
- like $res->{warnings}[0], qr/load_classes/i,
+ contains $res->{warnings}[0], "load_classes",
'correct warnings on re-dumping static schema with load_classes';
- like $res->{warnings}[1], qr/Dumping manual schema/i,
+ contains $res->{warnings}[1], "Dumping manual schema",
'correct warnings on re-dumping static schema with load_classes';
- like $res->{warnings}[2], qr/dump completed/i,
+ contains $res->{warnings}[2], "dump completed",
'correct warnings on re-dumping static schema with load_classes';
is scalar @{ $res->{warnings} }, 3,
);
$schema = $res->{schema};
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on upgrading to use_namespaces';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on upgrading to use_namespaces';
is scalar @{ $res->{warnings} }, 2,
$res->{classes}{bazs} }
'un-namespaced class names in custom content are translated';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub b_method { 'dongs' }",
'custom content from un-namespaced Result loaded into static dump correctly';
}
{
my $res = run_loader(clean_dumpdir => 1, static => 1, naming => 'current');
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on dumping static schema';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on dumping static schema';
is scalar @{ $res->{warnings} }, 2,
# test that with no use_namespaces option, use_namespaces is preserved
$res = run_loader(static => 1, naming => 'current');
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on re-dumping static schema';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on re-dumping static schema';
is scalar @{ $res->{warnings} }, 2,
);
my $schema = $res->{schema};
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on downgrading to load_classes';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on downgrading to load_classes';
is scalar @{ $res->{warnings} }, 2,
'namespaced class names in custom content are translated during load_classes '.
'downgrade';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub b_method { 'dongs' }",
'custom content from namespaced Result loaded into static dump correctly '.
'during load_classes downgrade';
}
naming => 'current',
);
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on dumping static schema';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on dumping static schema';
is scalar @{ $res->{warnings} }, 2,
# the custom result_namespace is preserved
$res = run_loader(static => 1, naming => 'current');
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on re-dumping static schema';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on re-dumping static schema';
is scalar @{ $res->{warnings} }, 2,
);
my $schema = $res->{schema};
- like $res->{warnings}[0], qr/Dumping manual schema/i,
+ contains $res->{warnings}[0], "Dumping manual schema",
'correct warnings on downgrading to load_classes';
- like $res->{warnings}[1], qr/dump completed/i,
+ contains $res->{warnings}[1], "dump completed",
'correct warnings on downgrading to load_classes';
is scalar @{ $res->{warnings} }, 2,
'namespaced class names in custom content are translated during load_classes '.
'downgrade';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub b_method { 'dongs' }",
'custom content from namespaced Result loaded into static dump correctly '.
'during load_classes downgrade';
}
$res->{classes}{bazs} }
'class names in custom content are translated when rewriting result_namespace';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub b_method { 'dongs' }",
'custom content from namespaced Result loaded into static dump correctly '.
'when rewriting result_namespace';
'class names in external content are translated when rewriting '.
'result_namespace';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub b_method { 'dongs' }",
'custom content from namespaced Result loaded into static dump correctly '.
'when rewriting result_namespace';
- class_content_like $schema, $res->{classes}{quuxs}, qr/sub a_method { 'hlagh' }/,
+ class_content_contains $schema, $res->{classes}{quuxs}, "sub a_method { 'hlagh' }",
'external content from unsingularized Result loaded into static dump correctly';
}
'unsingularized class names in custom content from Result with unchanged ' .
'name are translated';
- class_content_like $schema, $res->{classes}{bar}, qr/sub b_method { 'dongs' }/,
+ class_content_contains $schema, $res->{classes}{bar}, "sub b_method { 'dongs' }",
'custom content from Result with unchanged name loaded into static dump ' .
'correctly';
}
my $res = run_loader(static => 1);
- like $res->{warnings}[0], qr/0.05003 static schema/, 'backcompat warning';
+ contains $res->{warnings}[0], "0.05003 static schema", 'backcompat warning';
run_v5_tests($res);
my $res = run_loader(static => 1);
- like $res->{warnings}[0], qr/0.06001 static schema/, 'backcompat warning';
+ contains $res->{warnings}[0], "0.06001 static schema", 'backcompat warning';
run_v6_tests($res);
}->{_rel_key($from, $to)};
}
-sub class_content_like {
- my ($schema, $class, $re, $test_name) = @_;
+sub class_content_contains {
+ my ($schema, $class, $substr, $test_name) = @_;
my $file = $schema->loader->get_dump_filename($class);
my $code = slurp_file $file;
- like $code, $re, $test_name;
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ contains $code, $substr, $test_name;
+}
+
+sub contains {
+ my ($haystack, $needle, $test_name) = @_;
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ like $haystack, qr/\Q$needle\E/, $test_name;
}
sub add_custom_content {