Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
TagcloudTest.php
1 <?php
2 /**
3  * Created by JetBrains PhpStorm.
4  * User: Andrey
5  * Date: 5/21/13
6  * Time: 3:13 PM
7  * To change this template use File | Settings | File Templates.
8  */
9 
10 class TagcloudTest extends CTestCase{
11 
12  public $repositoryMoc = null;
13 
14  public $repositoryOrigin = null;
15 
16  public $tags = null;
17 
18  public static function setUpBeforeClass(){
19 
20  Yii::app()->getModule('tagcloud');
21  }
22 
23  public function setUp(){
24  parent::setUp();
25 
26  $this->repositoryMoc = $this->getMock('RepositoryApi', array('request'));
27 
28  $this->repositoryOrigin = Yii::app()->repositoryApi;
29 
30  $repositoryResponse = 'a:13:{s:6:"status";s:2:"ok";s:7:"10007.3";a:6:{s:9:"contentid";s:7:"10007.3";s:6:"obj_id";s:1:"3";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:1:"7";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:2:{s:13:"edittimestamp";s:10:"1364758042";s:11:"permissions";a:0:{}}}s:10:"10007.3812";a:6:{s:9:"contentid";s:10:"10007.3812";s:6:"obj_id";s:4:"3812";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3343";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:2:{s:13:"edittimestamp";s:10:"1364759267";s:11:"permissions";a:0:{}}}s:10:"10007.3813";a:6:{s:9:"contentid";s:10:"10007.3813";s:6:"obj_id";s:4:"3813";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3342";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:2:{s:13:"edittimestamp";s:10:"1364759288";s:11:"permissions";a:0:{}}}s:10:"10007.3815";a:6:{s:9:"contentid";s:10:"10007.3815";s:6:"obj_id";s:4:"3815";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3341";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:2:{s:13:"edittimestamp";s:10:"1364759347";s:11:"permissions";a:0:{}}}s:10:"10007.3822";a:6:{s:9:"contentid";s:10:"10007.3822";s:6:"obj_id";s:4:"3822";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3343";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:3:{s:13:"edittimestamp";s:10:"1364751584";s:7:"tagging";s:41:"jQuery, Conference, Aloha Editor, Gentics";s:11:"permissions";a:0:{}}}s:10:"10007.3823";a:6:{s:9:"contentid";s:10:"10007.3823";s:6:"obj_id";s:4:"3823";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3342";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:3:{s:13:"edittimestamp";s:10:"1366635676";s:7:"tagging";s:48:"Enterprise 2.0, Blog, Wiki, Crowd, Andrew Mcafee";s:11:"permissions";a:0:{}}}s:10:"10007.3952";a:6:{s:9:"contentid";s:10:"10007.3952";s:6:"obj_id";s:4:"3952";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3343";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:3:{s:13:"edittimestamp";s:10:"1345660473";s:7:"tagging";s:19:"Aloha Editor, HTML5";s:11:"permissions";a:0:{}}}s:10:"10007.3954";a:6:{s:9:"contentid";s:10:"10007.3954";s:6:"obj_id";s:4:"3954";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3343";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:3:{s:13:"edittimestamp";s:10:"1362059693";s:7:"tagging";s:38:"Mobile Websites, iPad, iPhone, Android";s:11:"permissions";a:0:{}}}s:10:"10007.3957";a:6:{s:9:"contentid";s:10:"10007.3957";s:6:"obj_id";s:4:"3957";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3342";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:3:{s:13:"edittimestamp";s:10:"1345696911";s:7:"tagging";s:27:"Google Wave, Enterprise 2.0";s:11:"permissions";a:0:{}}}s:10:"10007.3958";a:6:{s:9:"contentid";s:10:"10007.3958";s:6:"obj_id";s:4:"3958";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3341";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:3:{s:13:"edittimestamp";s:10:"1353009799";s:7:"tagging";s:35:"UX Barcamp, Usability, Aloha Editor";s:11:"permissions";a:0:{}}}s:10:"10007.3961";a:6:{s:9:"contentid";s:10:"10007.3961";s:6:"obj_id";s:4:"3961";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3341";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:3:{s:13:"edittimestamp";s:10:"1363265266";s:7:"tagging";s:36:"Aloha Editor, Dev Con, San Francisco";s:11:"permissions";a:0:{}}}s:10:"10007.3963";a:6:{s:9:"contentid";s:10:"10007.3963";s:6:"obj_id";s:4:"3963";s:8:"obj_type";s:5:"10007";s:9:"mother_id";s:4:"3341";s:11:"mother_type";s:5:"10002";s:10:"attributes";a:3:{s:13:"edittimestamp";s:10:"1362913604";s:7:"tagging";s:27:"OSSBIG, Aloha Editor, Event";s:11:"permissions";a:0:{}}}}';
31 
32  $this->repositoryMoc->expects($this->any())
33  ->method('request')
34  ->will($this->returnValue($repositoryResponse));
35 
36  Yii::app()->setComponent('repositoryApi', $this->repositoryMoc);
37 
38  $c = new CController('phpunit');
39  $c->setAction(new CInlineAction($c, 'urltest'));
40  Yii::app()->setController($c);
41 
42  $this->tags = array(
43  'Aloha Editor',
44  'Enterprise 2.0',
45  'UX Barcamp',
46  'Google Wave',
47  'Usability',
48  'Android',
49  'San Francisco',
50  'Event',
51  'OSSBIG',
52  'iPhone',
53  );
54  }
55 
56  public function testTagcloud(){
57 
58  Yii::app()->cache->flush();
59  $tagcloudHTML = Yii::app()->controller->widget(
60  'tagcloud.widgets.TagcloudWidget',
61  array(
62  'folderIds'=>array('10002.3341','10002.3342','10002.3343','10002.7'),
63  'usePersonalisation' => false,
64  'overviewPage' => '/Content.Node/blog/Corporate-Blog.en.html',
65  'tagstyles' => array('tagsize_1', 'tagsize_2', 'tagsize_3'),
66  'tagsSeparator'=>',',
67  'limit' => 10
68  ), true
69  );
70 
71  foreach($this->tags as $tag){
72 
73  preg_match("/$tag/", $tagcloudHTML, $match);
74  $this->assertNotEmpty($match, "The tag '$tag' has not been shown");
75  }
76 
77  Yii::app()->setComponent('repositoryApi', $this->repositoryOrigin);
78  }
79 }