From: Florent Bruneau Date: Sun, 18 Apr 2010 12:55:04 +0000 (+0200) Subject: A first batch of tests of the UserFilter. X-Git-Tag: xorg/1.0.0~294 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=aaf70eb89d0d410dfec95c2d7b262c3e7a940717;p=platal.git 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 --- 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: +?>