[pLog-svn] r6669 - plog/branches/lifetype-1.2/class/test/tests/dao
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Mon Jun 23 17:16:01 EDT 2008
Author: jondaley
Date: 2008-06-23 17:16:01 -0400 (Mon, 23 Jun 2008)
New Revision: 6669
Modified:
plog/branches/lifetype-1.2/class/test/tests/dao/articlecategories_test.class.php
Log:
cleanup test data when finished
Modified: plog/branches/lifetype-1.2/class/test/tests/dao/articlecategories_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/dao/articlecategories_test.class.php 2008-06-23 20:57:35 UTC (rev 6668)
+++ plog/branches/lifetype-1.2/class/test/tests/dao/articlecategories_test.class.php 2008-06-23 21:16:01 UTC (rev 6669)
@@ -12,43 +12,49 @@
*/
class ArticleCategories_Test extends LifeTypeTestCase
{
-
+ function setUp(){
+ // create the test data
+ $this->data = TestTools::createBlogScenario(
+ Array( "num_articles" => 5, "num_categories" => 3 ));
+
+ }
+
+ function tearDown(){
+ // delete the test data
+ //TestTools::deleteDaoTestData( $data["categories"] );
+ //TestTools::deleteDaoTestData( $data["articles"] );
+ TestTools::deleteDaoTestData( Array( $this->data["blog"], $this->data["user"] ));
+ }
+
/**
* Regression test for Mantis case http://bugs.lifetype.net/view.php?id=1100 -- category
* counters getting out of sync.
*/
function testArticleCategoriesCounters()
{
- // create the test data
- $data = TestTools::createBlogScenario( Array( "num_articles" => 5, "num_categories" => 3 ));
-
// add an article to one of the categories
- $article = TestTools::createArticle( $data["blog"]->getId(), $data["user"]->getId(), Array( $data["categories"][0]->getId()), POST_STATUS_DRAFT );
+ $article = TestTools::createArticle( $this->data["blog"]->getId(), $this->data["user"]->getId(), Array( $this->data["categories"][0]->getId()), POST_STATUS_DRAFT );
$this->assertTrue( $article, "Error creating test article!" );
// check that the counter has been updated
$articleCategories = new ArticleCategories();
- $updatedCat = $articleCategories->getCategory( $data["categories"][0]->getId());
- $this->assertTrue( $updatedCat->getNumArticles( POST_STATUS_ALL ) == ($data["categories"][0]->getNumArticles() + 1 ), "Article category counters are not valid!" );
+ $updatedCat = $articleCategories->getCategory( $this->data["categories"][0]->getId());
+ $this->assertTrue( $updatedCat->getNumArticles( POST_STATUS_ALL ) == ($this->data["categories"][0]->getNumArticles() + 1 ), "Article category counters are not valid!" );
// now let's mess up the database a little
$db =& Db::getDb();
$db->Execute( "UPDATE ".Db::getPrefix().
"articles_categories SET num_published_articles = 234234, num_articles = 2342 ".
- "WHERE id = ".$data["categories"][1]->getId());
+ "WHERE id = ".$this->data["categories"][1]->getId());
// trigger a cache reset
- $articleCategories->_cache->removeData( $data["categories"][1]->getId(), CACHE_ARTICLE_CATEGORIES );
+ $articleCategories->_cache->removeData( $this->data["categories"][1]->getId(), CACHE_ARTICLE_CATEGORIES );
// update the category, relaod it and check that the counters are correct again
- $tmp = $data["categories"][1];
+ $tmp = $this->data["categories"][1];
$articleCategories->updateCategory( $tmp );
- $updatedCat2 = $articleCategories->getCategory( $data["categories"][1]->getId());
- $this->assertTrue( $updatedCat2->getNumArticles( POST_STATUS_ALL ) == $data["categories"][1]->getNumArticles( POST_STATUS_ALL ), "Article category counters do not match!" );
- $this->assertTrue( $updatedCat2->getNumPublishedArticles() == $data["categories"][1]->getNumPublishedArticles(), "Article category counters do not match!" );
+ $updatedCat2 = $articleCategories->getCategory( $this->data["categories"][1]->getId());
+ $this->assertTrue( $updatedCat2->getNumArticles( POST_STATUS_ALL ) == $this->data["categories"][1]->getNumArticles( POST_STATUS_ALL ), "Article category counters do not match!" );
+ $this->assertTrue( $updatedCat2->getNumPublishedArticles() == $this->data["categories"][1]->getNumPublishedArticles(), "Article category counters do not match!" );
- // delete the test data
- //TestTools::deleteDaoTestData( Array( $data["blog"], $data["user"] ));
- //TestTools::deleteDaoTestData( $data["categories"] );
- //TestTools::deleteDaoTestData( $data["articles"] );
}
}
?>
\ No newline at end of file
More information about the pLog-svn
mailing list