[pLog-svn] r4050 - in plugins/branches/lifetype-1.1: . technorati
technorati/class technorati/class/action
technorati/class/tests unported
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Tue Sep 26 18:19:30 GMT 2006
Author: pwestbro
Date: 2006-09-26 18:19:29 +0000 (Tue, 26 Sep 2006)
New Revision: 4050
Added:
plugins/branches/lifetype-1.1/technorati/
plugins/branches/lifetype-1.1/technorati/class/tests/
plugins/branches/lifetype-1.1/technorati/class/tests/plugintechnorati_test.class.php
Removed:
plugins/branches/lifetype-1.1/unported/technorati/
Modified:
plugins/branches/lifetype-1.1/technorati/class/action/admintechnoratipluginupdatesettingsaction.class.php
plugins/branches/lifetype-1.1/technorati/plugintechnorati.class.php
Log:
Fixed the problems that were preventing the technorati plugin from working
with LifeType 1.1, and created some test cases
Copied: plugins/branches/lifetype-1.1/technorati (from rev 4041, plugins/branches/lifetype-1.1/unported/technorati)
Modified: plugins/branches/lifetype-1.1/technorati/class/action/admintechnoratipluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.1/unported/technorati/class/action/admintechnoratipluginupdatesettingsaction.class.php 2006-09-24 22:16:14 UTC (rev 4041)
+++ plugins/branches/lifetype-1.1/technorati/class/action/admintechnoratipluginupdatesettingsaction.class.php 2006-09-26 18:19:29 UTC (rev 4050)
@@ -91,7 +91,7 @@
$blogs = new Blogs();
// update the settings in the db, and make sure that everything went fine
- if( !$blogs->updateBlogs( $this->_blogInfo )) {
+ if( !$blogs->updateBlog( $this->_blogInfo )) {
$this->_view = new AdminTechnoratiPluginSettingsView( $this->_blogInfo );
$this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
$this->setCommonData();
Added: plugins/branches/lifetype-1.1/technorati/class/tests/plugintechnorati_test.class.php
===================================================================
--- plugins/branches/lifetype-1.1/unported/technorati/class/tests/plugintechnorati_test.class.php 2006-09-24 22:16:14 UTC (rev 4041)
+++ plugins/branches/lifetype-1.1/technorati/class/tests/plugintechnorati_test.class.php 2006-09-26 18:19:29 UTC (rev 4050)
@@ -0,0 +1,196 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
+ include_once( PLOG_CLASS_PATH."class/config/config.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/net/xmlrpc/IXR_Library.lib.php" );
+ include_once( PLOG_CLASS_PATH."class/net/url.class.php" );
+ include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/customfields/customfield.class.php" );
+
+ /**
+ * Unit test cases for the technorati plugin
+ */
+ class PluginTechnorati_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();
+ }
+
+ // load a UTF-8 locale
+ $zhLocale =& Locales::getLocale( "zh_CN" );
+
+ // create the test blog
+ $blogs = new Blogs();
+ $this->blog = null;
+ $this->blog = new BlogInfo( "test blog",
+ $this->owner->getId(),
+ "",
+ new BlogSettings());
+ $this->blog->setLocale( $zhLocale );
+ if( !$blogs->addBlog( $this->blog )) {
+ throw( new Exception( "Error adding test blog!" ));
+ die();
+ }
+
+ // add a default category
+ $this->cat = new ArticleCategory( "General",
+ "Description for category General",
+ $this->blog->getId(),
+ true );
+ $cats = new ArticleCategories();
+ if( !$cats->addArticleCategory( $this->cat )) {
+ throw( new Exception( "Error adding test category!" ));
+ die();
+ }
+
+
+ // Add the custom fields.
+
+ // NOTE: This should really just call the perform method on the
+ // Update action
+ // (How can you create a actionInfo?)
+ $customFields = new CustomFields();
+ $blogFields = $customFields->getBlogCustomFields( $this->blog->getId());
+
+ // check if the checkbox fields exists
+ if( !array_key_exists( "technoratiTags", $blogFields )) {
+ $customTechnoratiTags = new CustomField( "technoratiTags",
+ "technoratiTags_help",
+ CUSTOM_FIELD_TEXTBOX,
+ $this->blog->getId(),
+ false,
+ true );
+ $customFields->addCustomField( $customTechnoratiTags );
+ }
+ }
+
+ 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 the generating url array
+ */
+
+ function testGenerateTags()
+ {
+ // create a new post first
+ $article = new Article(
+ "topic",
+ "text",
+ Array( $this->cat->getId()),
+ $this->owner->getId(),
+ $this->blog->getId(),
+ POST_STATUS_PUBLISHED,
+ 0
+ );
+ $articles = new Articles();
+ $this->assertTrue( $articles->addArticle( $article ), "Unable to add a new test article" );
+
+ $customFieldValue = new CustomFieldValue( "technoratiTags",
+ "tag1,tag2,tag 3",
+ $article->getId(),
+ $this->blog->getId() );
+
+ $article->setFields( Array( "technoratiTags" => $customFieldValue ) );
+ $this->assertTrue( $articles->updateArticle( $article ), "Unable to update test article" );
+
+ // Now make sure the tags are returned
+ $pm =& PluginManager::getPluginManager(PLOG_CLASS_PATH."plugins/");
+ $pm->setBlogInfo($this->blog);
+ $pm->loadPlugins();
+ $plugins = $pm->getPlugins();
+
+ $plugin = $plugins["technorati"];
+ $tagArray = $plugin->getTags($article);
+
+ // see that the call was successful
+ $this->assertEquals( "<a href='http://technorati.com/tag/tag1' rel='tag'>tag1</a>", $tagArray["tag1"], "Wrong tag" );
+ $this->assertEquals( "<a href='http://technorati.com/tag/tag2' rel='tag'>tag2</a>", $tagArray["tag2"], "Wrong tag" );
+ $this->assertEquals( "<a href='http://technorati.com/tag/tag+3' rel='tag'>tag 3</a>", $tagArray["tag 3"], "Wrong tag" );
+
+ $this->assertTrue( $articles->deleteArticle( $article->getId(), $this->owner->getId(), $this->blog->getId(), true ),
+ "Error deleting article" );
+
+ }
+
+ function testGenerateNoTags()
+ {
+ // create a new post first
+ $article = new Article(
+ "topic",
+ "text",
+ Array( $this->cat->getId()),
+ $this->owner->getId(),
+ $this->blog->getId(),
+ POST_STATUS_PUBLISHED,
+ 0
+ );
+ $articles = new Articles();
+ $this->assertTrue( $articles->addArticle( $article ), "Unable to add a new test article" );
+
+ // Now make sure the tags are returned
+ $pm =& PluginManager::getPluginManager(PLOG_CLASS_PATH."plugins/");
+ $pm->setBlogInfo($this->blog);
+ $pm->loadPlugins();
+ $plugins = $pm->getPlugins();
+
+ $plugin = $plugins["technorati"];
+ $tagArray = $plugin->getTags($article);
+
+ // see that the call was successful
+ $this->assertTrue( count($tagArray) == 0, "UnUnexpected tag" );
+
+ $this->assertTrue( $articles->deleteArticle( $article->getId(), $this->owner->getId(), $this->blog->getId(), true ),
+ "Error deleting article" );
+
+ }
+
+ }
+?>
\ No newline at end of file
Modified: plugins/branches/lifetype-1.1/technorati/plugintechnorati.class.php
===================================================================
--- plugins/branches/lifetype-1.1/unported/technorati/plugintechnorati.class.php 2006-09-24 22:16:14 UTC (rev 4041)
+++ plugins/branches/lifetype-1.1/technorati/plugintechnorati.class.php 2006-09-26 18:19:29 UTC (rev 4050)
@@ -22,9 +22,9 @@
Implements technorati tagging with a custom field.
when posting, just type in your tags seperated by commas like <strong>'tag1, tag2, tag with space, tag4'</strong><br/>
<br/>Place this in your <em>post.template</em>:
-<pre>{if \$technorati && \$technnorati->isEnabled() }
+<pre>{if \$technorati && \$technorati->isEnabled() }
+{assign var="tagString" value=\$technorati->getTags(\$post)}
{foreach name=tags from=\$tagString item=tagLink}
- {assign var="tagString" value=\$technorati->getTags(\$post)}
{if \$smarty.foreach.tags.first} technorati tags: {/if}
{\$tagLink}
{if !\$smarty.foreach.tags.last}, {/if}
More information about the pLog-svn
mailing list