App-CELL

 view release on metacpan or  search on metacpan

t/070-config.t  view on Meta::CPAN

#!perl

#
# t/070-config.t
#
# Run Config.pm through its paces
#

use 5.012;
use strict;
use warnings;
use App::CELL::Config qw( $meta $core $site );
use App::CELL::Load;
use App::CELL::Log qw( $log );
use App::CELL::Test;
#use App::CELL::Test::LogToFile;
use Data::Dumper;
use Test::More;
use Test::Warnings;

my $status;
$log->init( ident => 'CELLtest', debug_mode => 1 );
$log->info("-------------------------------------------------------");
$log->info("---                  070-config.t                   ---");
$log->info("-------------------------------------------------------");

#
# META
#

$status = $meta->CELL_META_TEST_PARAM_BLOOEY;
ok( ! defined($status), "Still no blooey" );
ok( ! $meta->exists( 'CELL_META_TEST_PARAM_BLOOEY' ) );

$status = $meta->set( 'CELL_META_TEST_PARAM_BLOOEY', 'Blooey' );
ok( $status->ok, "Blooey create succeeded" );
ok( $meta->exists( 'CELL_META_TEST_PARAM_BLOOEY' ) );

# 'exists' returns undef on failure
$status = exists $App::CELL::Config::meta->{ 'CELL_META_TEST_PARAM_BLOOEY' };
ok( defined( $status ), "Blooey exists after its creation" );

$status = $meta->CELL_META_TEST_PARAM_BLOOEY;
is( $status, "Blooey", "Blooey has the right value via get_param" );

$status = App::CELL::Load::init( verbose => 1 );
is( $status->level, "WARN", "Load without sitedir gives warning" );

# 'exists' returns undef on failure
$status = $meta->CELL_META_UNIT_TESTING;
ok( defined( $status ), "Meta unit testing param exists" );

my $value = $App::CELL::Config::meta->{ 'CELL_META_UNIT_TESTING' }->{'Value'};
is( ref( $value ), "ARRAY", "Meta unit testing param is an array reference" );
is_deeply($value, [ 1, 2, 3, 'a', 'b', 'c' ], "Meta unit testing param, obtained by cheating, has expected value" );

my $result = $meta->CELL_META_UNIT_TESTING;
is_deeply( $result, [ 1, 2, 3, 'a', 'b', 'c' ], "Meta unit testing param, obtained via get_param, has expected value" );

$status = $meta->set( 'CELL_META_UNIT_TESTING', "different foo" );
#diag( "\$status level is " . $status->level . ", code " . $status->code );
ok( $status->ok, "set_meta says OK" );

$result = undef;
$result = $meta->CELL_META_UNIT_TESTING;
is( $result, "different foo", "set_meta really changed the value" );
# (should also test that this triggers a log message !)

# Bug #51
# https://sourceforge.net/p/perl-cell/tickets/51/
$result = undef;
$result = $meta->CELL_CORE_UNIT_TESTING;
#diag( "Use meta to access core param: " . Dumper( $result ) );
ok( ! defined( $result ), 'Cannot use $meta to access a core param' );
$result = $meta->CELL_SITE_UNIT_TESTING;
ok( ! defined( $result ), 'Cannot use $meta to access a site param' );
$result = $meta->get_param('CELL_SITE_UNIT_TESTING');



( run in 0.556 second using v1.01-cache-2.11-cpan-99c4e6809bf )