Bug 19382: Adjust comment in test
[koha.git] / t / db_dependent / Koha / Cities.t
blobacf44b3a04b92c2f9e8120ddec3a4ab2d095a9fc
1 #!/usr/bin/perl
3 # Copyright 2015 Koha Development team
5 # This file is part of Koha
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Modern::Perl;
22 use Test::More tests => 4;
24 use Koha::City;
25 use Koha::Cities;
26 use Koha::Database;
28 use t::lib::TestBuilder;
30 my $schema = Koha::Database->new->schema;
31 $schema->storage->txn_begin;
33 my $builder = t::lib::TestBuilder->new;
34 my $nb_of_cities = Koha::Cities->search->count;
35 my $new_city_1 = Koha::City->new({
36 city_name => 'my_city_name_for_test_1',
37 city_state => 'my_city_state_for_test_1',
38 city_zipcode => 'my_zipcode_4_test_1',
39 city_country => 'my_city_country_for_test_1',
40 })->store;
41 my $new_city_2 = Koha::City->new({
42 city_name => 'my_city_name_for_test_2',
43 city_state => 'my_city_state_for_test_2',
44 city_zipcode => 'my_zipcode_4_test_2',
45 city_country => 'my_city_country_for_test_2',
46 })->store;
48 like( $new_city_1->cityid, qr|^\d+$|, 'Adding a new city should have set the cityid');
49 is( Koha::Cities->search->count, $nb_of_cities + 2, 'The 2 cities should have been added' );
51 my $retrieved_city_1 = Koha::Cities->find( $new_city_1->cityid );
52 is( $retrieved_city_1->city_name, $new_city_1->city_name, 'Find a city by id should return the correct city' );
54 $retrieved_city_1->delete;
55 is( Koha::Cities->search->count, $nb_of_cities + 1, 'Delete should have deleted the city' );
57 $schema->storage->txn_rollback;