diff --git a/classes/mathcat.php b/classes/mathcat.php index bd2d6ff1c..5cb25d53f 100644 --- a/classes/mathcat.php +++ b/classes/mathcat.php @@ -480,7 +480,7 @@ public static function compose_chain($function1, $function2) { * * @return array - structure of the given array, needed for restoring by vector_to_array */ - public static function array_to_vector(&$data, int &$n = null): array { + public static function array_to_vector(&$data, int &$n = 0): array { // NOTE: The operation will be done directly on $data, so work with a copy! if (is_null($n)) { diff --git a/tests/mathcat_test.php b/tests/mathcat_test.php index ef2c48abb..cfc4a7e10 100644 --- a/tests/mathcat_test.php +++ b/tests/mathcat_test.php @@ -57,10 +57,10 @@ public function test_newton_raphson_multi_stable(): void { } /** - * @dataProvider conversion_of_array_to_vector_provider - * - * @param array - * @return void + * Test if array_to_vector and vector_to_array work as expected + * + * @param array + * @return void */ public function test_conversion_of_array_to_vector($data): void { $array = $data['old']; @@ -135,8 +135,9 @@ public static function conversion_of_array_to_vector_provider(): array { 'karaoke box' => 7, ], ], - 'basement' => 8 + 'basement' => 8, ], + ], 'modified and reordered' => [ 'old' => [0, 'first' => 2, 'second' => [7, 9, 8], 'third' => 5], @@ -145,14 +146,16 @@ public static function conversion_of_array_to_vector_provider(): array { ], // Forbidden cases: strings in array, empty arrays. - 'forbidden because of string' => ['old' => ['test' => 'test', 'legid' => 3], + 'forbidden because of string' => [ + 'old' => ['test' => 'test', 'legid' => 3], 'new' => ['test' => 0.0, 'legid' => 3.0], 'structure' => ['test' => 0, 'legid' => 1], ], - 'forbidden because of empty array' => ['old' => ['test' => []], + 'forbidden because of empty array' => [ + 'old' => ['test' => []], 'new' => ['test' => []], - 'structure' => ['test' => []], + 'structure' => ['test' => []], ], ]; }