[pLog-svn] r3988 - in plog/branches/lifetype-1.1.1/class:
summary/dao test/tests/summary test/tests/summary/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Mon Sep 18 20:27:02 GMT 2006
Author: oscar
Date: 2006-09-18 20:27:01 +0000 (Mon, 18 Sep 2006)
New Revision: 3988
Added:
plog/branches/lifetype-1.1.1/class/test/tests/summary/dao/
plog/branches/lifetype-1.1.1/class/test/tests/summary/dao/summarystats_test.class.php
Modified:
plog/branches/lifetype-1.1.1/class/summary/dao/summarystats.class.php
Log:
fixed mantis issue 1052 (http://bugs.lifetype.net/view.php?id=1052) -- articles with future time are displyed (but only in the summary!) The fix includes a test case to verify that this functionality works now as expected.
Modified: plog/branches/lifetype-1.1.1/class/summary/dao/summarystats.class.php
===================================================================
--- plog/branches/lifetype-1.1.1/class/summary/dao/summarystats.class.php 2006-09-18 17:04:30 UTC (rev 3987)
+++ plog/branches/lifetype-1.1.1/class/summary/dao/summarystats.class.php 2006-09-18 20:27:01 UTC (rev 3988)
@@ -239,11 +239,6 @@
if($globaArticleCategoryId != ALL_GLOBAL_ARTICLE_CATEGORIES)
$query .= " AND a.global_category_id = '".Db::qstr($globaArticleCategoryId)."'";
- //$query .= " GROUP BY a.id ORDER BY a.date DESC";
- /**
- * :TODO:
- * do we really need the GROUP BY? Why? MySQL does a better job without..
- */
$query .= " ORDER BY a.date DESC";
if( $maxPosts <= 0 )
@@ -345,20 +340,18 @@
return $count;
}
- function getNow() {
+ function getNow()
+ {
include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
$time = new Timestamp();
- $now = $time->getYear().$time->getMonth();
- if( $time->getDay() < 10 )
- $now .= "0";
- $now .= $time->getDay();
- $now .= "235959";
+ $now = $time->getTimestamp();
return $now;
}
- function getStartTime( $duration ) {
+ function getStartTime( $duration )
+ {
include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
$time = new Timestamp();
Added: plog/branches/lifetype-1.1.1/class/test/tests/summary/dao/summarystats_test.class.php
===================================================================
--- plog/branches/lifetype-1.1.1/class/test/tests/summary/dao/summarystats_test.class.php 2006-09-18 17:04:30 UTC (rev 3987)
+++ plog/branches/lifetype-1.1.1/class/test/tests/summary/dao/summarystats_test.class.php 2006-09-18 20:27:01 UTC (rev 3988)
@@ -0,0 +1,131 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/article.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/articlecategory.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/userstatus.class.php" );
+ include_once( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
+
+ /**
+ * Unit test cases for the SummaryStats class
+ */
+ class SummaryStats_Test extends LifeTypeTestCase
+ {
+ /**
+ * dummy blog we'll be using during the tests
+ */
+ var $blog;
+
+ /**
+ * dummy blog owner
+ */
+ var $owner;
+
+ /**
+ * dummy category
+ */
+ var $cat;
+
+ /**
+ * URL pointing to this server's xmlrpc.php
+ */
+
+ function setUp()
+ {
+ // create the blog owner
+ $this->owner = new UserInfo( md5(time()), // name
+ "password", // password
+ "whatever at whatever.com", // email address
+ "", // about
+ "" );
+ $users = new Users();
+ if( !$users->addUser( $this->owner )) {
+ throw( new Exception( "Error adding test user" ));
+ die();
+ }
+
+ // create the test blog
+ $blogs = new Blogs();
+ $this->blog = null;
+ $this->blog = new BlogInfo( "test blog",
+ $this->owner->getId(),
+ "",
+ new BlogSettings());
+ if( !$blogs->addBlog( $this->blog )) {
+ throw( new Exception( "Error adding test blog!" ));
+ die();
+ }
+
+ // add a default category
+ $this->cat = new ArticleCategory( "General",
+ "",
+ $this->blog->getId(),
+ true );
+ $cats = new ArticleCategories();
+ if( !$cats->addArticleCategory( $this->cat )) {
+ throw( new Exception( "Error adding test category!" ));
+ die();
+ }
+ }
+
+ function tearDown()
+ {
+ $users = new Users();
+ $users->deleteUser( $this->owner->getId());
+
+ $blogs = new Blogs();
+ $blogs->deleteBlog( $this->blog->getId());
+
+ $cats = new ArticleCategories();
+ $cats->deleteCategory( $this->cat->getId(), $this->blog->getId());
+ }
+
+ /**
+ * Test case for SummaryStats::getRecentArticles and mantis case 1052
+ * (http://bugs.lifetype.net/view.php?id=1052)
+ */
+ function testGetRecentArticlesIgnoreFuturePosts()
+ {
+ // create a new post first
+ $article = new Article(
+ "topic",
+ "text",
+ Array( $this->cat->getId()),
+ $this->owner->getId(),
+ $this->blog->getId(),
+ POST_STATUS_PUBLISHED,
+ 0
+ );
+ // set the date within 5 minutes
+ //$t = Timestamp::getTimestampWithOffset( new Timestamp(), 2 );
+ $t = new Timestamp();
+ $t->addSeconds( 5 * 60 );
+ $article->setDateObject( $t );
+
+ // save the article and check
+ $articles = new Articles();
+ $this->assertTrue( $articles->addArticle( $article ), "Unable to add a new test article" );
+
+ // load the list of recent posts and check that the one we've just added, which
+ // has a date in the future, isn't there
+ $stats = new SummaryStats();
+ $posts = $stats->getRecentArticles();
+ $i = 0;
+ $found = false;
+ while( $i < count( $posts ) && !$found ) {
+ $found = ($posts[$i]->getId() == $article->getId());
+ $i++;
+ }
+
+ $this->assertFalse( $found, "A post with date in the future was returned by getRecentPosts" );
+
+ $this->assertTrue( $articles->deleteArticle( $article->getId(), $this->owner->getId(), $this->blog->getId()));
+ }
+ }
+?>
\ No newline at end of file
More information about the pLog-svn
mailing list