# Copyright (c) 2008 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: FileChangeForm.bunit,v 1.2 2008/11/17 13:52:07 nagler Exp $ require 'FileChangeForm.PL'; my($upload) = sub { my($path, $content, $comment) = @_; return ( file => { filename => $path, content => defined($content) ? \$content : \('some text'), content_type => 'plain/text', }, comment => $comment || 'a comment', ); }; my($_FCM) = __PACKAGE__->use('Type.FileChangeMode'); [ [{ $upload->('/mypath/to/the/foo.txt', undef, 'initial revision'), mode => $_FCM->UPLOAD, }] => [{ 'Model.RealmFile' => { path => '/foo.txt', is_folder => 0, }, 'Model.RealmFileLock' => { realm_file_id => sub {req(qw(Model.RealmFile realm_file_id))}, comment => 'initial revision', }, }], sub { model('RealmFile')->create_folder({ path => '/folder1', }); return 1; } => 1, [{ path_info => '/folder1', $upload->('/mypath/to/the/foo2.txt', 'some more text'), mode => $_FCM->UPLOAD, }] => [{ 'Model.RealmFile' => { path => '/folder1/foo2.txt', is_folder => 0, }, }], sub { ${req('Model.RealmFile')->get_content} eq 'some more text' ? 1 : 0; } => 1, error_case({ comment => 'x', mode => $_FCM->UPLOAD, }, { file => 'NULL', }), error_case({ $upload->('*'), mode => $_FCM->UPLOAD, }, { file => 'FILE_NAME', }), error_case({ $upload->('foo3.txt', ''), mode => $_FCM->UPLOAD, }, { file => 'EMPTY', }), error_case({ $upload->(''), mode => $_FCM->UPLOAD, }, { file => 'FILE_NAME', }), ];