Bug 30571: Z3950Servers.t - Create subtest for existing tests
No real changes, just moving code and indentation. Ground work for following patch. Test plan: To let the test pass, disable strict_mode in koha-conf. Run perl t/db_dependent/Koha/Z3950Servers.t. Should pass now. However, in strict mode or with prove, it should fail. Run prove t/db_dependent/Koha/Z3950Servers.t. Failed? Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> 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
31293d711e
commit
c24a67a28d
1 changed files with 33 additions and 32 deletions
|
@ -18,44 +18,45 @@
|
|||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 4;
|
||||
|
||||
use Koha::Z3950Server;
|
||||
use Koha::Z3950Servers;
|
||||
use Koha::Database;
|
||||
use Test::More tests => 1;
|
||||
|
||||
use t::lib::TestBuilder;
|
||||
use Koha::Database;
|
||||
use Koha::Z3950Server;
|
||||
use Koha::Z3950Servers;
|
||||
|
||||
my $schema = Koha::Database->new->schema;
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
my $nb_of_z39s = Koha::Z3950Servers->search->count;
|
||||
my $new_z39_1 = Koha::Z3950Server->new({
|
||||
host => 'my_host1.org',
|
||||
port => '32',
|
||||
db => 'db1',
|
||||
servername => 'my_test_1',
|
||||
servertype => 'zed',
|
||||
recordtype => 'biblio',
|
||||
})->store;
|
||||
my $new_z39_2 = Koha::Z3950Server->new({
|
||||
host => 'my_host2.org',
|
||||
port => '64',
|
||||
db => 'db2',
|
||||
servername => 'my_test_2',
|
||||
servertype => 'zed',
|
||||
recordtype => 'authority',
|
||||
})->store;
|
||||
|
||||
like( $new_z39_1->id, qr|^\d+$|, 'Adding a new z39 server should have set the id');
|
||||
is( Koha::Z3950Servers->search->count, $nb_of_z39s + 2, 'The 2 z39 servers should have been added' );
|
||||
subtest 'new, find and delete tests' => sub {
|
||||
plan tests => 4;
|
||||
$schema->storage->txn_begin;
|
||||
my $nb_of_z39s = Koha::Z3950Servers->search->count;
|
||||
my $new_z39_1 = Koha::Z3950Server->new({
|
||||
host => 'my_host1.org',
|
||||
port => '32',
|
||||
db => 'db1',
|
||||
servername => 'my_test_1',
|
||||
servertype => 'zed',
|
||||
recordtype => 'biblio',
|
||||
})->store;
|
||||
my $new_z39_2 = Koha::Z3950Server->new({
|
||||
host => 'my_host2.org',
|
||||
port => '64',
|
||||
db => 'db2',
|
||||
servername => 'my_test_2',
|
||||
servertype => 'zed',
|
||||
recordtype => 'authority',
|
||||
})->store;
|
||||
|
||||
my $retrieved_z39_1 = Koha::Z3950Servers->find( $new_z39_1->id );
|
||||
is( $retrieved_z39_1->servername, $new_z39_1->servername, 'Find a z39 server by id should return the correct z39 server' );
|
||||
like( $new_z39_1->id, qr|^\d+$|, 'Adding a new z39 server should have set the id');
|
||||
is( Koha::Z3950Servers->search->count, $nb_of_z39s + 2, 'The 2 z39 servers should have been added' );
|
||||
|
||||
$retrieved_z39_1->delete;
|
||||
is( Koha::Z3950Servers->search->count, $nb_of_z39s + 1, 'Delete should have deleted the z39 server' );
|
||||
my $retrieved_z39_1 = Koha::Z3950Servers->find( $new_z39_1->id );
|
||||
is( $retrieved_z39_1->servername, $new_z39_1->servername, 'Find a z39 server by id should return the correct z39 server' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
$retrieved_z39_1->delete;
|
||||
is( Koha::Z3950Servers->search->count, $nb_of_z39s + 1, 'Delete should have deleted the z39 server' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue