Bugzilla – Attachment 43867 Details for
Bug 14778
DBIC should create/own the DB handler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 14778: Install fixtures for t/Images.t
PASSED-QA-Bug-14778-Install-fixtures-for-tImagest.patch (text/plain), 3.50 KB, created by
Kyle M Hall (khall)
on 2015-10-23 14:56:43 UTC
(
hide
)
Description:
[PASSED QA] Bug 14778: Install fixtures for t/Images.t
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-10-23 14:56:43 UTC
Size:
3.50 KB
patch
obsolete
>From 8e60d9238c57f801c35c5ec44ebe53de195ec1f4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 20 Oct 2015 12:44:55 +0100 >Subject: [PATCH] [PASSED QA] Bug 14778: Install fixtures for t/Images.t > >Note that this tests file were completely buggy before. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Images.pm | 2 +- > t/Images.t | 63 +++++++++++++++++++++++++++------------------------------ > 2 files changed, 31 insertions(+), 34 deletions(-) > >diff --git a/C4/Images.pm b/C4/Images.pm >index 74b7068..936c4df 100644 >--- a/C4/Images.pm >+++ b/C4/Images.pm >@@ -102,7 +102,7 @@ sub RetrieveImage { > > my $dbh = C4::Context->dbh; > my $query = >-'SELECT mimetype, imagefile, thumbnail FROM biblioimages WHERE imagenumber = ?'; >+'SELECT imagenumber, mimetype, imagefile, thumbnail FROM biblioimages WHERE imagenumber = ?'; > my $sth = $dbh->prepare($query); > $sth->execute($imagenumber); > my $imagedata = $sth->fetchrow_hashref; >diff --git a/t/Images.t b/t/Images.t >index c35d5bd..274766b 100644 >--- a/t/Images.t >+++ b/t/Images.t >@@ -2,53 +2,50 @@ > # > #Testing C4 Images > >-use strict; >-use warnings; >-use Test::More tests => 7; >+use Modern::Perl; >+use Test::More tests => 8; > use Test::MockModule; > >-BEGIN { >- use_ok('C4::Images'); >-} >- >-my $module = new Test::MockModule('C4::Context'); >-$module->mock( >- '_new_dbh', >- sub { >- my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) >- || die "Cannot create handle: $DBI::errstr\n"; >- return $dbh; >- } >+use_ok('C4::Images'); >+ >+use Test::DBIx::Class { >+ schema_class => 'Koha::Schema', >+ connect_info => ['dbi:SQLite:dbname=:memory:','',''], >+ connect_opts => { name_sep => '.', quote_char => '`', }, >+ fixture_class => '::Populate', >+}, 'Biblioimage' ; >+ >+# Make the code in the module use our mocked Koha::Schema/Koha::Database >+my $db = Test::MockModule->new('Koha::Database'); >+$db->mock( >+ # Schema() gives us the DB connection set up by Test::DBIx::Class >+ _new_schema => sub { return Schema(); } > ); >+ >+my $biblionumber = 2; > my $images = [ >- [ 'imagenumber', 'biblionumber', 'mimetype', 'imagefile', 'thumbnail' ], >- [ 1, 2, 'gif', 'red', 001, 000 ], >- [ 3, 2, 'jpeg', 'blue', 111, 110 ] >+ [ 1, $biblionumber, 'gif', 'imagefile1', 'thumbnail1' ], >+ [ 3, $biblionumber, 'jpeg', 'imagefile3', 'thumbnail3' ], > ]; >-my $dbh = C4::Context->dbh(); >- >-$dbh->{mock_add_resultset} = $images; >+fixtures_ok [ >+ Biblioimage => [ >+ [ 'imagenumber', 'biblionumber', 'mimetype', 'imagefile', 'thumbnail' ], >+ @$images, >+ ], >+], 'add fixtures'; > >-my $image = C4::Images::RetrieveImage(); >+my $image = C4::Images::RetrieveImage(1); > > is( $image->{'imagenumber'}, 1, 'First imagenumber is 1' ); > >-is( $image->{'mimetype'}, 'gif', 'First mimetype is red' ); >+is( $image->{'mimetype'}, 'gif', 'First mimetype is gif' ); > >-is( $image->{'thumbnail'}, 001, 'First thumbnail is 001' ); >+is( $image->{'thumbnail'}, 'thumbnail1', 'First thumbnail is correct' ); > >-$image = C4::Images::RetrieveImage(); >- >-$image = C4::Images::RetrieveImage(); >- >-$dbh->{mock_add_resultset} = $images; >- >-my @imagenumbers = C4::Images::ListImagesForBiblio(); >+my @imagenumbers = C4::Images::ListImagesForBiblio($biblionumber); > > is( $imagenumbers[0], 1, 'imagenumber is 1' ); > > is( $imagenumbers[1], 3, 'imagenumber is 3' ); > >-$dbh->{mock_add_resultset} = $images; >- > is( $imagenumbers[4], undef, 'imagenumber undef' ); >-- >1.7.2.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 14778
:
42326
|
42388
|
43247
|
43248
|
43249
|
43250
|
43440
|
43631
|
43632
|
43633
|
43634
|
43635
|
43636
|
43637
|
43638
|
43639
|
43640
|
43641
|
43642
|
43643
|
43644
|
43645
|
43834
|
43835
|
43836
|
43837
|
43838
|
43839
|
43840
|
43841
|
43842
|
43843
|
43844
|
43845
|
43846
|
43847
|
43848
|
43849
|
43850
|
43851
|
43852
|
43853
|
43857
|
43858
|
43859
|
43860
|
43861
|
43862
|
43863
|
43864
|
43865
|
43866
| 43867 |
43868
|
43869
|
43870
|
43871
|
43872
|
43873
|
43874
|
43875
|
43876
|
44003