Bug 12395: Add unit test to check created_by is correctly set
authorJulian Maurice <julian.maurice@biblibre.com>
Tue, 10 Feb 2015 09:23:25 +0000 (10:23 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 6 Jul 2018 14:01:47 +0000 (14:01 +0000)
Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

t/db_dependent/Acquisition/NewOrder.t

index b327a8d..b17dcec 100644 (file)
@@ -2,7 +2,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 7;
+use Test::More tests => 8;
 use C4::Acquisition;
 use C4::Biblio;
 use C4::Budgets;
@@ -17,6 +17,10 @@ $schema->storage->txn_begin();
 my $dbh = C4::Context->dbh;
 $dbh->{RaiseError} = 1;
 
+C4::Context->_new_userenv('xxx');
+C4::Context->set_userenv(42, 'ordercreator', '0042', 'Order', 'Creator', 'CPL',
+    0, 'ordercreator@example.com');
+
 my $bookseller = Koha::Acquisition::Bookseller->new(
     {
         name => "my vendor",
@@ -86,5 +90,6 @@ my $ordernumber = $order->ordernumber;
 $order = Koha::Acquisition::Orders->find( $ordernumber );
 is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' );
 is( $order->entrydate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' );
+is( $order->created_by, 42, 'Koha::Acquisition::Order->store set created_by to logged in user if not given' );
 
 $schema->storage->txn_rollback();