Bug 28744: Regression tests
This patch adds tests for the following cases: - to_api_mapping not defined - to_api_mapping returning an empty hashref To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => FAIL: Tests fail :-( Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> JD amended patch: remove uneeded commented lines Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
9a69c02545
commit
bcc586ef93
1 changed files with 23 additions and 1 deletions
|
@ -390,7 +390,7 @@ subtest "to_api_mapping() tests" => sub {
|
|||
|
||||
subtest "from_api_mapping() tests" => sub {
|
||||
|
||||
plan tests => 3;
|
||||
plan tests => 5;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
@ -449,6 +449,28 @@ subtest "from_api_mapping() tests" => sub {
|
|||
'Fresh mapping loaded'
|
||||
);
|
||||
|
||||
$city_class->unmock( 'to_api_mapping');
|
||||
$city_class->mock( 'to_api_mapping', undef );
|
||||
|
||||
# Get a fresh object
|
||||
$city = $builder->build_object({ class => 'Koha::Cities' });
|
||||
is_deeply(
|
||||
$city->from_api_mapping,
|
||||
{},
|
||||
'No to_api_mapping then empty hashref'
|
||||
);
|
||||
|
||||
$city_class->unmock( 'to_api_mapping');
|
||||
$city_class->mock( 'to_api_mapping', sub { return; } );
|
||||
|
||||
# Get a fresh object
|
||||
$city = $builder->build_object({ class => 'Koha::Cities' });
|
||||
is_deeply(
|
||||
$city->from_api_mapping,
|
||||
{},
|
||||
'Empty to_api_mapping then empty hashref'
|
||||
);
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue