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); }
<?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;
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']); }