From aaf70eb89d0d410dfec95c2d7b262c3e7a940717 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 18 Apr 2010 14:55:04 +0200 Subject: [PATCH] A first batch of tests of the UserFilter. Are (partially) tested: * UFC_HasProfile * UFC_Hruid * UFC_Hrpid * HFC_Ip A lot of work remains to: * test *all* the UFC and all the parameters of the UFCs. * test fetch of both UIDs and PIDs * test UFO * test boolean operations on UFCs. Signed-off-by: Florent Bruneau --- classes/userfilter.php | 4 +- core | 2 +- ut/userfiltertest.php | 134 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 ut/userfiltertest.php diff --git a/classes/userfilter.php b/classes/userfilter.php index ad6fc26..4458cca 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -46,7 +46,8 @@ class UFC_HasProfile implements UserFilterCondition { public function buildCondition(PlFilter &$uf) { - return '$PID IS NOT NULL'; + $uf->requireProfiles(); + return 'p.pid IS NOT NULL'; } } // }}} @@ -1810,6 +1811,7 @@ class UserFilter extends PlFilter return $this->getUsers($limit); } + public function getTotalCount() { if (is_null($this->lastcount)) { diff --git a/core b/core index 46ca274..41e571e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 46ca2746b59162c026f67271c5583fa2f20f5c4c +Subproject commit 41e571e3c1546e3288eb386bdd1f2863bcbb95be diff --git a/ut/userfiltertest.php b/ut/userfiltertest.php new file mode 100644 index 0000000..1a97504 --- /dev/null +++ b/ut/userfiltertest.php @@ -0,0 +1,134 @@ +numRows(); + if (!is_null($expcount)) { + if ($expcount < 0) { + $this->assertNotEquals(0, $count); + } else { + $this->assertEquals($expcount, $count); + } + } + $ids = $query->fetchColumn(); + $this->assertEquals($count, count($ids)); + sort($ids); + + $uf = new UserFilter($cond); + /* XXX: API issue, there's no guarantee getTotalCount() + returns the number of users. + */ + //$this->assertEquals($count, $uf->getTotalCount()); + $got = $uf->getUIDs(); + $this->assertEquals($count, count($got)); + sort($got); + $this->assertEquals($ids, $got); + + $uf = new UserFilter($cond); + $got = $uf->getUIDs(); + $this->assertEquals($count, count($got)); + sort($got); + $this->assertEquals($ids, $got); + $this->assertEquals($count, $uf->getTotalCount()); + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> -- 2.1.4