webgui/t/Asset/Wobject/GalleryAlbum/rss.t
Doug Bell ab6f4defe3 - moved Gallery utility methods to WebGUI::Utility::Gallery
- Added tests for GalleryAlbum RSS
- More tests for comments
- Test International Macro sprintf as third+ arguments
- Add Gallery search limiting by user ID
- Remaining i18n for Gallery templates
- Fix: Search form now visible in Photo assets
Moved a lot of stuff from Photo to GalleryFile
2008-03-20 18:51:44 +00:00

107 lines
3.4 KiB
Perl

# $vim: syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../../../lib";
## The goal of this test is to test the rss view of GalleryAlbums
use Scalar::Util qw( blessed );
use WebGUI::Test;
use WebGUI::Session;
use Test::More;
use Test::Deep;
use XML::Simple;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Album Test"});
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery",
groupIdAddComment => 2, # Registered Users
groupIdAddFile => 2, # Registered Users
groupIdView => 7, # Everyone
groupIdEdit => 3, # Admins
ownerUserId => 3, # Admin
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::GalleryAlbum",
ownerUserId => "3", # Admin
description => "An RSS Description",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my @photos;
for my $i ( 0 .. 5 ) {
$photos[ $i ]
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
filename => "$i.jpg",
synopsis => "This is a description for $i.jpg",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
}
$versionTag->commit;
#----------------------------------------------------------------------------
# Tests
plan tests => 2;
use_ok("Test::WWW::Mechanize");
my $mech;
#----------------------------------------------------------------------------
# Test www_viewRss
$mech = Test::WWW::Mechanize->new;
my $url = $session->url->getSiteURL . $session->url->makeAbsolute( $album->getUrl('func=viewRss') );
$mech->get( $url );
cmp_deeply(
XMLin( $mech->content ),
{
version => '2.0',
channel => {
link => $session->url->getSiteURL . $album->getUrl,
description => $album->get("description"),
title => $album->get("title"),
item => bag(
map {
superhashof({
link => $session->url->getSiteURL . $_->getUrl,
title => $_->get("title"),
pubDate => $session->datetime->epochToMail( $_->get("revisionDate") ),
description => $_->get("synopsis"),
})
} @photos
),
},
},
"RSS Datastructure is complete and correct",
);
#----------------------------------------------------------------------------
# Cleanup
END {
$versionTag->rollback();
}