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;
24 use t::lib::TestBuilder;
26 my $builder = t::lib::TestBuilder->new;
27 my $nb_of_cities = Koha::Cities->search->count;
28 my $new_city_1 = Koha::City->new({
29 city_name => 'my_city_name_for_test_1',
30 city_state => 'my_city_state_for_test_1',
31 city_zipcode => 'my_city_zipcode_for_test_1',
32 city_country => 'my_city_country_for_test_1',
34 my $new_city_2 = Koha::City->new({
35 city_name => 'my_city_name_for_test_2',
36 city_state => 'my_city_state_for_test_2',
37 city_zipcode => 'my_city_zipcode_for_test_2',
38 city_country => 'my_city_country_for_test_2',
41 like( $new_city_1->cityid, qr|^\d+$|, 'Adding a new city should have set the cityid');
42 is( Koha::Cities->search->count, $nb_of_cities + 2, 'The 2 cities should have been added' );
44 my $retrieved_city_1 = Koha::Cities->find( $new_city_1->cityid );
45 is( $retrieved_city_1->city_name, $new_city_1->city_name, 'Find a city by id should return the correct city' );
47 $retrieved_city_1->delete;
48 is( Koha::Cities->search->count, $nb_of_cities + 1, 'Delete should have deleted the city' );