1#!perl -t
2
3use warnings;
4use strict;
5use Test::More;
6use Test::Deep;
7
8use_ok "WebService::Pushover" or BAIL_OUT "WebService::Pushover failed. Cannot continue testing";
9
10my $API_TOKEN  = "abcdefghijklmnopqrstuvwxyz1234";
11my $USER_TOKEN = "1234abcdefghijklmnopqrstuvwxyz";
12
13subtest "Basic pushover object creation" => sub {
14	my $push = WebService::Pushover->new();
15	isa_ok $push, "WebService::Pushover", "new() created object of correct class";
16	is $push->api_token,  undef, "api_token isn't set unless provided";
17	is $push->user_token, undef, "user_token isn't set unless provided";
18	is $push->debug, 0, "debug is 0 by default";
19};
20
21subtest "Enabling debugging" => sub {
22	my $push = WebService::Pushover->new(debug => 1);
23	is $push->debug, 1, "Debug gets set properly";
24	$push = WebService::Pushover->new(debug => 'asdf');
25	is $push->debug, 1, "debug is coerced into '1' for a true value";
26
27	$push = WebService::Pushover->new(debug => 0);
28	is $push->debug, 0, "debug is disabled properly";
29	$push = WebService::Pushover->new(debug => '');
30	is $push->debug, 0, "debug is coerced into '0' for a false value";
31};
32
33subtest "Setting default tokens" => sub {
34	my $push = WebService::Pushover->new(api_token => $API_TOKEN, user_token => $USER_TOKEN);
35	is $push->{api_token}, $API_TOKEN, "api_token gets set properly";
36	is $push->{user_token}, $USER_TOKEN, "user_token gets set properly";
37};
38
39done_testing;
40