API-ISPManager

 view release on metacpan or  search on metacpan

lib/API/ISPManager.pm  view on Meta::CPAN

    if ($xml) {
        my $error_node = exists $xml->{authfail};
        return '' if $error_node;

        return $xml->{auth}->{id};
    } else {
        return '';
    }
}

# Wrapper for "ref" on undef value, without warnings :)
# Possible very stupid sub :)
# STATIC(REF: our_ref)
sub refs {
    my $ref = shift;

    return '' unless $ref;

    return ref $ref;
}

t/01-test.t  view on Meta::CPAN


use Test::More tests => $ONLINE ? 42 : 40;

my $test_host = $ENV{host} || 'ultrasam.ru';

ok(1, 'Test OK');
use_ok('API::ISPManager');

$a = 'refs';

is( refs( undef ),   '',       $a);
is( refs( {} ),      'HASH',   $a );
is( refs( [] ),      'ARRAY',  $a );
is( refs( sub {} ),  'CODE',   $a );
is( refs( \$a ),     'SCALAR', $a );

$a = 'is_success';

ok(! is_success(), $a);
ok(! is_success( { error => {}, data => {} } ), $a);
ok(  is_success( { data  => {} } ), $a);

t/01-test.t  view on Meta::CPAN


$a = 'filter_hash';
is_deeply( API::ISPManager::filter_hash( {  }, [ ]), {}, $a );
is_deeply( API::ISPManager::filter_hash( { aaa => 555, bbb => 111 }, [ 'aaa' ]), { aaa => 555 }, $a );
is_deeply( API::ISPManager::filter_hash( { aaa => 555, bbb => 111 }, [ ]), { }, $a );
is_deeply( API::ISPManager::filter_hash( { }, [ 'aaa' ]), { }, $a );

$a = 'mk_query_string';
is( API::ISPManager::mk_query_string( {  }  ), '', $a );
is( API::ISPManager::mk_query_string( ''    ), '', $a );
is( API::ISPManager::mk_query_string( undef ), '', $a );
is( API::ISPManager::mk_query_string( { aaa => 111, bbb => 222 } ), 'aaa=111&bbb=222', $a );
is( API::ISPManager::mk_query_string( { bbb => 222, aaa => 111 } ), 'aaa=111&bbb=222', $a );
is( API::ISPManager::mk_query_string( [ ] ), '', $a );
is( API::ISPManager::mk_query_string( { dddd => 'dfdf' } ), 'dddd=dfdf', $a );

my $kill_start_end_slashes_test = {
    '////aaa////' => 'aaa',
    'bbb////'     => 'bbb',
    '////ccc'     => 'ccc', 
    ''            => '',



( run in 1.030 second using v1.01-cache-2.11-cpan-d80b1682f3f )