Bugzilla – Attachment 10474 Details for
Bug 8309
Koha namespace organisation, first implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Branches table management
Branches-table-management.patch (text/plain), 7.16 KB, created by
Paul Poulain
on 2012-06-25 13:05:40 UTC
(
hide
)
Description:
Branches table management
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2012-06-25 13:05:40 UTC
Size:
7.16 KB
patch
obsolete
>From a1d15ffd1379738b4d979111295cd44e13a8deb6 Mon Sep 17 00:00:00 2001 >From: Paul Poulain <paul.poulain@biblibre.com> >Date: Wed, 20 Jun 2012 09:00:15 +0200 >Subject: [PATCH] Branches table management > >it's called Branch2.pm because I tried another organisation, then switched to this one, which is better I think > >http://bugs.koha-community.org/show_bug.cgi?id=8309 >--- > Koha/BusinessLogic/Branch2.pm | 7 +++ > Koha/DB/Branch2.pm | 57 ++++++++++++++++++++ > Koha/DataObject/Branch2.pm | 5 ++ > .../lib/KohaTest/Koha/BusinessLogic/Branch2.t | 24 +++++++++ > t/db_dependent/lib/KohaTest/Koha/DB/Branch2.t | 25 +++++++++ > .../lib/KohaTest/Koha/DataObject/Branch2.t | 25 +++++++++ > 6 files changed, 143 insertions(+) > create mode 100644 Koha/BusinessLogic/Branch2.pm > create mode 100644 Koha/DB/Branch2.pm > create mode 100644 Koha/DataObject/Branch2.pm > create mode 100644 t/db_dependent/lib/KohaTest/Koha/BusinessLogic/Branch2.t > create mode 100644 t/db_dependent/lib/KohaTest/Koha/DB/Branch2.t > create mode 100644 t/db_dependent/lib/KohaTest/Koha/DataObject/Branch2.t > >diff --git a/Koha/BusinessLogic/Branch2.pm b/Koha/BusinessLogic/Branch2.pm >new file mode 100644 >index 0000000..99e8873 >--- /dev/null >+++ b/Koha/BusinessLogic/Branch2.pm >@@ -0,0 +1,7 @@ >+package Koha::BusinessLogic::Branch2; >+ >+use Modern::Perl; >+use Moose; >+extends (qw(Koha::DataObject::Branch2)); >+ >+use Koha::DataObject::Branchrelation; >\ No newline at end of file >diff --git a/Koha/DB/Branch2.pm b/Koha/DB/Branch2.pm >new file mode 100644 >index 0000000..6bdbb08 >--- /dev/null >+++ b/Koha/DB/Branch2.pm >@@ -0,0 +1,57 @@ >+package Koha::DB::Branch2; >+ >+use Modern::Perl; >+use C4::Context; #FIXME = create a Koha package for KOHA_CONF reading >+ >+use Koha::Schema; >+ >+use Moose; >+ >+has 'branchcode' => (is => 'rw', required => 1, isa => 'Str'); >+has 'branchname' => (is => 'rw', required => 1, isa => 'Str'); >+has 'branchaddress1' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchaddress2' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchaddress3' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchzip' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchcity' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchstate' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchcountry' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchphone' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchfax' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchemail' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchurl' => (is => 'rw', required => 0, isa => 'Str'); >+has 'issuing' => (is => 'rw', required => 0, isa => 'Int'); >+has 'branchip' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchprinter' => (is => 'rw', required => 0, isa => 'Str'); >+has 'branchnotes' => (is => 'rw', required => 0, isa => 'Str'); >+has 'opac_info' => (is => 'rw', required => 0, isa => 'Str'); >+ >+my $schema = Koha::Schema->connect( >+ 'dbi:mysql:dbname='.C4::Context->config("database"), >+ C4::Context->config("user"), >+ C4::Context->config("pass"), >+ { AutoCommit => 1, >+ cursor_class => 'DBIx::Class::Cursor::Cached', >+ }, >+ ); >+ >+sub create { >+ my ($self) = @_; >+ $schema->resultset('Branch')->create({ map { $_ => $self->$_ } $schema->source('Branch')->columns }); >+} >+ >+sub read { >+ my ($self, $branch) = @_; >+ return $schema->resultset('Branch')->search($branch, { cache_for => 300 }); >+} >+ >+sub update { >+ my ($self, $branch) = @_; >+ return $schema->resultset('Branch')->search({branchcode => $branch->{branchcode}})->update($branch); >+} >+ >+sub delete { >+ my ($self,$branch) = @_; >+ $schema->resultset('Branch')->search($branch)->delete; >+} >+ >diff --git a/Koha/DataObject/Branch2.pm b/Koha/DataObject/Branch2.pm >new file mode 100644 >index 0000000..ddb4162 >--- /dev/null >+++ b/Koha/DataObject/Branch2.pm >@@ -0,0 +1,5 @@ >+package Koha::DataObject::Branch2; >+ >+use Modern::Perl; >+use Moose; >+extends (qw(Koha::DB::Branch2)); >diff --git a/t/db_dependent/lib/KohaTest/Koha/BusinessLogic/Branch2.t b/t/db_dependent/lib/KohaTest/Koha/BusinessLogic/Branch2.t >new file mode 100644 >index 0000000..81850c8 >--- /dev/null >+++ b/t/db_dependent/lib/KohaTest/Koha/BusinessLogic/Branch2.t >@@ -0,0 +1,24 @@ >+#!/usr/bin/perl >+ >+use v5.10.0; >+use Modern::Perl; >+ >+use Test::More tests => 5; >+ >+BEGIN { >+ use_ok('Koha::BusinessLogic::Branch2', 'Loading Koha::BusinessLogic::Branch2 OK'); >+} >+ >+# CREATE >+my $branch = Koha::BusinessLogic::Branch2->new({'branchcode' => 'TEST_T','branchname' => 'TEST NAME'}); >+ok($branch->create->id eq 'TEST_T','Creating a branch OK'); >+ >+# READ >+ok(Koha::BusinessLogic::Branch2->read({'branchcode' => 'TEST_T'})->first->branchname eq 'TEST NAME','Reading a branch OK'); >+ >+# UPDATE >+Koha::BusinessLogic::Branch2->update({'branchcode' => 'TEST_T','branchname' => 'TEST UPDATED'}); >+ok(Koha::BusinessLogic::Branch2->read({'branchcode' => 'TEST_T'})->first->branchname eq 'TEST UPDATED','Updating a branch OK'); >+ >+# DELETE >+ok(Koha::BusinessLogic::Branch2->delete({'branchcode' => 'TEST_T'}),'Deleting a branch OK'); >diff --git a/t/db_dependent/lib/KohaTest/Koha/DB/Branch2.t b/t/db_dependent/lib/KohaTest/Koha/DB/Branch2.t >new file mode 100644 >index 0000000..bcc0efa >--- /dev/null >+++ b/t/db_dependent/lib/KohaTest/Koha/DB/Branch2.t >@@ -0,0 +1,25 @@ >+#!/usr/bin/perl >+ >+use v5.10.0; >+use Modern::Perl; >+ >+use Test::More tests => 5; >+ >+BEGIN { >+ use_ok('Koha::DB::Branch2', 'Loading Koha::DB::Branch OK'); >+} >+ >+# CREATE >+my $branch = Koha::DB::Branch2->new({'branchcode' => 'TEST','branchname' => 'TEST NAME'}); >+ok($branch->create->id eq 'TEST','Creating a branch OK'); >+ >+# READ >+ok(Koha::DB::Branch2->read({'branchcode' => 'TEST'})->first->branchname eq 'TEST NAME','Reading a branch OK'); >+ >+# UPDATE >+Koha::DB::Branch2->update({'branchcode' => 'TEST','branchname' => 'TEST UPDATED'}); >+ok(Koha::DB::Branch2->read({'branchcode' => 'TEST'})->first->branchname eq 'TEST UPDATED','Updating a branch OK'); >+ >+# DELETE >+ok(Koha::DB::Branch2->delete({'branchcode' => 'TEST'}),'Deleting a branch OK'); >+ >diff --git a/t/db_dependent/lib/KohaTest/Koha/DataObject/Branch2.t b/t/db_dependent/lib/KohaTest/Koha/DataObject/Branch2.t >new file mode 100644 >index 0000000..5718e7c >--- /dev/null >+++ b/t/db_dependent/lib/KohaTest/Koha/DataObject/Branch2.t >@@ -0,0 +1,25 @@ >+#!/usr/bin/perl >+ >+use v5.10.0; >+use Modern::Perl; >+ >+use Test::More tests => 5; >+ >+BEGIN { >+ use_ok('Koha::DataObject::Branch2', 'Loading Koha::DataObject::Branch2 OK'); >+} >+ >+# CREATE >+my $branch = Koha::DataObject::Branch2->new({'branchcode' => 'TEST','branchname' => 'TEST NAME'}); >+ok($branch->create->id eq 'TEST','Creating a branch OK'); >+ >+# READ >+ok(Koha::DataObject::Branch2->read({'branchcode' => 'TEST'})->first->branchname eq 'TEST NAME','Reading a branch OK'); >+ >+# UPDATE >+Koha::DataObject::Branch2->update({'branchcode' => 'TEST','branchname' => 'TEST UPDATED'}); >+ok(Koha::DataObject::Branch2->read({'branchcode' => 'TEST'})->first->branchname eq 'TEST UPDATED','Updating a branch OK'); >+ >+# DELETE >+ok(Koha::DataObject::Branch2->delete({'branchcode' => 'TEST'}),'Deleting a branch OK'); >+ >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8309
:
10473
| 10474 |
10475
|
10476
|
10477
|
10478