|
Lines 1-63
Link Here
|
| 1 |
#!/usr/bin/perl |
|
|
| 2 |
|
| 3 |
use Modern::Perl; |
| 4 |
|
| 5 |
use C4::Context; |
| 6 |
use Koha::Database; |
| 7 |
use t::lib::TestBuilder; |
| 8 |
|
| 9 |
use Test::More tests => 2; |
| 10 |
|
| 11 |
my $schema = Koha::Database->new->schema; |
| 12 |
$schema->storage->txn_begin; |
| 13 |
my $dbh = C4::Context->dbh; |
| 14 |
my $builder = t::lib::TestBuilder->new; |
| 15 |
|
| 16 |
use_ok('Koha::Patron::Restriction::Types'); |
| 17 |
|
| 18 |
$dbh->do(q|DELETE FROM borrower_debarments|); |
| 19 |
$dbh->do(q|DELETE FROM restriction_types|); |
| 20 |
|
| 21 |
$builder->build( |
| 22 |
{ |
| 23 |
source => 'RestrictionType', |
| 24 |
value => { |
| 25 |
code => 'ONE', |
| 26 |
display_text => 'One', |
| 27 |
is_system => 1, |
| 28 |
is_default => 0 |
| 29 |
} |
| 30 |
} |
| 31 |
); |
| 32 |
$builder->build( |
| 33 |
{ |
| 34 |
source => 'RestrictionType', |
| 35 |
value => { |
| 36 |
code => 'TWO', |
| 37 |
display_text => 'Two', |
| 38 |
is_system => 1, |
| 39 |
is_default => 1 |
| 40 |
} |
| 41 |
} |
| 42 |
); |
| 43 |
|
| 44 |
# keyed_on_code |
| 45 |
my $keyed = Koha::Patron::Restriction::Types->keyed_on_code; |
| 46 |
my $expecting = { |
| 47 |
ONE => { |
| 48 |
code => 'ONE', |
| 49 |
display_text => 'One', |
| 50 |
is_system => 1, |
| 51 |
is_default => 0 |
| 52 |
}, |
| 53 |
TWO => { |
| 54 |
code => 'TWO', |
| 55 |
display_text => 'Two', |
| 56 |
is_system => 1, |
| 57 |
is_default => 1 |
| 58 |
} |
| 59 |
}; |
| 60 |
|
| 61 |
is_deeply( $keyed, $expecting, 'keyed_on_code returns correctly' ); |
| 62 |
|
| 63 |
$schema->storage->txn_rollback; |
| 64 |
- |