Bug 15199: t/db_dependent/Review.t should not depend on existing data
This patch makes the tests create a branch and a patron category instead of searching for them on the DB. To test: - Apply the patch on current master - Run $ prove t/db_dependent/Review.t => SUCCESS: Tests pass - Sign off Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> All test pass successful Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
87f8d7303c
commit
87e7d5555e
1 changed files with 15 additions and 6 deletions
|
@ -17,7 +17,11 @@
|
|||
# with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 117;
|
||||
use t::lib::TestBuilder;
|
||||
|
||||
use Koha::Database;
|
||||
use Time::Piece;
|
||||
|
||||
BEGIN {
|
||||
|
@ -41,16 +45,19 @@ can_ok(
|
|||
deletereview )
|
||||
);
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
$dbh->{AutoCommit} = 0;
|
||||
$dbh->{RaiseError} = 1;
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
our $dbh = C4::Context->dbh;
|
||||
|
||||
$dbh->do('DELETE FROM reviews');
|
||||
$dbh->do('DELETE FROM issues');
|
||||
$dbh->do('DELETE FROM borrowers');
|
||||
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
|
||||
# ---------- Some borrowers for testing -------------------
|
||||
my $categorycode = Koha::Database->new()->schema()->resultset('Category')->first()->categorycode();
|
||||
my $branchcode = Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
|
||||
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
|
||||
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
|
||||
|
||||
my $b1 = Koha::Borrower->new(
|
||||
{ surname => 'Borrower 1',
|
||||
|
@ -383,4 +390,6 @@ ok( !defined($review3), 'Review3 is no longer defined' );
|
|||
$numberOfReviews = numberofreviews($status0) + numberofreviews($status1);
|
||||
is( $numberOfReviews, 0, 'There is no review left in database' );
|
||||
|
||||
$dbh->rollback;
|
||||
$schema->storage->txn_rollback;
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in a new issue