|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# Copyright 2015 Koha Development team |
| 4 |
# |
| 5 |
# This file is part of Koha |
| 6 |
# |
| 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. |
| 11 |
# |
| 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. |
| 16 |
# |
| 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>. |
| 19 |
|
| 20 |
use Modern::Perl; |
| 21 |
use Test::More tests => 4; |
| 22 |
use Koha::City; |
| 23 |
use Koha::Cities; |
| 24 |
use t::lib::TestBuilder; |
| 25 |
|
| 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', |
| 33 |
})->store; |
| 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', |
| 39 |
})->store; |
| 40 |
|
| 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' ); |
| 43 |
|
| 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' ); |
| 46 |
|
| 47 |
$retrieved_city_1->delete; |
| 48 |
is( Koha::Cities->search->count, $nb_of_cities + 1, 'Delete should have deleted the city' ); |