App-CELL

 view release on metacpan or  search on metacpan

t/110-site.t  view on Meta::CPAN

is( $msgobj->text, 'This is a test message.', 
    "Test message has the right text" );
$msgobj = $CELL->msg( 'NON_EXISTENT_MESSAGE' );
ok( blessed($msgobj), "Message object with undefined code is blessed" );
is( $msgobj->text, 'NON_EXISTENT_MESSAGE', 
    "Non-existent message text the same as non-existent message code" );

$msgobj = $CELL->msg( 'BAR_ARGS_MSG', "FooBar", 2 );
is( $msgobj->text, 'This FooBar message takes 2 arguments.' );

#$status = $msgobj->lang('cz');
#my $cesky_text = $status->payload->text;
#is( $cesky_text, "Tato FooBar zpráva bere 2 argumenty." );

is( $site->A_RANDOM_PARAMETER, "34WDFWWD", "Random parameter has value we set" );

#---
# and now, a second sitedir
#---
$status = mktmpdir();
ok( $status->ok, "Second temporary directory created" );
my $sitedir2 = $status->payload;
ok( -d $sitedir2, "Second tmpdir is a directory" );
ok( -W $sitedir2, "Second tmpdir is writable by us" );

$full_path = File::Spec->catfile( $sitedir2, 'CELL2_Message_en.conf' );
$stuff = <<'EOS';
# some messages for the second sitedir
TEST2_MESSAGE
This is a test2 message.

FOO2_BAR
Second message that says bar foo.

BAR2_ARGS_MSG
This second %s message takes %s arguments.

EOS
#diag( "Now populating $full_path" );
populate_file( $full_path, $stuff );

$full_path = File::Spec->catfile( $sitedir2, 'CELL_SiteConfig.pm' );
$stuff = <<'EOS';
set( 'CELL2_BIG_BUS_PARAM', "Vehiculo longo" );

# a random parameter
set( 'A_RANDOM_PARAMETER', "different value" );

use strict;
use warnings;
1;
EOS
#diag( "Now populating $full_path" );
populate_file( $full_path, $stuff );

$status = $CELL->load( sitedir => $sitedir2 );
ok( $status->ok, "CELL initialization with second sitedir OK" );
is( $site->CELL2_BIG_BUS_PARAM, "Vehiculo longo", "Unique param has value we set" );
is( $site->A_RANDOM_PARAMETER, "34WDFWWD", "Attempt to overwrite existing site param failed" );
is( $meta->CELL_META_SITEDIR_LOADED, 2, "Meta param set correctly after second load");
is_deeply( $meta->CELL_META_SITEDIR_LIST, [ $sitedir, $sitedir2 ], "List of sitedirs correctly expanded after second load" );

done_testing;



( run in 0.388 second using v1.01-cache-2.11-cpan-b85c58fdc1d )