[Rt-commit] r2549 - in experiments/Bamboo: . t
jesse at bestpractical.com
jesse at bestpractical.com
Fri Apr 1 03:51:20 EST 2005
Author: jesse
Date: Fri Apr 1 03:51:19 2005
New Revision: 2549
Added:
experiments/Bamboo/t/00smoke.t
experiments/Bamboo/t/01basicparse.t
experiments/Bamboo/t/02model.t
Removed:
experiments/Bamboo/t/0smoke.t
experiments/Bamboo/t/1basicparse.t
experiments/Bamboo/t/2model.t
Modified:
experiments/Bamboo/ (props changed)
Log:
r10805 at hualien: jesse | 2005-03-31 20:51:59 +0800
* rename tests for sorting
Added: experiments/Bamboo/t/00smoke.t
==============================================================================
--- (empty file)
+++ experiments/Bamboo/t/00smoke.t Fri Apr 1 03:51:19 2005
@@ -0,0 +1,13 @@
+use Test::More qw/no_plan/;
+
+
+use_ok('Bamboo::Base');
+use_ok('Bamboo::Controller::Method');
+use_ok('Bamboo::Controller::MethodCollection');
+use_ok('Bamboo::Controller::Object');
+use_ok('Bamboo::Controller::ObjectCollection');
+use_ok('Bamboo::Controller::ParamCollection');
+use_ok('Bamboo::Controller::WebForms');
+use_ok('Bamboo::Controller');
+use_ok('Bamboo::Model::Facade');
+use_ok('Bamboo');
Added: experiments/Bamboo/t/01basicparse.t
==============================================================================
--- (empty file)
+++ experiments/Bamboo/t/01basicparse.t Fri Apr 1 03:51:19 2005
@@ -0,0 +1,95 @@
+package RT::MockTicket;
+
+sub new {
+ my $self = {};
+ bless $self;
+ return $self;
+}
+
+sub Load {
+ my $self = shift;
+ $self->{id} = shift;
+}
+
+sub SetStatus {
+ my $self = shift;
+ $self->{Status} = shift;
+}
+
+
+package Bamboo::Facade::RT::MockTicket;
+use base qw/Bamboo::Model::Facade/;
+__PACKAGE__->facade_for('RT::MockTicket');
+
+
+__PACKAGE__->register_method('Load');
+__PACKAGE__->register_method('SetStatus');
+__PACKAGE__->register_parameter( method => 'SetStatus',
+ position => 1,
+ validator => 'Bamboo::Validator::RT::MockStatus'
+ );
+
+
+package Bamboo::Validator::RT::MockStatus;
+
+sub is_valid {
+ my $status = shift;
+ if ($status =~ /^(?:new|open|stalled::resolved)$/) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
+
+package main;
+
+use Test::More qw/no_plan/;
+
+use YAML qw/Dump/;
+use_ok(Bamboo::Controller);
+
+my %basic_test = (
+
+ 'RT::MockTicket-23-SetStatus-ss1-_Param1' => 'open',
+ 'RT::MockTicket-24-SetStatus-ss1-_Param1' => 'stalled',
+
+);
+
+my $controller = Bamboo::Controller->new();
+
+is( ref($controller), 'Bamboo::Controller' );
+
+$controller->parse_param_hash(%basic_test);
+
+is( ref( $controller->objects ), 'Bamboo::Controller::ObjectCollection' );
+
+my @objects = $controller->objects->as_array;
+is( $#objects, 1 );
+
+# Get the object for Ticket 23;
+my $ticket_23 = $controller->objects->get( RT::MockTicket => 23 );
+is( ref($ticket_23), 'Bamboo::Controller::Object' );
+
+my @methods = $ticket_23->methods->as_array;
+
+is( $#methods, 0 );
+
+my @setstatus_monikers = $ticket_23->methods->get_monikers('SetStatus');
+
+is( $#setstatus_monikers, 0 );
+my $moniker = shift @setstatus_monikers;
+is( $moniker, 'ss1' );
+my $method_set_status = $ticket_23->methods->get( 'SetStatus', $moniker );
+is( ref($method_set_status), 'Bamboo::Controller::Method' );
+
+my @params = $method_set_status->params->names;
+
+is( $#params, 0 );
+
+is( $method_set_status->params->get( $params[0] ), 'open' );
+
+$controller->process_method_calls();
+
+
Added: experiments/Bamboo/t/02model.t
==============================================================================
--- (empty file)
+++ experiments/Bamboo/t/02model.t Fri Apr 1 03:51:19 2005
@@ -0,0 +1,22 @@
+package Bamboo::MockTicket;
+
+use strict;
+use Class::Meta;
+use Class::Meta::Types::String;
+
+BEGIN {
+my $cm = Class::Meta->new();
+$cm->add_constructor( name => 'new',
+ create => 1);
+
+$cm->add_attribute( name => 'Status', type => 'string');
+$cm->build();
+}
+
+package main;
+
+use Test::More qw/no_plan/;
+my $mockticket = Bamboo::MockTicket->new();
+is(ref($mockticket),'Bamboo::MockTicket');
+$mockticket->Status('new');
+is ($mockticket->Status, 'new');
More information about the Rt-commit
mailing list