Net-APNS-Persistent
view release on metacpan or search on metacpan
t/02-send.t view on Meta::CPAN
use Test::More tests => 9;
use Test::Exception;
BEGIN { use_ok('Net::APNS::Persistent') };
SKIP: {
if (!($ENV{APNS_TEST_DEVICETOKEN} && $ENV{APNS_TEST_CERT} && $ENV{APNS_TEST_KEY})) {
# make sure cpan installers see this
my $msg = "skipping - can't make connection without environment variables: APNS_TEST_DEVICETOKEN APNS_TEST_CERT, APNS_TEST_KEY and (if needed) APNS_TEST_KEY_PASSWD";
diag $msg;
skip $msg, 8;
}
my %args = (
sandbox => 1,
cert => $ENV{APNS_TEST_CERT},
key => $ENV{APNS_TEST_KEY},
);
t/02-send.t view on Meta::CPAN
isa_ok(
my $apns = Net::APNS::Persistent->new(\%args),
'Net::APNS::Persistent',
"created Net::APNS::Persistent object"
);
sleep 3;
lives_ok {
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => '02-send.t first',
sound => 'default',
badge => 1,
},
},
) } "queued single notification";
lives_ok { $apns->send_queue } "sent";
sleep 3;
lives_ok {
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => '02-send.t second',
sound => 'default',
badge => 1,
},
},
);
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => '02-send.t third',
sound => 'default',
badge => 1,
},
},
);
} "queued multiple notifications";
lives_ok { $apns->send_queue } "sent";
sleep 3;
lives_ok {
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => {
body => '02-send.t fourth',
'action-loc-key' => undef,
},
sound => 'default',
badge => 1,
},
foo => 'bar',
t/03-send-large.t view on Meta::CPAN
use Test::More tests => 9;
use Test::Exception;
BEGIN { use_ok('Net::APNS::Persistent') };
SKIP: {
if (!($ENV{APNS_TEST_DEVICETOKEN} && $ENV{APNS_TEST_CERT} && $ENV{APNS_TEST_KEY})) {
# make sure cpan installers see this
my $msg = "skipping - can't make connection without environment variables: APNS_TEST_DEVICETOKEN APNS_TEST_CERT, APNS_TEST_KEY and (if needed) APNS_TEST_KEY_PASSWD";
diag $msg;
skip $msg, 8;
}
my %args = (
sandbox => 1,
cert => $ENV{APNS_TEST_CERT},
key => $ENV{APNS_TEST_KEY},
);
t/03-send-large.t view on Meta::CPAN
isa_ok(
my $apns = Net::APNS::Persistent->new(\%args),
'Net::APNS::Persistent',
"created Net::APNS::Persistent object"
);
sleep 3;
lives_ok {
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => "03-send-large.t first
Beware the Jubjub bird, and shun
The frumious Bandersnatch!'
He took his vorpal sword in hand:
Long time the manxome foe he sought --
So rested he by the Tumtum tree,
And stood awhile in thought.
And, as in uffish thought he stood,
t/03-send-large.t view on Meta::CPAN
},
},
) } "queued single large notification";
lives_ok { $apns->send_queue } "sent";
sleep 3;
lives_ok {
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => '02-send.t second
There was movement at the station, for the word had passed around
That the colt from old Regret had got away,
And had joined the wild bush horses - he was worth a thousand pound,
So all the cracks had gathered to the fray.
All the tried and noted riders from the stations near and far
Had mustered at the homestead overnight,
For the bushmen love hard riding where the wild bush horses are,
And the stock-horse snuffs the battle with delight.',
sound => 'default',
badge => 1,
},
},
);
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => "02-send.t third
Blessed are the poor in spirit,
For theirs is the kingdom of heaven.
Blessed are those who mourn,
For they shall be comforted.
Blessed are the meek,
For they shall inherit the earth.
Blessed are those who hunger and thirst for righteousness,
t/03-send-large.t view on Meta::CPAN
},
);
} "queued multiple large notifications";
lives_ok { $apns->send_queue } "sent";
sleep 5;
lives_ok {
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => "02-send.t fourth",
sound => 'default',
badge => 1,
},
},
);
} "queued single notification again, just to make sure we haven't messed up the byte order";
t/04-send-utf8.t view on Meta::CPAN
use Test::More tests => 7;
use Test::Exception;
use Encode;
use FindBin;
use utf8;
BEGIN { use_ok('Net::APNS::Persistent') };
SKIP: {
if (!($ENV{APNS_TEST_DEVICETOKEN} && $ENV{APNS_TEST_CERT} && $ENV{APNS_TEST_KEY})) {
# make sure cpan installers see this
my $msg = "skipping - can't make connection without environment variables: APNS_TEST_DEVICETOKEN APNS_TEST_CERT, APNS_TEST_KEY and (if needed) APNS_TEST_KEY_PASSWD";
diag $msg;
skip $msg, 6;
}
my %args = (
sandbox => 1,
cert => $ENV{APNS_TEST_CERT},
key => $ENV{APNS_TEST_KEY},
);
t/04-send-utf8.t view on Meta::CPAN
isa_ok(
my $apns = Net::APNS::Persistent->new(\%args),
'Net::APNS::Persistent',
"created Net::APNS::Persistent object"
);
sleep 5;
lives_ok {
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => "caf\xc3\xa9",
sound => 'default',
badge => 1,
},
},
);
} "queued single large utf8 notification";
t/04-send-utf8.t view on Meta::CPAN
or die "unable to open utf8-Demosthenes.txt: $!";
binmode $utf8_text_fh;
while (<$utf8_text_fh>) {
$utf8_text .= $_;
}
lives_ok {
$apns->queue_notification(
$ENV{APNS_TEST_DEVICETOKEN},
{
aps => {
alert => $utf8_text,
sound => 'default',
badge => 1,
},
},
);
} "queued single large utf8 notification";
( run in 0.586 second using v1.01-cache-2.11-cpan-49f99fa48dc )