Many more RssAspect tests.
This commit is contained in:
parent
409e3a3f6c
commit
c8fe4092a2
3 changed files with 78 additions and 9 deletions
|
|
@ -207,7 +207,8 @@ sub exportAssetCollateral {
|
||||||
# Get the parent dir's *path* (essentially the name of the dir) relative to
|
# Get the parent dir's *path* (essentially the name of the dir) relative to
|
||||||
# its own parent dir.
|
# its own parent dir.
|
||||||
$filenameBase = $basepath->parent->relative( $basepath->parent->parent )->stringify;
|
$filenameBase = $basepath->parent->relative( $basepath->parent->parent )->stringify;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
# Get the 1st ancestor, since the asset is a file recognized by apache, so
|
# Get the 1st ancestor, since the asset is a file recognized by apache, so
|
||||||
# we want our files in the same dir.
|
# we want our files in the same dir.
|
||||||
$filedir = $basepath->parent->absolute->stringify;
|
$filedir = $basepath->parent->absolute->stringify;
|
||||||
|
|
@ -429,7 +430,8 @@ sub getFeed {
|
||||||
if (!$new_item->guid) {
|
if (!$new_item->guid) {
|
||||||
if ($new_item->link) {
|
if ($new_item->link) {
|
||||||
$new_item->guid( $new_item->link );
|
$new_item->guid( $new_item->link );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$new_item->guid( $self->session->id->generate );
|
$new_item->guid( $self->session->id->generate );
|
||||||
$set_permalink_false = 1;
|
$set_permalink_false = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ use strict;
|
||||||
use lib "$FindBin::Bin/../lib";
|
use lib "$FindBin::Bin/../lib";
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
|
use File::Path;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||||
|
|
@ -30,11 +31,12 @@ use WebGUI::Asset::RssAspectDummy;
|
||||||
# Init
|
# Init
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
WebGUI::Test->originalConfig('exportPath');
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
plan tests => 18; # Increment this number for each test you create
|
plan tests => 21; # Increment this number for each test you create
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
|
@ -92,11 +94,12 @@ is($newFeed, $feed, 'getFeed returns the same object');
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$feed,
|
$feed,
|
||||||
methods(
|
methods(
|
||||||
title => 'Dummy Title',
|
title => 'Dummy Title',
|
||||||
description => 'Dummy Synopsis', ##Not description
|
description => 'Dummy Synopsis', ##Not description
|
||||||
link => '/home/shawshank',
|
link => '/home/shawshank',
|
||||||
|
copyright => '',
|
||||||
),
|
),
|
||||||
'... title, description, link inherit from asset by default'
|
'... title, description, link inherit from asset by default, copyright unset'
|
||||||
);
|
);
|
||||||
cmp_bag(
|
cmp_bag(
|
||||||
[ $feed->get_item() ],
|
[ $feed->get_item() ],
|
||||||
|
|
@ -104,16 +107,81 @@ cmp_bag(
|
||||||
methods(
|
methods(
|
||||||
title => 'this title',
|
title => 'this title',
|
||||||
description => 'this description',
|
description => 'this description',
|
||||||
|
'link' => 'this link',
|
||||||
|
guid => 'this link',
|
||||||
),
|
),
|
||||||
methods(
|
methods(
|
||||||
title => 'another title',
|
title => 'another title',
|
||||||
description => 'another description', ##Not description
|
description => 'another description', ##Not description
|
||||||
|
guid => re('^[a-zA-Z0-9\-_]{22}'), ##GUID is a GUID since there's no link
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
'... contains 2 feed items with the correct contents'
|
'... contains 2 feed items with the correct contents'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$dummy->update({
|
||||||
|
feedCopyright => 'copyright 2009 Plain Black Corporation',
|
||||||
|
feedTitle => 'Rita Hayworth and the Shawshank Redemption',
|
||||||
|
feedDescription => 'A good movie, providing loads of testing collateral',
|
||||||
|
});
|
||||||
|
$feed = $dummy->getFeed(XML::FeedPP::RSS->new());
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$feed,
|
||||||
|
methods(
|
||||||
|
title => 'Rita Hayworth and the Shawshank Redemption',
|
||||||
|
description => 'A good movie, providing loads of testing collateral',
|
||||||
|
link => '/home/shawshank',
|
||||||
|
copyright => 'copyright 2009 Plain Black Corporation',
|
||||||
|
),
|
||||||
|
'... feed settings override asset defaults, copyright'
|
||||||
|
);
|
||||||
|
|
||||||
|
#####################################################
|
||||||
|
#
|
||||||
|
# exportAssetCollateral
|
||||||
|
#
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
my $exportStorage = WebGUI::Storage->create($session);
|
||||||
|
WebGUI::Test->storagesToDelete($exportStorage);
|
||||||
|
my $basedir = Path::Class::Dir->new($exportStorage->getPath);
|
||||||
|
my $assetdir = $basedir->subdir('shawshank');
|
||||||
|
my $indexfile = $assetdir->file('index.html');
|
||||||
|
mkpath($assetdir->stringify);
|
||||||
|
$dummy->exportAssetCollateral($indexfile, {}, $session);
|
||||||
|
|
||||||
|
cmp_bag(
|
||||||
|
$exportStorage->getFiles(),
|
||||||
|
[qw/
|
||||||
|
shawshank.rss shawshank
|
||||||
|
shawshank.atom
|
||||||
|
/],
|
||||||
|
'exportAssetCollateral: feed files exported, index.html file'
|
||||||
|
);
|
||||||
|
|
||||||
|
$exportStorage = WebGUI::Storage->create($session);
|
||||||
|
WebGUI::Test->storagesToDelete($exportStorage);
|
||||||
|
$basedir = Path::Class::Dir->new($exportStorage->getPath);
|
||||||
|
my $assetfile = $basedir->file('shawshank.html');
|
||||||
|
$dummy->exportAssetCollateral($assetfile, {}, $session);
|
||||||
|
|
||||||
|
cmp_bag(
|
||||||
|
$exportStorage->getFiles(),
|
||||||
|
[qw/
|
||||||
|
shawshank.html.rss
|
||||||
|
shawshank.html.atom
|
||||||
|
/],
|
||||||
|
'exportAssetCollateral: feed files exported, shawshank.html file'
|
||||||
|
);
|
||||||
|
|
||||||
|
#####################################################
|
||||||
|
#
|
||||||
|
# exportAssetCollateral
|
||||||
|
#
|
||||||
|
#####################################################
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Cleanup
|
# Cleanup
|
||||||
END {
|
END {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,6 @@ return [
|
||||||
{
|
{
|
||||||
title => 'another title',
|
title => 'another title',
|
||||||
description => 'another description',
|
description => 'another description',
|
||||||
'link' => 'another link',
|
|
||||||
author => 'another author',
|
author => 'another author',
|
||||||
date => 'another date',
|
date => 'another date',
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue