diff --git a/lib/org/openpsa/expenses/handler/hours/admin.php b/lib/org/openpsa/expenses/handler/hours/admin.php index 6c1186139..e8384f38a 100644 --- a/lib/org/openpsa/expenses/handler/hours/admin.php +++ b/lib/org/openpsa/expenses/handler/hours/admin.php @@ -141,9 +141,10 @@ private function parse_input(ParameterBag $input, string $action) : int|bool if ($action == 'invoiceable') { return $input->getBoolean('value'); } - if ($selection = $input->get('selection')) { + if ($selection = $input->all('selection')) { return (int) array_pop($selection); } + return 0; } } diff --git a/test/org/openpsa/expenses/handler/hours/adminTest.php b/test/org/openpsa/expenses/handler/hours/adminTest.php index 1757ec49e..f5dcd93ab 100644 --- a/test/org/openpsa/expenses/handler/hours/adminTest.php +++ b/test/org/openpsa/expenses/handler/hours/adminTest.php @@ -105,4 +105,22 @@ public function testHandler_hours_create_invoice() midcom::get()->auth->drop_sudo(); } + + public function testHandler_hours_batch() + { + midcom::get()->auth->request_sudo('org.openpsa.expenses'); + + $data = $this->run_handler('org.openpsa.expenses', ['hours', 'task', 'batch']); + $this->assertEquals('hours_task_action', $data['handler_id']); + + $invoice = $this->create_object(\org_openpsa_invoices_invoice_dba::class); + $_POST = [ + 'action' => 'invoice', + 'entries' => [self::$_report->id], + 'selection' => [$invoice->id] + ]; + $this->run_handler('org.openpsa.expenses', ['hours', 'task', 'batch']); + + midcom::get()->auth->drop_sudo(); + } }