[pLog-svn] r4304 - plog/branches/lifetype-1.1.3/class/dao
Jon Daley
plogworld at jon.limedaley.com
Thu Nov 16 12:50:30 GMT 2006
I don't really seem to be getting how to go about testing stuff.
It seems like a simple test would be to check the return type of the
function.
It should always be an "int", right? and not an array of comments?
On Thu, 16 Nov 2006, Oscar Renalias wrote:
> We'll have to verify this with a test case. It can't be that this
> method has been broken for so long, as it's used in a few places
> throughout the code.
>
> On 11/16/06, jondaley at devel.lifetype.net <jondaley at devel.lifetype.net> wrote:
>> Author: jondaley
>> Date: 2006-11-16 03:47:57 +0000 (Thu, 16 Nov 2006)
>> New Revision: 4304
>>
>> Modified:
>> plog/branches/lifetype-1.1.3/class/dao/commentscommon.class.php
>> Log:
>> this can't be doing what it was supposed to be doing, can it? if the
>> status was COMMENT_STATUS_SPAM, getNumComments used to return all of the
>> comment data?!
>>
>> Modified: plog/branches/lifetype-1.1.3/class/dao/commentscommon.class.php
>> ===================================================================
>> --- plog/branches/lifetype-1.1.3/class/dao/commentscommon.class.php
>> 2006-11-16 02:00:54 UTC (rev 4303)
>> +++ plog/branches/lifetype-1.1.3/class/dao/commentscommon.class.php
>> 2006-11-16 03:47:57 UTC (rev 4304)
>> @@ -179,28 +179,39 @@
>> $numComments = 0;
>> $articles = new Articles();
>> $article = $articles->getArticle( $artId );
>> -
>> +
>> + if(!$article)
>> + return 0;
>> +
>> if( $type == COMMENT_TYPE_COMMENT ) {
>> - if( $status == COMMENT_STATUS_ALL &&
>> $article ) {
>> + if( $status == COMMENT_STATUS_ALL ) {
>> $numComments =
>> $article->getTotalComments();
>> }
>> - elseif( $status == COMMENT_STATUS_NONSPAM
>> && $article ) {
>> + elseif( $status == COMMENT_STATUS_NONSPAM )
>> {
>> $numComments =
>> $article->getNumComments();
>> }
>> + elseif( $status == COMMENT_STATUS_SPAM ) {
>> + $numComments =
>> $article->getTotalComments() - $article->getNumComments();
>> + }
>> else {
>> - $numComments =
>> $this->getPostComments( $artId, COMMENT_ORDER_NEWEST_FIRST, $status, $type
>> );
>> +// $numComments =
>> $this->getPostComments( $artId, COMMENT_ORDER_NEWEST_FIRST, $status, $type
>> );
>> + $numComments = 0;
>> }
>> }
>> else {
>> - if( $status == COMMENT_STATUS_ALL &&
>> $article ) {
>> + if( $status == COMMENT_STATUS_ALL ) {
>> $numComments =
>> $article->getTotalTrackBacks();
>> }
>> - elseif( $status == COMMENT_STATUS_NONSPAM
>> && $article ) {
>> + elseif( $status == COMMENT_STATUS_NONSPAM )
>> {
>> $numComments =
>> $article->getNumTrackBacks();
>> }
>> + elseif( $status == COMMENT_STATUS_SPAM ) {
>> + $numComments =
>> $article->getTotalTrackbacks() - $article->getNumTrackbacks();
>> + }
>> else {
>> - $numComments =
>> $this->getPostComments( $artId, COMMENT_ORDER_NEWEST_FIRST, $status, $type
>> );
>> - }
>> +// $numComments =
>> $this->getPostComments( $artId, COMMENT_ORDER_NEWEST_FIRST, $status, $type
>> );
>> + $numComments = 0;
>> + }
>> }
>>
>> return( $numComments );
>>
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://devel.lifetype.net/mailman/listinfo/plog-svn
>>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
>
--
Jon Daley
http://jon.limedaley.com/
Proofreading is more effective after publication.
-- Barker
More information about the pLog-svn
mailing list