View | Details | Raw Unified | Return to bug 19915
Collapse All | Expand All

(-)a/t/db_dependent/Items/GetItemsForInventory.t (-32 / +24 lines)
Lines 18-60 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::More tests => 7;
21
use Test::More tests => 2;
22
22
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
23
24
24
use Koha::AuthorisedValues;
25
use C4::Context;
26
use C4::Biblio;
25
use C4::ClassSource;
27
use C4::ClassSource;
28
use C4::Items;
29
use C4::Koha;
30
use Koha::AuthorisedValues;
31
use Koha::Database;
32
use Koha::Items;
26
33
27
$| = 1;
34
my $schema  = Koha::Database->new->schema;
28
35
$schema->storage->txn_begin;
29
BEGIN {
30
    use_ok('C4::Context');
31
    use_ok('C4::Items');
32
    use_ok('C4::Biblio');
33
    use_ok('C4::Koha');
34
}
35
36
can_ok('C4::Items','GetItemsForInventory');
37
38
my $dbh = C4::Context->dbh;
39
$dbh->{AutoCommit} = 0;
40
$dbh->{RaiseError} = 1;
41
42
my ($oldResults, $oldCount) = OldWay($dbh);
43
my ($newResults, $newCount) = GetItemsForInventory;
44
36
45
is_deeply($newResults,$oldResults,"Inventory results unchanged.");
37
subtest 'Verify results with OldWay' => sub {
38
    plan tests => 1;
46
39
47
$dbh->rollback;
40
    my ($oldResults, $oldCount) = OldWay();
48
$dbh->{AutoCommit} = 1;
41
    my ($newResults, $newCount) = GetItemsForInventory();
42
    is_deeply($newResults,$oldResults,"Inventory results unchanged.");
43
};
49
44
50
subtest 'Use cn_sort rather than callnumber to determine correct location' => sub {
45
subtest 'Use cn_sort rather than callnumber to determine correct location' => sub {
51
52
    plan tests => 1;
46
    plan tests => 1;
47
53
    my $builder = t::lib::TestBuilder->new;
48
    my $builder = t::lib::TestBuilder->new;
54
    my $schema  = Koha::Database->new->schema;
49
    Koha::Items->delete;
55
    $schema->storage->txn_begin;
56
    $builder->schema->resultset( 'Issue' )->delete_all;
57
    $builder->schema->resultset( 'Item' )->delete_all;
58
50
59
    my $class_rule = $builder->build({
51
    my $class_rule = $builder->build({
60
        source => 'ClassSortRule',
52
        source => 'ClassSortRule',
Lines 80-92 subtest 'Use cn_sort rather than callnumber to determine correct location' => su Link Here
80
        class_source => $class_source->{cn_source},
72
        class_source => $class_source->{cn_source},
81
    });
73
    });
82
    is($item_count,1,"We should return GT95 as between GT90 and GT100");
74
    is($item_count,1,"We should return GT95 as between GT90 and GT100");
83
    $schema->storage->txn_rollback;
84
75
85
};
76
};
86
77
87
sub OldWay {
78
$schema->storage->txn_rollback;
88
    my ($tdbh)       = @_;
79
89
    my $ldbh         = $tdbh;
80
sub OldWay { # FIXME Do we really still need so much code to check results ??
81
    my $ldbh = C4::Context->dbh;
82
90
    my $minlocation  = '';
83
    my $minlocation  = '';
91
    my $maxlocation  = '';
84
    my $maxlocation  = '';
92
    my $location     = '';
85
    my $location     = '';
93
- 

Return to bug 19915