Bug 20199: Add tests for Koha::Acq::Order->store
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 14 Feb 2018 17:13:15 +0000 (14:13 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 26 Feb 2018 16:24:43 +0000 (13:24 -0300)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Koha/Acquisition/Order.t

index f597453..ed9ebc0 100644 (file)
@@ -19,7 +19,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 1;
+use Test::More tests => 2;
 
 use t::lib::TestBuilder;
 use t::lib::Mocks;
@@ -55,3 +55,43 @@ subtest 'basket() tests' => sub {
 
     $schema->storage->txn_rollback;
 };
+
+subtest 'store' => sub {
+    plan tests => 1;
+
+    $schema->storage->txn_begin;
+    my $o = $builder->build_object(
+        {
+            class => 'Koha::Acquisition::Orders'
+        }
+    );
+
+    subtest 'entrydate' => sub {
+        plan tests => 2;
+
+        my $order;
+
+        t::lib::Mocks::mock_preference( 'TimeFormat', '12hr' );
+        $order = Koha::Acquisition::Order->new(
+            {
+                basketno     => $o->basketno,
+                biblionumber => $o->biblionumber,
+                budget_id    => $o->budget_id,
+            }
+        )->store;
+        $order->discard_changes;
+        like( $order->entrydate, qr|^\d{4}-\d{2}-\d{2}$| );
+
+        t::lib::Mocks::mock_preference( 'TimeFormat', '24hr' );
+        $order = Koha::Acquisition::Order->new(
+            {
+                basketno     => $o->basketno,
+                biblionumber => $o->biblionumber,
+                budget_id    => $o->budget_id,
+            }
+        )->store;
+        $order->discard_changes;
+        like( $order->entrydate, qr|^\d{4}-\d{2}-\d{2}$| );
+    };
+    $schema->storage->txn_rollback;
+};