"Fossies" - the Fresh Open Source Software Archive

Member "eprints3.4-3.4.4/tests/40_views.pl" (7 Aug 2022, 2718 Bytes) of package /linux/www/eprints3.4-3.4.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "40_views.pl": 3.4-3.4.3_vs_3.4-3.4.4.

    1 use strict;
    2 use Test::More tests => 6;
    3 
    4 BEGIN { use_ok( "EPrints" ); }
    5 BEGIN { use_ok( "EPrints::Test" ); }
    6 
    7 
    8 $SIG{INT} = sub { die "CAUGHT SIGINT\n" };
    9 
   10 EPrints::Test::mem_increase();
   11 
   12 my $repo = EPrints::Test->repository;
   13 
   14 $repo->cache_subjects;
   15 
   16 my $views = $repo->config( "browse_views" );
   17 
   18 my $ds = $repo->dataset( "archive" );
   19 
   20 my $test_id = "_40_views_pl";
   21 
   22 my $lang = $repo->get_lang;
   23 my $langid = $lang->{id};
   24 
   25 my $viewdir = File::Temp->newdir();
   26 
   27 local $repo->{config}->{htdocs_path} = "$viewdir";
   28 
   29 # Work-around to suppress the phrase warnings
   30 {
   31 my $data = $lang->_get_repositorydata;
   32 my $phrase = $repo->make_element( "phrase", id => "viewname_eprint_$test_id" );
   33 $phrase->appendChild( $repo->make_text( $test_id ) );
   34 $data->{xml}->{"viewname_eprint_$test_id"} = $phrase;
   35 keys %{$data->{file}};
   36 (undef, $data->{file}->{"viewname_eprint_$test_id"}) = each %{$data->{file}};
   37 keys %{$data->{file}};
   38 }
   39 
   40 my $test_view = 
   41 {
   42     id => $test_id,
   43     allow_null => 1,
   44     fields => "-date;res=year",
   45     order => "creators_name/title",
   46     variations => [
   47         "creators_name;first_letter",
   48         "type",
   49         "DEFAULT" ],
   50 };
   51 
   52 my $view = EPrints::Update::Views->new(
   53     repository => $repo,
   54     view => $test_view
   55 );
   56 
   57 EPrints::Test::mem_increase();
   58 Test::More::diag( "memory footprint\n" );
   59 
   60 $view->update_view_by_path(
   61         on_write => sub { diag( $_[0] ); },
   62         langid => $langid, 
   63         do_menus => 1,
   64         do_lists => 1 );
   65 
   66 ok( -e "$viewdir/$langid/view/$test_id/index.page", "browse_view_menu");
   67 ok( -e "$viewdir/$langid/view/$test_id/2004.page", "browse_view_menu");
   68 
   69 Test::More::diag( "\t update_view_by_path=" . EPrints::Test::human_mem_increase() );
   70 
   71 EPrints::Update::Views::update_view_file(
   72         $repo,
   73         $langid,
   74         "view/index.html" );
   75 
   76 ok( -e "$viewdir/$langid/view/index.page", "browse_view_menu");
   77 
   78 Test::More::diag( "\t update_browse_view_list=" . EPrints::Test::human_mem_increase() );
   79 
   80 ok(1);
   81 
   82 
   83 
   84 =head1 COPYRIGHT
   85 
   86 =for COPYRIGHT BEGIN
   87 
   88 Copyright 2022 University of Southampton.
   89 EPrints 3.4 is supplied by EPrints Services.
   90 
   91 http://www.eprints.org/eprints-3.4/
   92 
   93 =for COPYRIGHT END
   94 
   95 =for LICENSE BEGIN
   96 
   97 This file is part of EPrints 3.4 L<http://www.eprints.org/>.
   98 
   99 EPrints 3.4 and this file are released under the terms of the
  100 GNU Lesser General Public License version 3 as published by
  101 the Free Software Foundation unless otherwise stated.
  102 
  103 EPrints 3.4 is distributed in the hope that it will be useful,
  104 but WITHOUT ANY WARRANTY; without even the implied warranty of
  105 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  106 See the GNU Lesser General Public License for more details.
  107 
  108 You should have received a copy of the GNU Lesser General Public
  109 License along with EPrints 3.4.
  110 If not, see L<http://www.gnu.org/licenses/>.
  111 
  112 =for LICENSE END
  113