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

(-)a/t/db_dependent/Illrequests.t (-2 / +56 lines)
Lines 22-34 use Koha::Database; Link Here
22
use Koha::Illrequestattributes;
22
use Koha::Illrequestattributes;
23
use Koha::Illrequest::Config;
23
use Koha::Illrequest::Config;
24
use Koha::Patrons;
24
use Koha::Patrons;
25
use Koha::AuthorisedValueCategories;
26
use Koha::AuthorisedValues;
25
use t::lib::Mocks;
27
use t::lib::Mocks;
26
use t::lib::TestBuilder;
28
use t::lib::TestBuilder;
27
use Test::MockObject;
29
use Test::MockObject;
28
use Test::MockModule;
30
use Test::MockModule;
29
use Test::Exception;
31
use Test::Exception;
30
32
31
use Test::More tests => 11;
33
use Test::More tests => 12;
32
34
33
my $schema = Koha::Database->new->schema;
35
my $schema = Koha::Database->new->schema;
34
my $builder = t::lib::TestBuilder->new;
36
my $builder = t::lib::TestBuilder->new;
Lines 860-862 subtest 'TO_JSON() tests' => sub { Link Here
860
862
861
    $schema->storage->txn_rollback;
863
    $schema->storage->txn_rollback;
862
};
864
};
863
- 
865
866
subtest 'Custom statuses' => sub {
867
868
    plan tests => 3;
869
870
    $schema->storage->txn_begin;
871
872
    my $cat = Koha::AuthorisedValueCategories->search(
873
        {
874
            category_name => 'ILLSTATUS'
875
        }
876
    );
877
878
    if ($cat->count == 0) {
879
        $cat  = $builder->build_object(
880
            {
881
                class => 'Koha::AuthorisedValueCategory',
882
                value => {
883
                    category_name => 'ILLSTATUS'
884
                }
885
            }
886
        );
887
    };
888
889
    my $av = $builder->build_object(
890
        {
891
            class => 'Koha::AuthorisedValues',
892
            value => {
893
                category => 'ILLSTATUS'
894
            }
895
        }
896
    );
897
898
    is($av->category, 'ILLSTATUS',
899
       "Successfully created authorised value for custom status");
900
901
    my $ill_req = $builder->build_object(
902
        {
903
            class => 'Koha::Illrequests',
904
            value => {
905
                status_alias => $av->id
906
            }
907
        }
908
    );
909
    isa_ok($ill_req->statusalias, 'Koha::AuthorisedValue',
910
           "statusalias correctly returning Koha::AuthorisedValue object");
911
912
    $ill_req->status("COMP");
913
    is($ill_req->statusalias, undef,
914
        "Koha::Illrequest->status overloading resetting status_alias");
915
916
    $schema->storage->txn_rollback;
917
};

Return to bug 20581