Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 1; |
23 |
|
23 |
|
24 |
use Koha::MarcSubfieldStructure; |
24 |
use Koha::MarcSubfieldStructure; |
25 |
use Koha::MarcSubfieldStructures; |
25 |
use Koha::MarcSubfieldStructures; |
Lines 30-56
use t::lib::TestBuilder;
Link Here
|
30 |
my $schema = Koha::Database->new->schema; |
30 |
my $schema = Koha::Database->new->schema; |
31 |
$schema->storage->txn_begin; |
31 |
$schema->storage->txn_begin; |
32 |
|
32 |
|
33 |
my $builder = t::lib::TestBuilder->new; |
33 |
subtest 'Trivial tests' => sub { |
34 |
my $nb_of_fields = Koha::MarcSubfieldStructures->search->count; |
34 |
plan tests => 3; |
35 |
my $framework = $builder->build({ source => 'BiblioFramework' }); |
|
|
36 |
my $new_field_1 = Koha::MarcSubfieldStructure->new({ |
37 |
frameworkcode => $framework->{frameworkcode}, |
38 |
tagfield => 200, |
39 |
tagsubfield => 'a', |
40 |
})->store; |
41 |
my $new_field_2 = Koha::MarcSubfieldStructure->new({ |
42 |
frameworkcode => $framework->{frameworkcode}, |
43 |
tagfield => 245, |
44 |
tagsubfield => 'a', |
45 |
})->store; |
46 |
|
35 |
|
47 |
is( Koha::MarcSubfieldStructures->search->count, $nb_of_fields + 2, 'The 2 fields should have been added' ); |
36 |
my $builder = t::lib::TestBuilder->new; |
|
|
37 |
my $nb_of_fields = Koha::MarcSubfieldStructures->search->count; |
38 |
my $framework = $builder->build({ source => 'BiblioFramework' }); |
39 |
my $new_field_1 = Koha::MarcSubfieldStructure->new({ |
40 |
frameworkcode => $framework->{frameworkcode}, |
41 |
tagfield => 200, |
42 |
tagsubfield => 'a', |
43 |
})->store; |
44 |
my $new_field_2 = Koha::MarcSubfieldStructure->new({ |
45 |
frameworkcode => $framework->{frameworkcode}, |
46 |
tagfield => 245, |
47 |
tagsubfield => 'a', |
48 |
})->store; |
48 |
|
49 |
|
49 |
my $retrieved_fields = Koha::MarcSubfieldStructures->search({ frameworkcode => $framework->{frameworkcode}, tagfield => 200, tagsubfield => 'a' }); |
50 |
is( Koha::MarcSubfieldStructures->search->count, $nb_of_fields + 2, 'The 2 fields should have been added' ); |
50 |
is( $retrieved_fields->count, 1, 'Search for a field by frameworkcode, tagfield and tagsubfield should return the field' ); |
|
|
51 |
|
51 |
|
52 |
$retrieved_fields->next->delete; |
52 |
my $retrieved_fields = Koha::MarcSubfieldStructures->search({ frameworkcode => $framework->{frameworkcode}, tagfield => 200, tagsubfield => 'a' }); |
53 |
is( Koha::MarcSubfieldStructures->search->count, $nb_of_fields + 1, 'Delete should have deleted the field' ); |
53 |
is( $retrieved_fields->count, 1, 'Search for a field by frameworkcode, tagfield and tagsubfield should return the field' ); |
54 |
|
54 |
|
55 |
$schema->storage->txn_rollback; |
55 |
$retrieved_fields->next->delete; |
|
|
56 |
is( Koha::MarcSubfieldStructures->search->count, $nb_of_fields + 1, 'Delete should have deleted the field' ); |
57 |
}; |
56 |
|
58 |
|
57 |
- |
59 |
$schema->storage->txn_rollback; |