From 2645315fe3acc8486febbd6421bf8a955eae9c5a Mon Sep 17 00:00:00 2001
From: Tiago Grego <tgrego@ebi.ac.uk>
Date: Mon, 26 Feb 2018 12:56:33 +0000
Subject: [PATCH] Added biotype.t test to check warning in
 fetch_all_by_object_type

---
 modules/t/biotype.t | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/t/biotype.t b/modules/t/biotype.t
index 36f57e5261..4530596551 100644
--- a/modules/t/biotype.t
+++ b/modules/t/biotype.t
@@ -17,7 +17,7 @@ use strict;
 use warnings;
 
 use Test::More;
-use Test::Warnings qw( allow_warnings );
+use Test::Warnings qw( warning );
 use Test::Exception;
 
 use Bio::EnsEMBL::Test::MultiTestDB;
@@ -26,7 +26,6 @@ use Bio::EnsEMBL::Test::TestUtils;
 our $verbose = 0; #set to 1 to turn on debug printouts
 
 
-
 # Get a DBAdaptor to from the test system
 my $multi = Bio::EnsEMBL::Test::MultiTestDB->new;
 ok($multi, "Test DB loaded successfully");
@@ -93,5 +92,13 @@ my $biotypes = $biotype_adaptor->fetch_all_by_object_type('gene');
 is(ref $biotypes, 'ARRAY', 'Got an array');
 is(scalar @{$biotypes}, '2', 'of size 2');
 is_deeply($biotypes, [$biotype1, $biotype3], 'with the correct objects');
+my $warning = warning { $biotypes = $biotype_adaptor->fetch_all_by_object_type('none') };
+like( $warning,
+    qr/No objects retrieved. Check if object_type 'none' is correct./,
+    "Got a warning from fetch_all_by_object_type('none') ",
+) or diag 'Got warning: ', explain($warning);
+is(ref $biotypes, 'ARRAY', 'Got an array');
+is(scalar @{$biotypes}, '0', 'of size 0');
+is_deeply($biotypes, [], 'totally empty');
 
 done_testing();
-- 
GitLab