3 # Copyright 2015 Koha Development team
6 # This file is part of Koha
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Test
::More tests
=> 4;
30 use t
::lib
::TestBuilder
;
32 my $schema = Koha
::Database
->new->schema;
33 $schema->storage->txn_begin;
36 if (not defined Koha
::Libraries
->find('CPL')) {
37 Koha
::Library
->new({ branchcode
=> 'CPL', branchname
=> 'Centerville' })->store;
40 my $builder = t
::lib
::TestBuilder
->new;
41 my $nb_of_desks = Koha
::Desks
->search->count;
42 my $new_desk_1 = Koha
::Desk
->new({
43 desk_name
=> 'my_desk_name_for_test_1',
46 my $new_desk_2 = Koha
::Desk
->new({
47 desk_name
=> 'my_desk_name_for_test_2',
51 like
( $new_desk_1->desk_id, qr
|^\d
+$|, 'Adding a new desk should have set the desk_id');
52 is
( Koha
::Desks
->search->count, $nb_of_desks + 2, 'The 2 desks should have been added' );
54 my $retrieved_desk_1 = Koha
::Desks
->find( $new_desk_1->desk_id );
55 is
( $retrieved_desk_1->desk_name, $new_desk_1->desk_name, 'Find a desk by id should return the correct desk' );
57 $retrieved_desk_1->delete;
58 is
( Koha
::Desks
->search->count, $nb_of_desks + 1, 'Delete should have deleted the desk' );
60 $schema->storage->txn_rollback;