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

(-)a/Koha/Patron.pm (-1 / +1 lines)
Lines 1576-1582 sub extended_attributes { Link Here
1576
                              undef
1576
                              undef
1577
                        },
1577
                        },
1578
                        { join => 'borrower_attribute_types_branches' }
1578
                        { join => 'borrower_attribute_types_branches' }
1579
                    )->get_column('class');
1579
                    )->get_column('code');
1580
                for my $type ( @required_attribute_types ) {
1580
                for my $type ( @required_attribute_types ) {
1581
                    Koha::Exceptions::Object::FKConstraint->throw(
1581
                    Koha::Exceptions::Object::FKConstraint->throw(
1582
                        broken_fk => "$type",
1582
                        broken_fk => "$type",
(-)a/t/db_dependent/Koha/Patron.t (-4 / +13 lines)
Lines 616-636 subtest 'extended_attributes' => sub { Link Here
616
616
617
    subtest 'globally mandatory attributes tests' => sub {
617
    subtest 'globally mandatory attributes tests' => sub {
618
618
619
        plan tests => 3;
619
        plan tests => 5;
620
620
621
        my $patron = $builder->build_object({ class => 'Koha::Patrons' });
621
        my $patron = $builder->build_object({ class => 'Koha::Patrons' });
622
622
623
        my $attribute_type_1 = $builder->build_object(
623
        my $attribute_type_1 = $builder->build_object(
624
            {
624
            {
625
                class => 'Koha::Patron::Attribute::Types',
625
                class => 'Koha::Patron::Attribute::Types',
626
                value => { mandatory => 1 }
626
                value => { mandatory => 1, class => 'a' }
627
            }
627
            }
628
        );
628
        );
629
629
630
        my $attribute_type_2 = $builder->build_object(
630
        my $attribute_type_2 = $builder->build_object(
631
            {
631
            {
632
                class => 'Koha::Patron::Attribute::Types',
632
                class => 'Koha::Patron::Attribute::Types',
633
                value => { mandatory => 0 }
633
                value => { mandatory => 0, class => 'a' }
634
            }
634
            }
635
        );
635
        );
636
636
Lines 647-653 subtest 'extended_attributes' => sub { Link Here
647
            'Koha::Exceptions::Object::FKConstraint',
647
            'Koha::Exceptions::Object::FKConstraint',
648
            'Exception thrown on missing mandatory attribute type';
648
            'Exception thrown on missing mandatory attribute type';
649
649
650
        is( $@->value, $attribute_type_1->code, 'Exception parameters are correct' );
651
650
        is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' );
652
        is( $patron->extended_attributes->count, 0, 'Extended attributes storing rolled back' );
653
654
        $patron->extended_attributes(
655
            [
656
                { code => $attribute_type_1->code, attribute => 'b' }
657
            ]
658
        );
659
660
        is( $patron->extended_attributes->count, 1, 'Extended attributes succeeded' );
651
    };
661
    };
652
662
653
    $schema->storage->txn_rollback;
663
    $schema->storage->txn_rollback;
654
- 

Return to bug 27857