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>.
21 use Test::More tests => 4;
25 my $nb_of_cities = Koha::Cities->search->count;
26 my $new_city_1 = Koha::City->new({
27 city_name => 'my_city_name_for_test_1',
28 city_state => 'my_city_state_for_test_1',
29 city_zipcode => 'my_city_zipcode_for_test_1',
30 city_country => 'my_city_country_for_test_1',
32 my $new_city_2 = Koha::City->new({
33 city_name => 'my_city_name_for_test_2',
34 city_state => 'my_city_state_for_test_2',
35 city_zipcode => 'my_city_zipcode_for_test_2',
36 city_country => 'my_city_country_for_test_2',
39 like( $new_city_1->cityid, qr|^\d+$|, 'Adding a new city should have set the cityid');
40 is( Koha::Cities->search->count, $nb_of_cities + 2, 'The 2 cities should have been added' );
42 my $retrieved_city_1 = Koha::Cities->find( $new_city_1->cityid );
43 is( $retrieved_city_1->city_name, $new_city_1->city_name, 'Find a city by id should return the correct city' );
45 $retrieved_city_1->delete;
46 is( Koha::Cities->search->count, $nb_of_cities + 1, 'Delete should have deleted the city' );