Bug 40777: Add tests for empty_title
Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
5da10c0ecf
commit
bc4db881f4
|
|
@ -1,7 +1,7 @@
|
|||
use Modern::Perl;
|
||||
|
||||
#use Test::NoWarnings;
|
||||
use Test::More tests => 5;
|
||||
use Test::NoWarnings;
|
||||
use Test::More tests => 7;
|
||||
use Test::Warn;
|
||||
|
||||
use Koha::Items;
|
||||
|
|
@ -396,3 +396,43 @@ subtest 'nonexistent_AV' => sub {
|
|||
is( scalar(@errors), 1 );
|
||||
};
|
||||
};
|
||||
|
||||
subtest 'empty_title' => sub {
|
||||
|
||||
plan tests => 3;
|
||||
|
||||
$schema->storage->txn_begin();
|
||||
|
||||
my $biblio_ok = $builder->build_sample_biblio;
|
||||
my $item_ok = $builder->build_sample_item( { biblionumber => $biblio_ok->biblionumber } );
|
||||
my $biblio_ko = $builder->build_sample_biblio;
|
||||
my $item_ko = $builder->build_sample_item( { biblionumber => $biblio_ko->biblionumber } );
|
||||
|
||||
my $biblios = Koha::Biblios->search( { biblionumber => [ $biblio_ok->biblionumber, $biblio_ko->biblionumber ] } );
|
||||
|
||||
subtest 'ok' => sub {
|
||||
plan tests => 1;
|
||||
my @errors = Koha::Database::DataInconsistency->empty_title($biblios);
|
||||
is_deeply( \@errors, [] );
|
||||
};
|
||||
|
||||
subtest 'title => undef' => sub {
|
||||
plan tests => 1;
|
||||
$biblio_ko->set( { title => undef } )->store;
|
||||
my @errors = Koha::Database::DataInconsistency->empty_title($biblios);
|
||||
is_deeply(
|
||||
\@errors,
|
||||
[ sprintf 'Biblio with biblionumber=%s does not have title defined', $biblio_ko->biblionumber ]
|
||||
);
|
||||
};
|
||||
|
||||
subtest 'title => ""' => sub {
|
||||
plan tests => 1;
|
||||
$biblio_ko->set( { title => q{} } )->store;
|
||||
my @errors = Koha::Database::DataInconsistency->empty_title($biblios);
|
||||
is_deeply(
|
||||
\@errors,
|
||||
[ sprintf 'Biblio with biblionumber=%s does not have title defined', $biblio_ko->biblionumber ]
|
||||
);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue