X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F20-mock_load.t;h=987dd236e34fe0bdb7e160ab18f0560eb3a6d1d4;hb=32c7af257f98dbcbfdb73dbaa97c6648e021cef0;hp=aa762a854124dc26536b47081e8ea86119059f8c;hpb=975b8d595674656d719b02b50c7ae0c60a171afd;p=catagits%2FCatalyst-Plugin-ConfigLoader.git diff --git a/t/20-mock_load.t b/t/20-mock_load.t index aa762a8..987dd23 100644 --- a/t/20-mock_load.t +++ b/t/20-mock_load.t @@ -1,17 +1,29 @@ -package MockApp; - -use Test::More tests => 7; - -use Cwd; -$ENV{ CATALYST_HOME } = cwd . '/t/mockapp'; - -use_ok( 'Catalyst', qw( ConfigLoader ) ); - -__PACKAGE__->setup; - -ok( __PACKAGE__->config ); -is( __PACKAGE__->config->{ 'Controller::Foo' }->{ foo }, 'bar' ); -is( __PACKAGE__->config->{ 'Controller::Foo' }->{ new }, 'key' ); -is( __PACKAGE__->config->{ 'Model::Baz' }->{ qux }, 'xyzzy' ); -is( __PACKAGE__->config->{ 'Model::Baz' }->{ another }, 'new key' ); -is( __PACKAGE__->config->{ 'view' }, 'View::TT::New' ); +package MockApp; + +use Test::More tests => 10; +use Cwd; + +# Remove all relevant env variables to avoid accidental fail +foreach my $name ( grep { m{^(CATALYST)} } keys %ENV ) { + delete $ENV{ $name }; +} + +$ENV{ CATALYST_HOME } = cwd . '/t/mockapp'; + +use_ok( 'Catalyst', qw( ConfigLoader ) ); + +__PACKAGE__->config->{ 'Plugin::ConfigLoader' }->{ substitutions } = { + foo => sub { shift; join( '-', @_ ); } +}; + +__PACKAGE__->setup; + +ok( __PACKAGE__->config ); +is( __PACKAGE__->config->{ 'Controller::Foo' }->{ foo }, 'bar' ); +is( __PACKAGE__->config->{ 'Controller::Foo' }->{ new }, 'key' ); +is( __PACKAGE__->config->{ 'Model::Baz' }->{ qux }, 'xyzzy' ); +is( __PACKAGE__->config->{ 'Model::Baz' }->{ another }, 'new key' ); +is( __PACKAGE__->config->{ 'view' }, 'View::TT::New' ); +is( __PACKAGE__->config->{ 'foo_sub' }, 'x-y' ); +is( __PACKAGE__->config->{ 'literal_macro' }, '__DATA__' ); +is( __PACKAGE__->config->{ 'Plugin::Zot' }->{ zoot }, 'zooot');