Bug 16500: Catch two warns in TestBuilder.t with warning_like
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 11 May 2016 12:49:07 +0000 (14:49 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 17 Jun 2016 14:42:08 +0000 (14:42 +0000)
When testing a wrong case in TestBuilder.t, two warns show up.
We can catch them with warning_like.

Test plan:
Run t/db_dependent/TestBuilder.t

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
t/db_dependent/TestBuilder.t

index 0baec38..724f32d 100644 (file)
@@ -54,7 +54,9 @@ subtest 'Start with some trivial tests' => sub {
     # return undef if a record exists
     my $param = { source => 'Branch', value => { branchcode => 'MPL' } };
     $builder->build( $param ); # at least it should exist now
-    is( $builder->build( $param ), undef, 'Return undef when exists' );
+    warning_like { $builder->build( $param ) }
+        qr/Violation of unique constraint/,
+        'Catch warn on adding existing record';
 };
 
 
@@ -229,7 +231,9 @@ subtest 'Test build with NULL values' => sub {
 
     # PK should not be null
     my $params = { source => 'Branch', value => { branchcode => undef }};
-    is( $builder->build( $params ), undef, 'PK should not be null' );
+    warning_like { $builder->build( $params ) }
+        qr/Null value for branchcode/,
+        'Catch warn on adding branch with a null branchcode';
     # Nullable column
     my $info = $schema->source( 'Item' )->column_info( 'barcode' );
     $params = { source => 'Item', value  => { barcode => undef }};