Example #1
0
 public function testSearchAll()
 {
     $indexer = new TagArticles();
     $tag = 'iphone';
     $tag_id = Tag::fetch($tag)->id;
     $rows = $indexer->search($tag_id);
     $this->assertEquals(2, count($rows));
     $row = $rows[0];
     $pk = array('site_id' => $row['site_id'], 'news_id' => $row['news_id']);
     $article = ArticleTags::model()->findByPk($pk);
     if ($article) {
         $tags = $article->str2arr($article->tags);
         $this->assertTrue(in_array($tag, $tags));
     }
 }
Example #2
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']);
 }