Bugzilla – Attachment 47855 Details for
Bug 15707
Add ability to define hierarchical groups of libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15707 - Unit Tests
Bug-15707---Unit-Tests.patch (text/plain), 3.51 KB, created by
Kyle M Hall (khall)
on 2016-02-10 14:11:00 UTC
(
hide
)
Description:
Bug 15707 - Unit Tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-02-10 14:11:00 UTC
Size:
3.51 KB
patch
obsolete
>From f85de2417faea0ab484ee5304df422c4ec92a102 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 5 Feb 2016 06:53:20 +0000 >Subject: [PATCH] Bug 15707 - Unit Tests > >--- > t/db_dependent/LibraryGroups.t | 79 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > create mode 100644 t/db_dependent/LibraryGroups.t > >diff --git a/t/db_dependent/LibraryGroups.t b/t/db_dependent/LibraryGroups.t >new file mode 100644 >index 0000000..5076e11 >--- /dev/null >+++ b/t/db_dependent/LibraryGroups.t >@@ -0,0 +1,79 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use List::MoreUtils 'any'; >+ >+use Test::More tests => 13; >+ >+use t::lib::TestBuilder; >+ >+BEGIN { >+ use FindBin; >+ use lib $FindBin::Bin; >+ use_ok('Koha::Library::Group'); >+ use_ok('Koha::Library::Groups'); >+} >+ >+our $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+$dbh->do(q|DELETE FROM issues|); >+ >+my $builder = t::lib::TestBuilder->new(); >+ >+my $library1 = $builder->build( >+ { >+ source => 'Branch', >+ } >+); >+ >+my $library2 = $builder->build( >+ { >+ source => 'Branch', >+ } >+); >+ >+my $library3 = $builder->build( >+ { >+ source => 'Branch', >+ } >+); >+ >+my $root_group = >+ Koha::Library::Group->new( { title => "Test root group" } )->store(); >+ >+my @root_groups = Koha::Library::Groups->get_root_groups(); >+my $in_list = any { $_->id eq $root_group->id } @root_groups; >+ok( $in_list, 'New root group is in the list returned by the get_root_groups method'); >+ >+my $groupA = Koha::Library::Group->new({ parent_id => $root_group->id, title => 'Group A' })->store(); >+my $groupA1 = Koha::Library::Group->new({ parent_id => $groupA->id, title => 'Group A1' })->store(); >+my $groupA2 = Koha::Library::Group->new({ parent_id => $groupA->id, title => 'Group A2' })->store(); >+ >+my $groupA_library1 = Koha::Library::Group->new({ parent_id => $groupA->id, branchcode => $library1->{branchcode} })->store(); >+my $groupA1_library2 = Koha::Library::Group->new({ parent_id => $groupA1->id, branchcode => $library2->{branchcode} })->store(); >+ >+my @children = $root_group->children()->as_list(); >+is( $children[0]->id, $groupA->id, 'Child of root group set correctly' ); >+ >+@children = $groupA->children()->as_list(); >+is( $children[1]->id, $groupA1->id, 'Child 1 of 2nd level group set correctly' ); >+is( $children[2]->id, $groupA2->id, 'Child 2 of 2nd level group set correctly' ); >+is( $children[0]->id, $groupA_library1->id, 'Child 3 of 2nd level group set correctly' ); >+ >+is( $children[0]->branchcode, $groupA_library1->branchcode, 'Child 3 is correctly set as leaf node' ); >+ >+@children = $groupA1->children()->as_list(); >+is( $children[0]->branchcode, $library2->{branchcode}, 'Child 1 of 3rd level group correctly set as leaf node' ); >+ >+my $library = $groupA_library1->library(); >+is( ref( $library ), 'Koha::Library', 'Method library returns a Koha::Library object' ); >+is( $library->id, $groupA_library1->branchcode, 'Branchcode for fetched library matches' ); >+ >+my @libraries_not_direct_children = $groupA->libraries_not_direct_children(); >+$in_list = any { $_->id eq $groupA_library1->branchcode } @libraries_not_direct_children; >+ok( !$in_list, 'Method libraries_not_direct_children returns all libraries not direct decendents of group, library 1 is not in the list'); >+$in_list = any { $_->id eq $groupA1_library2->branchcode } @libraries_not_direct_children; >+ok( $in_list, 'Method libraries_not_direct_children returns all libraries not direct decendents of group, library 2 is in the list'); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15707
:
47479
|
47480
|
47481
|
47482
|
47483
|
47484
|
47728
|
47729
|
47730
|
47731
|
47732
|
47733
|
47734
|
47849
|
47850
|
47851
|
47852
|
47853
|
47854
|
47855
|
47868
|
47869
|
47870
|
47871
|
47872
|
47873
|
47874
|
48072
|
50400
|
50401
|
50402
|
50403
|
50404
|
50405
|
50406
|
50407
|
50408
|
52267
|
52268
|
52269
|
52270
|
52271
|
52272
|
52273
|
52274
|
52275
|
52367
|
52370
|
52562
|
52563
|
52564
|
52565
|
52566
|
52567
|
52568
|
52569
|
52570
|
52571
|
52572
|
52573
|
52574
|
52575
|
57080
|
57081
|
57082
|
57083
|
57084
|
57085
|
57086
|
57087
|
57088
|
57089
|
57090
|
57091
|
57092
|
57093
|
58086
|
60504
|
60505
|
60506
|
60507
|
60508
|
60509
|
60510
|
60511
|
60512
|
60513
|
60514
|
60515
|
60516
|
60517
|
60518
|
60572
|
60573
|
60574
|
60575
|
60576
|
60577
|
60578
|
60579
|
60580
|
60581
|
60582
|
60583
|
60584
|
60585
|
60586
|
60587
|
60755
|
60756
|
60757
|
60758
|
60759
|
60760
|
60761
|
60762
|
60763
|
60764
|
60765
|
60766
|
60767
|
60768
|
60769
|
60770
|
60771
|
65666
|
65667
|
65668
|
65669
|
65670
|
65671
|
65672
|
65673
|
65674
|
65675
|
65676
|
65677
|
65678
|
65679
|
65680
|
65681
|
69514
|
69515
|
69516
|
69517
|
69518
|
69519
|
69520
|
69521
|
69522
|
69523
|
69524
|
69525
|
69526
|
69527
|
69528
|
69529
|
69573
|
69574
|
69575
|
69576
|
69577
|
69578
|
69579
|
69580
|
69581
|
69582
|
69583
|
69584
|
69585
|
69586
|
69587
|
69588
|
69589