migrate EMSTicket to FormBuilder
This commit is contained in:
parent
39c775a44d
commit
6729cb0621
2 changed files with 60 additions and 5 deletions
|
|
@ -16,6 +16,7 @@ package WebGUI::Asset::Sku::EMSTicket;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Moose;
|
use Moose;
|
||||||
|
use WebGUI::FormBuilder;
|
||||||
use WebGUI::Definition::Asset;
|
use WebGUI::Definition::Asset;
|
||||||
extends 'WebGUI::Asset::Sku';
|
extends 'WebGUI::Asset::Sku';
|
||||||
define assetName => ['ems ticket', 'Asset_EMSTicket'];
|
define assetName => ['ems ticket', 'Asset_EMSTicket'];
|
||||||
|
|
@ -497,11 +498,11 @@ sub view {
|
||||||
|
|
||||||
# build the add to cart form
|
# build the add to cart form
|
||||||
if ($form->get('badgeId') ne '') {
|
if ($form->get('badgeId') ne '') {
|
||||||
my $addToCart = WebGUI::HTMLForm->new($self->session, action=>$self->getUrl);
|
my $f = WebGUI::FormBuilder->new( $self->session, action => $self->getUrl );
|
||||||
$addToCart->hidden(name=>"func", value=>"addToCart");
|
$f->addField( "hidden", name=>"func", value=>"addToCart" );
|
||||||
$addToCart->hidden(name=>"badgeId", value=>$form->get('badgeId'));
|
$f->addField( "hidden", name=>"badgeId", value=>$form->get('badgeId') );
|
||||||
$addToCart->submit(value=>$i18n->get('add to cart','Shop'), label=>$self->getPrice);
|
$f->addField( "submit", value=>$i18n->get('add to cart','Shop'), label=>$self->getPrice );
|
||||||
$output .= $addToCart->print;
|
$output .= $f->toHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
|
|
||||||
54
t/Asset/Sku/EMSTicket.t
Normal file
54
t/Asset/Sku/EMSTicket.t
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
# vim:syntax=perl
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# WebGUI is Copyright 2001-2009 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
|
||||||
|
#------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Test the EMSTicket asset
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
use FindBin;
|
||||||
|
use strict;
|
||||||
|
use lib "$FindBin::Bin/lib";
|
||||||
|
use Test::More;
|
||||||
|
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||||
|
use WebGUI::Test::Mechanize;
|
||||||
|
use WebGUI::Shop::Cart;
|
||||||
|
use WebGUI::Session;
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Init
|
||||||
|
my $session = WebGUI::Test->session;
|
||||||
|
my $ems = WebGUI::Test->asset( className => 'WebGUI::Asset::Wobject::EventManagementSystem' );
|
||||||
|
my $badge = $ems->addChild({
|
||||||
|
className => 'WebGUI::Asset::Sku::EMSBadge',
|
||||||
|
});
|
||||||
|
my $ticket = $ems->addChild({
|
||||||
|
className => 'WebGUI::Asset::Sku::EMSTicket',
|
||||||
|
});
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Tests
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Test the addToCart form
|
||||||
|
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||||
|
$mech->get_ok( '/' );
|
||||||
|
$mech->session->user({ userId => 3 });
|
||||||
|
$mech->get_ok( $ticket->getUrl( 'badgeId=' . $badge->getId ) );
|
||||||
|
$mech->submit_form_ok({
|
||||||
|
fields => { },
|
||||||
|
});
|
||||||
|
|
||||||
|
my $cart = WebGUI::Shop::Cart->newBySession( $mech->session );
|
||||||
|
ok( $cart->getItemsByAssetId([ $ticket->getId ])->[0]->getId, $ticket->getId );
|
||||||
|
|
||||||
|
|
||||||
|
done_testing;
|
||||||
|
#vim:ft=perl
|
||||||
Loading…
Add table
Add a link
Reference in a new issue