示例#1
0
 public function testRemove()
 {
     $tag = 'iphone';
     $data = array('site_id' => TagSite::getSiteId('ent'), 'news_id' => ArticleTags::genId(1), 'type' => 1, 'time' => util_time(7));
     $tag_id = Tag::model()->fetch($tag)->id;
     $count = TagArticles::model()->count($tag_id);
     $this->assertEquals(2, $count);
     $count = TagArticles::model()->count($tag_id, $data['site_id']);
     $this->assertEquals(1, $count);
     $count = TagArticles::model()->count($tag_id, 0, $data['type']);
     $this->assertEquals(1, $count);
     $count = TagArticles::model()->count($tag_id, $data['site_id'], $data['type']);
     $this->assertEquals(1, $count);
     $result = TagArticles::model()->removeIndex($tag_id, $data);
     //$this->assertTrue($result);
     $count = TagArticles::model()->count($tag_id);
     $this->assertEquals(1, $count);
     $count = TagArticles::model()->count($tag_id, $data['site_id']);
     $this->assertEquals(0, $count);
     $count = TagArticles::model()->count($tag_id, 0, $data['type']);
     $this->assertEquals(0, $count);
     $count = TagArticles::model()->count($tag_id, $data['site_id'], $data['type']);
     $this->assertEquals(0, $count);
     $result = TagArticles::model()->index($tag_id, $data);
     //$this->assertTrue($result);
 }
示例#2
0
 public function testAddArticle()
 {
     $site_id = TagSite::getSiteId('tech');
     $news_id = util_genId(4);
     $title = '科技-标题4';
     $type = 0;
     $pub_time = time();
     $result = ArticleMini::model()->addArticle($site_id, $news_id, $title, $type, $pub_time);
     $this->assertTrue($result);
     $article = ArticleMini::model()->findByPk(array($site_id, $news_id));
     $this->assertNotNull($article);
     $this->assertEquals($site_id, $article->Fsite_id);
     $this->assertEquals($news_id, $article->Farticle_id);
     $this->assertEquals($title, $article->Ftitle);
 }
示例#3
0
<?php

$data = array(array('tag_id' => 4, 'site_id' => TagSite::getSiteId('news'), 'news_id' => util_genId(1), 'type' => 0, 'time' => util_time(9)), array('tag_id' => 4, 'site_id' => TagSite::getSiteId('ent'), 'news_id' => util_genId(1), 'type' => 1, 'time' => util_time(8)), array('tag_id' => 3, 'site_id' => TagSite::getSiteId('news'), 'news_id' => util_genId(1), 'type' => 0, 'time' => util_time(9)));
return $data;
示例#4
0
<?php

// change the following paths if necessary
require_once 'inc/tags/lib/Loader.class.php';
WF_Loader::registerAutoload();
require_once "inc/tags/TagArticles.inc.php";
require_once "inc/tags/Tag.inc.php";
require_once "inc/tags/ArticleTags.inc.php";
require_once "inc/tags/ArticleMini.inc.php";
require_once "inc/tags/TagsKey.inc.php";
require_once "inc/tags/TagSite.inc.php";
require __DIR__ . '/fixtures/util.func.php';
$conf = (require __DIR__ . '/config/test.conf.php');
define("ROOT_DIR", __DIR__);
WF_Registry::set('logger', new WF_Logger());
$instance = WF_Db::instance($conf['db']);
WF_Registry::set('db', $instance);
unset($instance);
WF_DbTestCase::setBasePath(ROOT_DIR . "/fixtures");
WF_Event::bind('addArticleTag', array(TagArticles::model(), 'onAddArticleTag'));
WF_Event::bind('removeArticleTag', array(TagArticles::model(), 'onRemoveArticleTag'));
$redis = new Redis();
$redis_config = $conf['redis'];
$redis->connect($redis_config['host'], $redis_config['port']);
$redis->flushAll();
WF_Registry::set('cache', $redis);
WF_Registry::set('redis', $redis);
WF_Config::set('tagitem_use_cache', true);
TagSite::refresh(__DIR__ . '/data/sites.dat');
$id = TagSite::getSiteId('news');
示例#5
0
<?php

return array(array('site_id' => TagSite::getSiteId('news'), 'news_id' => util_genId(1), 'tags' => 'iphone;ipad', 'create_time' => 1230952189, 'update_time' => 1230952189));
示例#6
0
 public function testTagsIndexMobile()
 {
     $tags = array('iphone', 'ipad');
     $site_id = TagSite::getSiteId('news');
     //'news';
     $news_id = util_genId(51);
     $indexer = new TagArticles();
     $tag_id = Tag::fetch('iphone')->id;
     $rows = $indexer->search($tag_id, 0, 0, 'mobile', 1);
     $this->assertEquals(1, count($rows));
     $this->assertEquals($news_id, $rows[0]['news_id']);
     $article = new ArticleTags();
     $article->setAttributes(array('site_id' => $site_id, 'news_id' => $news_id, 'time' => util_time(23), 'type' => 0, 'source' => 'mobile'));
     $result = $article->saveTags($tags);
     $this->assertTrue($result);
     $rows = $indexer->search($tag_id, 0, 0, 'web', 1);
     $this->assertEquals(1, count($rows));
     $this->assertEquals($news_id, $rows[0]['news_id']);
     $rows = $indexer->search($tag_id, 0, 0, 'mobile', 1);
     $this->assertEquals(1, count($rows));
     $this->assertEquals($news_id, $rows[0]['news_id']);
 }
示例#7
0
<?php

$rows = array(array('Fsite_id' => TagSite::getSiteId('news'), 'Farticle_id' => util_genId(1), 'Ftitle' => '新闻-标题1', 'Ftype' => 0, 'Fpub_time' => util_datetime(9)), array('Fsite_id' => TagSite::getSiteId('ent'), 'Farticle_id' => util_genId(1), 'Ftitle' => '娱乐-标题2', 'Ftype' => 0, 'Fpub_time' => util_datetime(8)), array('Fsite_id' => TagSite::getSiteId('news'), 'Farticle_id' => util_genId(3), 'Ftitle' => '新闻-标题2', 'Ftype' => 0, 'Fpub_time' => util_datetime(7)));
return $rows;