Bug 37898: Wrap Patroncards.t inside a transaction
This tests leave data on the DB and need to be fixed. This patch does that. To test: 1. Run: $ ktd --shell k$ echo "SELECT COUNT(*) FROM creator_layouts \G" | koha-mysql kohadev 2. Run: k$ prove t/db_dependent/Patroncards.t => SUCCESS: Tests pass 3. Repeat 1 => FAIL: Numbers don't match the original ones! 4. Apply this patch 5. Repeat 2 and 3 => SUCCESS: Tests still pass! => SUCCESS: Numbers match! 6. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
be0931fdf7
commit
979d1cb2c5
1 changed files with 14 additions and 7 deletions
|
@ -15,20 +15,27 @@
|
||||||
# with Koha; if not, see <http://www.gnu.org/licenses>.
|
# with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||||
|
|
||||||
use Modern::Perl;
|
use Modern::Perl;
|
||||||
|
|
||||||
use Test::More tests => 1;
|
use Test::More tests => 1;
|
||||||
use Test::MockModule;
|
|
||||||
use t::lib::Mocks;
|
|
||||||
use t::lib::TestBuilder;
|
|
||||||
|
|
||||||
use C4::Patroncards::Layout qw( save new );
|
use C4::Patroncards::Layout;
|
||||||
|
use Koha::Database;
|
||||||
|
|
||||||
|
my $schema = Koha::Database->new->schema;
|
||||||
|
|
||||||
|
subtest 'save() tests' => sub {
|
||||||
|
|
||||||
subtest '->save' => sub {
|
|
||||||
plan tests => 1;
|
plan tests => 1;
|
||||||
|
|
||||||
|
$schema->storage->txn_begin;
|
||||||
|
|
||||||
my $layout = C4::Patroncards::Layout->new(
|
my $layout = C4::Patroncards::Layout->new(
|
||||||
layout_name => "new patron card",
|
layout_name => "new patron card",
|
||||||
layout_id => '', # The interface send an empty string
|
layout_id => '', # The interface send an empty string
|
||||||
layout_xml => 'some_xml'
|
layout_xml => 'some_xml'
|
||||||
);
|
);
|
||||||
my $layout_id = $layout->save;
|
my $layout_id = $layout->save;
|
||||||
ok($layout_id > 0, 'A layout_id should have been returned on ->save');
|
ok( $layout_id > 0, 'A layout_id should have been returned on ->save' );
|
||||||
|
|
||||||
|
$schema->storage->txn_rollback;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue