diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-24 10:05:45 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-24 10:05:45 -0400 |
commit | 700b4e8f0265e4eabd7a7c0eb6a06088d50554fe (patch) | |
tree | e38c011894e6f53b59557ad9a86fed8ad6bf6049 /tests/units/FunctionTest.php | |
parent | 9e278a9370e3b651a4a545c0c0c0c256088ed187 (diff) |
Associate tags to tasks in BoardFormatter
Diffstat (limited to 'tests/units/FunctionTest.php')
-rw-r--r-- | tests/units/FunctionTest.php | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/tests/units/FunctionTest.php b/tests/units/FunctionTest.php index 72895845..1c5f971d 100644 --- a/tests/units/FunctionTest.php +++ b/tests/units/FunctionTest.php @@ -18,4 +18,106 @@ class FunctionTest extends Base $this->assertSame(579.7, array_column_sum($input, 'my_column')); } + + public function testArrayColumnIndex() + { + $input = array( + array( + 'k1' => 11, + 'k2' => 22, + ), + array( + 'k1' => 11, + 'k2' => 55, + ), + array( + 'k1' => 33, + 'k2' => 44, + ), + array() + ); + + $expected = array( + 11 => array( + array( + 'k1' => 11, + 'k2' => 22, + ), + array( + 'k1' => 11, + 'k2' => 55, + ) + ), + 33 => array( + array( + 'k1' => 33, + 'k2' => 44, + ) + ) + ); + + $this->assertSame($expected, array_column_index($input, 'k1')); + } + + public function testArrayMergeRelation() + { + $relations = array( + 88 => array( + 'id' => 123, + 'value' => 'test1', + ), + 99 => array( + 'id' => 456, + 'value' => 'test2', + ), + 55 => array() + ); + + $input = array( + array(), + array( + 'task_id' => 88, + 'title' => 'task1' + ), + array( + 'task_id' => 99, + 'title' => 'task2' + ), + array( + 'task_id' => 11, + 'title' => 'task3' + ) + ); + + $expected = array( + array( + 'my_relation' => array(), + ), + array( + 'task_id' => 88, + 'title' => 'task1', + 'my_relation' => array( + 'id' => 123, + 'value' => 'test1', + ), + ), + array( + 'task_id' => 99, + 'title' => 'task2', + 'my_relation' => array( + 'id' => 456, + 'value' => 'test2', + ), + ), + array( + 'task_id' => 11, + 'title' => 'task3', + 'my_relation' => array(), + ) + ); + + array_merge_relation($input, $relations, 'my_relation', 'task_id'); + + $this->assertSame($expected, $input); + } } |