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

(-)a/Koha/ArticleRequest.pm (-1 / +1 lines)
Lines 269-275 sub store { Link Here
269
        $self->created_on( dt_from_string() );
269
        $self->created_on( dt_from_string() );
270
    }
270
    }
271
271
272
    Koha::Exceptions::ArticleRequest::WrongFormat->throw
272
    Koha::Exceptions::ArticleRequest::WrongFormat->throw( format => $self->format )
273
        unless grep { $_ eq $self->format } @{ C4::Context->multivalue_preference('ArticleRequestsSupportedFormats') };
273
        unless grep { $_ eq $self->format } @{ C4::Context->multivalue_preference('ArticleRequestsSupportedFormats') };
274
274
275
    return $self->SUPER::store;
275
    return $self->SUPER::store;
(-)a/Koha/Exceptions/ArticleRequest.pm (-1 / +2 lines)
Lines 29-35 use Exception::Class ( Link Here
29
    },
29
    },
30
    'Koha::Exceptions::ArticleRequest::WrongFormat' => {
30
    'Koha::Exceptions::ArticleRequest::WrongFormat' => {
31
        isa         => 'Koha::Exceptions::ArticleRequest',
31
        isa         => 'Koha::Exceptions::ArticleRequest',
32
        description => 'Passed format is not locally supported'
32
        description => 'Passed format is not locally supported',
33
        fields      => ['format'],
33
    },
34
    },
34
);
35
);
35
36
(-)a/t/db_dependent/Koha/ArticleRequest.t (-2 / +2 lines)
Lines 224-236 subtest 'cancel() tests' => sub { Link Here
224
};
224
};
225
225
226
subtest 'store' => sub {
226
subtest 'store' => sub {
227
    plan tests => 2;
227
    plan tests => 3;
228
    $schema->storage->txn_begin;
228
    $schema->storage->txn_begin;
229
229
230
    t::lib::Mocks::mock_preference( 'ArticleRequestsSupportedFormats', 'SCAN' );
230
    t::lib::Mocks::mock_preference( 'ArticleRequestsSupportedFormats', 'SCAN' );
231
    my $ar = $builder->build_object( { class => 'Koha::ArticleRequests', value => { format => 'PHOTOCOPY' } } );
231
    my $ar = $builder->build_object( { class => 'Koha::ArticleRequests', value => { format => 'PHOTOCOPY' } } );
232
    throws_ok { $ar->format('test')->store } 'Koha::Exceptions::ArticleRequest::WrongFormat',
232
    throws_ok { $ar->format('test')->store } 'Koha::Exceptions::ArticleRequest::WrongFormat',
233
        'Format not supported';
233
        'Format not supported';
234
    is( $@->format, 'test', 'Passed format returned with the exception' );
234
    t::lib::Mocks::mock_preference( 'ArticleRequestsSupportedFormats', 'SCAN|PHOTOCOPY|ELSE' );
235
    t::lib::Mocks::mock_preference( 'ArticleRequestsSupportedFormats', 'SCAN|PHOTOCOPY|ELSE' );
235
    lives_ok { $ar->format('PHOTOCOPY')->store } 'Now we do support it';
236
    lives_ok { $ar->format('PHOTOCOPY')->store } 'Now we do support it';
236
237
237
- 

Return to bug 39191