getMessage()); } // 2) JSON string input with duplicates and zero try { $result = department_selfserve_tasks_o::normalizeButtonsInput('[4,5,5,0]'); if ($result === [4,5,0]) { ok('JSON input normalized with duplicates removed'); } else { fail('JSON input normalization mismatch: ' . json_encode($result)); } } catch (\Exception $e) { fail('JSON input threw unexpectedly: ' . $e->getMessage()); } // 3) CSV string input try { $result = department_selfserve_tasks_o::normalizeButtonsInput('6, 7 ,8'); if ($result === [6,7,8]) { ok('CSV input normalized correctly'); } else { fail('CSV input normalization mismatch: ' . json_encode($result)); } } catch (\Exception $e) { fail('CSV input threw unexpectedly: ' . $e->getMessage()); } // 4) Invalid input should throw $thrown = false; try { department_selfserve_tasks_o::normalizeButtonsInput('["a", 2]'); } catch (\Exception $e) { $thrown = true; ok('Invalid input correctly threw exception: ' . $e->getMessage()); } if (!$thrown) { fail('Expected exception for invalid input, but none was thrown'); } echo "\nButtonsNormalizationTest completed.\n"; }