Bug 7639: (follow-up) add Unit Tests
[koha_fer] / Koha / Authority.pm
index b07db92..509fe3f 100644 (file)
@@ -38,9 +38,9 @@ use MARC::Record;
 use MARC::File::XML;
 use C4::Charset;
 
-use base qw(Class::Accessor);
+use base qw(Koha::MetadataRecord);
 
-__PACKAGE__->mk_accessors(qw( authid authtype record marcflavour ));
+__PACKAGE__->mk_accessors(qw( authid authtype ));
 
 =head2 new
 
@@ -59,17 +59,21 @@ sub new {
     return $self;
 }
 
+
 =head2 get_from_authid
 
     my $auth = Koha::Authority->get_from_authid($authid);
 
 Create the Koha::Authority object associated with the provided authid.
+Note that this routine currently retrieves a MARC record because
+authorities in Koha are MARC records by definition. This is an
+unfortunate but unavoidable fact.
 
 =cut
 sub get_from_authid {
     my $class = shift;
     my $authid = shift;
-    my $marcflavour = C4::Context->preference("marcflavour");
+    my $marcflavour = lc C4::Context->preference("marcflavour");
 
     my $dbh=C4::Context->dbh;
     my $sth=$dbh->prepare("select authtypecode, marcxml from auth_header where authid=?");
@@ -81,8 +85,8 @@ sub get_from_authid {
     $record->encoding('UTF-8');
 
     my $self = $class->SUPER::new( { authid => $authid,
-                                     marcflavour => $marcflavour,
                                      authtype => $authtypecode,
+                                     schema => $marcflavour,
                                      record => $record });
 
     bless $self, $class;