&getitemtypeimagelocation
&GetAuthorisedValues
&GetAuthorisedValueCategories
- &IsAuthorisedValueCategory
&GetKohaAuthorisedValues
&GetKohaAuthorisedValuesFromField
&GetKohaAuthorisedValuesMapping
return \@results;
}
-=head2 IsAuthorisedValueCategory
-
- $is_auth_val_category = IsAuthorisedValueCategory($category);
-
-Returns whether a given category name is a valid one
-
-=cut
-
-sub IsAuthorisedValueCategory {
- my $category = shift;
- my $query = '
- SELECT category
- FROM authorised_values
- WHERE category=?
- LIMIT 1
- ';
- my $sth = C4::Context->dbh->prepare($query);
- $sth->execute($category);
- $sth->fetchrow ? return 1
- : return 0;
-}
-
=head2 GetAuthorisedValueByCode
$authorised_value = GetAuthorisedValueByCode( $category, $authvalcode, $opac );
# use Data::Dumper;
use C4::Log;
+use Koha::AuthorisedValues;
+
BEGIN {
# set the version for version checking
$VERSION = 3.07.00.049;
my $reserved_authorised_values = GetReservedAuthorisedValues();
if ( exists $reserved_authorised_values->{$authorised_value} ||
- C4::Koha::IsAuthorisedValueCategory($authorised_value) ) {
+ Koha::AuthorisedValues->search({ category => $authorised_value })->count ) {
return 1;
}
use C4::Output;
use C4::Debug;
use C4::Branch; # XXX subfield_is_koha_internal_p
-use C4::Koha qw/IsAuthorisedValueCategory GetFrameworksLoop/;
+use C4::Koha qw/GetFrameworksLoop/;
use C4::Context;
use C4::Log;
use Koha::DateUtils qw/dt_from_string output_pref/;
use Koha::AuthorisedValue;
+use Koha::AuthorisedValues;
=head1 NAME
#---- "true" authorised value
}
else {
- if ( IsAuthorisedValueCategory($authorised_value) ) {
+ if ( Koha::AuthorisedValues->search({ category => $authorised_value })->count ) {
my $query = '
SELECT authorised_value,lib
FROM authorised_values
BEGIN {
if ( check_install( module => 'Test::DBIx::Class' ) ) {
- plan tests => 34;
+ plan tests => 31;
} else {
plan skip_all => "Need Test::DBIx::Class"
}
connect_info => ['dbi:SQLite:dbname=:memory:','',''],
connect_opts => { name_sep => '.', quote_char => '`', },
fixture_class => '::Populate',
-}, 'AuthorisedValue', 'Branch' ;
+}, 'Branch' ;
sub fixtures {
- my ( $av, $libraries ) = @_;
+ my ( $libraries ) = @_;
fixtures_ok [
- AuthorisedValue => [
- [ 'category', 'authorised_value' ],
- @$av,
- ],
Branch => [
['branchcode', 'branchname'],
@$libraries,
my $db = Test::MockModule->new('Koha::Database');
$db->mock( _new_schema => sub { return Schema(); } );
-my $authorised_values = [
- ['LOC', 'LOC'],
- ['RELTERMS', 'RELTERMS'],
-];
my $libraries = [
['XXX_test', 'my branchname XXX'],
];
-fixtures($authorised_values, $libraries);
-
-is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value category');
-is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category');
-is ( IsAuthorisedValueCategory('RELTERMS'), 1, 'RELTERMS is a valid authorized value category');
+fixtures($libraries);
my $isbn13 = "9780330356473";
my $isbn13D = "978-0-330-35647-3";
['YYY_test', 'my branchname YYY'],
['ZZZ_test', 'my branchname XXX'],
];
- fixtures($authorised_values, $libraries);
+ fixtures($libraries);
is ( Koha::Libraries->search->count, 3, 'There should be only more than 1 library (singleBranchMode off)' );
$facets = C4::Koha::getFacets();
use Modern::Perl;
use Test::More tests => 13;
-use Test::MockModule;
-use t::lib::Mocks;
+use Koha::Database;
use_ok('C4::Reports::Guided');
-my $context = new Test::MockModule('C4::Context');
-my $koha = new Test::MockModule('C4::Koha');
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
-BEGIN {
- t::lib::Mocks::mock_dbh;
-}
-
-sub MockedIsAuthorisedValueCategory {
- my $authorised_value = shift;
-
- if ( $authorised_value eq 'LOC' ) {
- return 1;
- } else {
- return 0;
- }
-}
-
-$koha->mock(
- 'IsAuthorisedValueCategory',
- \&MockedIsAuthorisedValueCategory
-);
+$_->delete for Koha::AuthorisedValues->search({ category => 'XXX' });
+Koha::AuthorisedValue->new({category => 'LOC'})->store;
{ # GetReservedAuthorisedValues tests
# This one will catch new reserved words not added