Bugzilla – Attachment 59501 Details for
Bug 17932
Koha::Object should provide a TO_JSON method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17932: (followup) Tidy tests
Bug-17932-followup-Tidy-tests.patch (text/plain), 4.52 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-01-24 13:52:44 UTC
(
hide
)
Description:
Bug 17932: (followup) Tidy tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-01-24 13:52:44 UTC
Size:
4.52 KB
patch
obsolete
>From 0231aeb9261049d8b5f3b941cceb648f6ebfb857 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 24 Jan 2017 10:48:31 -0300 >Subject: [PATCH] Bug 17932: (followup) Tidy tests > >This patch makes the tests create its own data instead of searching the >DB for a branchcode and a categorycode. It does so on each subtest, >because there shouldn't be side effects between subtests. > >I also wrapped each subtest inside a transaction, for the same reason. > >To test: >- Apply this patch >- Run: > $ prove t/db_dependent/Koha/Object.t >=> SUCCESS: Tests return green with this patch >- Sign off :-D >--- > t/db_dependent/Koha/Object.t | 49 +++++++++++++++++++++++++++++++++++++------- > 1 file changed, 42 insertions(+), 7 deletions(-) > >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index fd5d89b0a3..d812d37a19 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/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; > }; > > >-- >2.11.0
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 17932
:
59431
|
59432
|
59498
|
59499
|
59500
|
59501
|
59696
|
59697
|
59698
|
59699
|
60072
|
60073
|
60074
|
60075