Date-Holidays

 view release on metacpan or  search on metacpan

t/Test/Class/Date/Holidays.pm  view on Meta::CPAN

package Test::Class::Date::Holidays;

## no critic (Subroutines::RequireFinalReturn, ValuesAndExpressions::ProhibitMagicNumbers)

use strict;
use warnings;
use base qw(Test::Class);
use Test::More; # done_testing
use Test::Fatal qw(dies_ok);
use Env qw($TEST_VERBOSE $EXTENDED_TESTING $HOLIDAYS_EXTENDED_TESTING);
use Locale::Country; # all_country_codes
use Test::MockModule;
use English qw(-no_match_vars);

our $VERSION = '1.35';

#run prior and once per suite
sub startup : Test(startup => 1) {

    # Testing compilation of component
    use_ok('Date::Holidays');
}

sub constructor : Test(5) {

    # Constructor requires country code so this test relies on
    # Date::Holidays::DK
    SKIP: {
        eval { require Date::Holidays::DK };
        skip 'Date::Holidays::DK not installed', 5 if $EVAL_ERROR;

        ok( my $dh = Date::Holidays->new( countrycode => 'DK', nocheck => 1 ), 'calling contructor with dk and nocheck' );

        isa_ok( $dh, 'Date::Holidays', 'checking wrapper object' );

        can_ok( $dh, qw(new), 'new' );

        can_ok( $dh, qw(holidays), 'holidays' );

        can_ok( $dh, qw(is_holiday), 'is_holiday' );
    }
}

sub _fetch : Test(2) {

    # Constructor requires country code so this test relies on
    # Date::Holidays::DK
    SKIP: {
        eval { require Date::Holidays::DK };
        skip 'Date::Holidays::DK not installed', 2 if $EVAL_ERROR;

        ok( my $dh = Date::Holidays->new( countrycode => 'DK' ), 'calling constructor with dk' );

        can_ok( $dh, '_fetch' );
    }
}

sub _load : Test(1) {

    #Testing load with something from own distribution
    ok(my $mod = Date::Holidays->_load('Date::Holidays::Adapter'), 'loading adapter');
}

sub is_holiday_dt : Test(3) {
    SKIP: {
        eval { require Date::Holidays::DK };
        skip 'Date::Holidays::DK not installed', 3 if $EVAL_ERROR;

        ok( my $dh = Date::Holidays->new( countrycode => 'dk' ), 'calling constructor with dk' );



( run in 0.898 second using v1.01-cache-2.11-cpan-54e63673c56 )