WebService-Braintree

 view release on metacpan or  search on metacpan

t/unit/configuration.t  view on Meta::CPAN

# vim: sw=4 ts=4 ft=perl

use 5.010_001;
use strictures 1;

use Test::More;
use Test::Warn;

use lib qw(lib t/lib);

use WebService::Braintree;

my $config = WebService::Braintree->configuration;

$config->environment("sandbox");
$config->public_key("integration_public_key");
$config->merchant_id("integration_merchant_id");
$config->private_key("integration_private_key");

$config = WebService::Braintree->configuration;

subtest 'server()' => sub {
    my %choices = (
        development => 'localhost',
        integration => 'localhost',
        sandbox     => 'api.sandbox.braintreegateway.com',
        qa          => 'qa-master.braintreegateway.com',
        production  => 'api.braintreegateway.com',
    );

    while (my ($env, $url) = each %choices) {
        $config->environment($env);
        is $config->server, $url, "server() in $env is correct";
    }
};

subtest 'auth_url()' => sub {
    my %choices = (
        development => 'http://auth.venmo.dev:9292',
        integration => 'http://auth.venmo.dev:9292',
        sandbox     => 'https://auth.sandbox.venmo.com',
        qa          => 'https://auth.qa.venmo.com',
        production  => 'https://auth.venmo.com',
    );

    while (my ($env, $url) = each %choices) {
        $config->environment($env);
        is $config->auth_url, $url, "auth_url() in $env is correct";
    }
};

subtest 'ssl_enabled()' => sub {
    my %choices = (
        development => !1,
        integration => !1,
        sandbox     => !!1,
        qa          => !!1,
        production  => !!1,
    );

    while (my ($env, $truth) = each %choices) {
        $config->environment($env);
        if ($truth) {
            ok $config->ssl_enabled, "ssl_enabled() in $env is correct";
        }
        else {
            ok !$config->ssl_enabled, "ssl_enabled() in $env is correct";
        }
    }
};

subtest 'protocol()' => sub {
    my %choices = (
        development => 'http',
        integration => 'http',
        sandbox     => 'https',
        qa          => 'https',
        production  => 'https',



( run in 1.277 second using v1.01-cache-2.11-cpan-39bf76dae61 )