# Copyright (c) 2009 bivio Software Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: TupleDefListForm2.bunit,v 1.3 2009/05/05 00:42:41 nagler Exp $ FormModel(); req()->set_realm_and_user('fourem'); my($def_id) = model('TupleUse', {moniker => 'tuple_bunit1'})->get('tuple_def_id'); my($strid, $intid) = map(unauth_model(TupleSlotType => { realm_id => 1, label => $_, })->get('tuple_slot_type_id'), qw(String Integer)); my($data) = { map({ my($x) = $_; (shift(@$x) => {map(("tuple_bunit1.TupleTag.slot$_" => shift(@$x)), 1..4)}); } [qw(crm_tech1 oneopt onereq 1 one)], [qw(mail_user1 twoopt tworeq 2 two)], [qw(tuple_user threeopt threereq 3 three)], ), }; while (my($user, $v) = each(%$data)) { req()->with_user($user => sub { class('Bivio::Biz::Model::t::Tuple::T1Form')->execute(req(), $v); }); } [ req_state({ user => 'root', realm => 'fourem', query => { this => $def_id, } }), empty_case({ 'TupleDef.label' => 'TupleBunit1', 'TupleDef.moniker' => 'tuple_bunit1', 'TupleSlotDef.label_0' => 'Optional', 'TupleSlotDef.label_1' => 'Required', 'TupleSlotDef.label_2' => 'Integer', 'TupleSlotDef.label_3' => 'String', }), [{ 'TupleDef.label' => 'TupleBunit1', 'TupleDef.moniker' => 'tuple_bunit1', 'TupleSlotDef.label_0' => '', 'TupleSlotDef.tuple_slot_type_id_0' => $strid, empty_row_count => 0, }] => sub { while (my($user, $v) = each(%$data)) { assert_contains( {map({ my($new_key) = (/slot(d+)$/) - 1; $new_key > 0 ? ("slot$new_key" => $v->{$_}) : (); } sort(keys(%$v)))}, model(TupleTag => { tuple_def_id => $def_id, primary_id => realm_id($user), })->get_shallow_copy, ); } return 1; }, ];