diff --git a/module/search/test/lib/tao.class.php b/module/search/test/lib/tao.class.php index 180e59159f..4a4123653b 100644 --- a/module/search/test/lib/tao.class.php +++ b/module/search/test/lib/tao.class.php @@ -206,4 +206,20 @@ class searchTaoTest extends baseTest if(dao::isError()) return dao::getError(); return $result; } + + /** + * Test checkTodoPriv method. + * + * @param array $results + * @param array $objectIdList + * @param string $table + * @access public + * @return array + */ + public function checkTodoPrivTest(array $results, array $objectIdList, string $table): array + { + $result = $this->invokeArgs('checkTodoPriv', [$results, $objectIdList, $table]); + if(dao::isError()) return dao::getError(); + return $result; + } } diff --git a/module/search/test/tao/checktodopriv.php b/module/search/test/tao/checktodopriv.php new file mode 100755 index 0000000000..8575d7d0a1 --- /dev/null +++ b/module/search/test/tao/checktodopriv.php @@ -0,0 +1,52 @@ +#!/usr/bin/env php +id->range('1-10'); +$todo->account->range('admin,user1,user2,admin,user1,user2,admin,user1,user2,admin'); +$todo->name->range('Todo 1,Todo 2,Todo 3,Todo 4,Todo 5,Todo 6,Todo 7,Todo 8,Todo 9,Todo 10'); +$todo->private->range('0,1,1,0,1,0,1,0,1,1'); +$todo->status->range('wait{5},doing{3},done{2}'); +$todo->gen(10); + +su('admin'); + +$searchTest = new searchTaoTest(); + +$results1 = array(1 => (object)array('id' => 1, 'objectType' => 'todo', 'objectID' => 1)); +$objectIdList1 = array(1 => 1); + +$results2 = array(1 => (object)array('id' => 1, 'objectType' => 'todo', 'objectID' => 2)); +$objectIdList2 = array(2 => 1); + +$results3 = array(1 => (object)array('id' => 1, 'objectType' => 'todo', 'objectID' => 7)); +$objectIdList3 = array(7 => 1); + +$results4 = array(1 => (object)array('id' => 1, 'objectType' => 'todo', 'objectID' => 1), 2 => (object)array('id' => 2, 'objectType' => 'todo', 'objectID' => 4)); +$objectIdList4 = array(1 => 1, 4 => 2); + +$results5 = array(1 => (object)array('id' => 1, 'objectType' => 'todo', 'objectID' => 1), 2 => (object)array('id' => 2, 'objectType' => 'todo', 'objectID' => 4), 3 => (object)array('id' => 3, 'objectType' => 'todo', 'objectID' => 7)); +$objectIdList5 = array(1 => 1, 4 => 2, 7 => 3); + +r(count($searchTest->checkTodoPrivTest($results1, $objectIdList1, TABLE_TODO))) && p() && e('1'); +r(count($searchTest->checkTodoPrivTest($results2, $objectIdList2, TABLE_TODO))) && p() && e('0'); +r(count($searchTest->checkTodoPrivTest($results3, $objectIdList3, TABLE_TODO))) && p() && e('1'); +r(count($searchTest->checkTodoPrivTest($results4, $objectIdList4, TABLE_TODO))) && p() && e('2'); +r(count($searchTest->checkTodoPrivTest($results5, $objectIdList5, TABLE_TODO))) && p() && e('3'); \ No newline at end of file