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