Add tdwtf_series function for new API call
[webservice-tdwtf.git] / t / WebService-TDWTF.t
CommitLineData
54c23de0
MG
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use Test::RequiresInternet ('thedailywtf.com' => 80);
8773c4ec 6use Test::More tests => 16;
54c23de0
MG
7BEGIN { use_ok('WebService::TDWTF') };
8
9my $art = tdwtf_article;
10ok $art->Title, 'article';
11$art = tdwtf_article 8301;
12is $art->Title, 'Your Recommended Virus', 'article 8301';
13$art = tdwtf_article 'your-recommended-virus';
14is $art->Title, 'Your Recommended Virus', 'article \'your-recommended-virus\'';
15
16my @recent = tdwtf_list_recent;
17is @recent, 8, 'tdwtf_list_recent';
18@recent = tdwtf_list_recent 2;
19is @recent, 2, 'tdwtf_list_recent 2';
20
21my @dec15 = tdwtf_list_recent 2015, 12;
22is $dec15[0]->Title, 'Best of 2015: The A(nti)-Team', 'tdwtf_list_recent 2015, 12';
23is $dec15[0]->BodyHtml, '', '->BodyHtml';
24isnt $dec15[0]->Body, '', '->Body';
25isnt $dec15[0]->Body, '', '->Body (cached)';
26
27my @erik = tdwtf_list_author 'erik-gern';
28is @erik, 8, 'tdwtf_list_author \'erik-gern\'';
29
30my @sod = tdwtf_list_series 'code-sod', 5;
31is @sod, 5, 'tdwtf_list_series \'code-sod\', 5';
32
8773c4ec
MG
33my @series = tdwtf_series;
34note 'Found ' . @series . ' series';
35cmp_ok @series, '==', scalar tdwtf_series, 'tdwtf_series scalar context';
36my ($codesod) = grep { $_->{Title} =~ /codesod/i } @series;
37is $codesod->{Slug}, 'code-sod', 'tdwtf_series finds CodeSOD';
54c23de0
MG
38
39my ($last) = tdwtf_list_recent 1;
40ok !defined $last->NextArticle, 'last article has no next article';
41is $last->PreviousArticle->NextArticle->Id, $last->Id, 'next article of the previous article is current article';
This page took 0.012515 seconds and 4 git commands to generate.