Beispiel #1
0
 public function testAddArticle()
 {
     $news_id = util_genId(20);
     $title = '科技-标题20';
     $result = $this->tagsController->addArticle('tech', $news_id, $title, 1, time(), array('key1' => 'val1'));
     $this->assertTrue($result);
     $article = $this->tagsController->getArticle('tech', $news_id);
     $meta = json_decode($article['Fmeta'], true);
     $this->assertEquals($title, $article['Ftitle']);
     $this->assertEquals('val1', $meta['key1']);
 }
Beispiel #2
0
 public function testUpdate()
 {
     $tag = 'iphone';
     $pk = array('site_id' => TagSite::getSiteId('ent'), 'news_id' => util_genId(21));
     $tag_id = Tag::fetch($tag)->id;
     $data = $pk + array('time' => util_time(10), 'type' => 0);
     $result = TagArticles::model()->index($tag_id, $data);
     //$this->assertTrue($result);
     $articles = TagArticles::model()->search($tag_id);
     $article = $articles[0];
     $this->assertEquals($pk['news_id'], $article['news_id']);
     $this->assertEquals($pk['site_id'], $article['site_id']);
     $result = TagArticles::model()->removeIndex($tag_id, $data);
     //$this->assertTrue($result);
 }
 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);
 }
<?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;
<?php

return array(array('site_id' => TagSite::getSiteId('news'), 'news_id' => util_genId(1), 'tags' => 'iphone;ipad', 'create_time' => 1230952189, 'update_time' => 1230952189));
 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']);
 }
Beispiel #7
0
 public function testAddArticle()
 {
     $url = "/tags/addArticle.php";
     $params = array('site' => 'ent', 'news_id' => util_genId(5), 'pub_time' => time(), 'type' => 0, 'title' => '娱乐-标题5', 'meta' => array('thumbnail' => 'http://ia.ibtimes.com/chinese/data/images/full/2012/09/13/16421.jpg'));
     $result = $this->request($this->server . $url, $params, 'post');
     $data = $this->checkResult($result);
     $url = "/tags/getArticle.php";
     $params2 = array('site' => 'ent', 'news_id' => util_genId(5));
     $result = $this->request($this->server . $url, $params2);
     $data = $this->checkResult($result);
     $this->assertEquals($params['title'], $data['Ftitle']);
 }
<?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;