@@ -, +, @@ - Apply this patch - Run: $ prove t/db_dependent/Koha/Object.t - Sign off :-D --- t/db_dependent/Koha/Object.t | 49 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) --- a/t/db_dependent/Koha/Object.t +++ a/t/db_dependent/Koha/Object.t @@ -33,16 +33,17 @@ BEGIN { use_ok('Koha::Patron'); } -my $schema = Koha::Database->new->schema; -$schema->storage->txn_begin; - +my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new(); -my $categorycode = $schema->resultset('Category')->first()->categorycode(); -my $branchcode = $schema->resultset('Branch')->first()->branchcode(); - subtest 'is_changed' => sub { plan tests => 6; + + $schema->storage->txn_begin; + + my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; + my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; + my $object = Koha::Patron->new(); $object->categorycode( $categorycode ); $object->branchcode( $branchcode ); @@ -61,10 +62,18 @@ subtest 'is_changed' => sub { is( $object->is_changed(), 1, "Object is changed after Set" ); $object->store(); is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" ); + + $schema->storage->txn_rollback; }; subtest 'in_storage' => sub { plan tests => 6; + + $schema->storage->txn_begin; + + my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; + my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; + my $object = Koha::Patron->new(); is( $object->in_storage, 0, "Object is not in storage" ); $object->categorycode( $categorycode ); @@ -83,23 +92,43 @@ subtest 'in_storage' => sub { $patron = $schema->resultset('Borrower')->find( $borrowernumber ); ok( ! $patron, "Object no longer found in database" ); is( $object->in_storage, 0, "Object is not in storage" ); + + $schema->storage->txn_rollback; }; subtest 'id' => sub { plan tests => 1; + + $schema->storage->txn_begin; + + my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; + my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; + my $patron = Koha::Patron->new({categorycode => $categorycode, branchcode => $branchcode })->store; is( $patron->id, $patron->borrowernumber ); + + $schema->storage->txn_rollback; }; subtest 'get_column' => sub { plan tests => 1; + + $schema->storage->txn_begin; + + my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; + my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; + my $patron = Koha::Patron->new({categorycode => $categorycode, branchcode => $branchcode })->store; is( $patron->get_column('borrowernumber'), $patron->borrowernumber, 'get_column should retrieve the correct value' ); + + $schema->storage->txn_rollback; }; subtest 'discard_changes' => sub { plan tests => 1; - my $builder = t::lib::TestBuilder->new; + + $schema->storage->txn_begin; + my $patron = $builder->build( { source => 'Borrower' } ); $patron = Koha::Patrons->find( $patron->{borrowernumber} ); $patron->dateexpiry(dt_from_string); @@ -109,12 +138,16 @@ subtest 'discard_changes' => sub { dt_from_string->truncate( to => 'day' ), 'discard_changes should refresh the object' ); + + $schema->storage->txn_rollback; }; subtest 'TO_JSON tests' => sub { plan tests => 5; + $schema->storage->txn_begin; + my $borrowernumber = $builder->build( { source => 'Borrower', value => { lost => 1, @@ -131,6 +164,8 @@ subtest 'TO_JSON tests' => sub { is( $gonenoaddress, 0, 'Boolean attribute value is correct (false)' ); ok( !isvstring($patron->borrowernumber), 'Integer values are not coded as strings' ); + + $schema->storage->txn_rollback; }; --