12 public $fixtures = array(
16 public $collection_id;
20 public static function setUpBeforeClass(){
22 Yii::app()->getModule(
'history');
23 Yii::app()->cache->delete(VisitedHistory::getCacheKey(
'getCacheKey'));
26 public function setUp(){
28 $this->collection_id =
'history';
32 'url' =>
'http://gportal-dev-dev.gentics.com/Content.Node/index.html',
37 'url' =>
'http://gportal-dev-dev.gentics.com/Content.Node/news/News-Overview.en.html',
42 'url' =>
'http://gportal-dev-dev.gentics.com/Content.Node/products/Products.en.html',
43 'title' =>
'products',
47 'url' =>
'http://gportal-dev-dev.gentics.com/Content.Node/blog/Corporate-Blog.en.html',
52 'url' =>
'http://gportal-dev-dev.gentics.com/Content.Node/service/Overview_Service.en.html',
61 public function testSaveHistory(){
63 foreach($this->data as $i => $page){
65 VisitedHistory::addItem($page[
'url'], $page[
'title'], $page[
'page_id'], $this->collection_id);
67 $this->assertNotEquals(Yii::app()->cache->get(VisitedHistory::getCacheKey($this->collection_id)), null,
"History has not been written");
71 public function testReadHistory(){
73 $history = VisitedHistory::getItems($this->collection_id);
75 $this->assertNotEmpty($history,
"History has not been read");
77 foreach($history as $valuesFromCache){
78 $title = $valuesFromCache[
'title'];
79 $this->assertEquals($this->getHash($this->data[$title]), $this->getHash($valuesFromCache),
"Information which was read doesn't math the pattern");
83 public function getHash($data){
85 $comparedFields = array(
'url',
'title',
'page_id');
87 foreach($data as $fieldName => $value){
89 if(in_array($fieldName, $comparedFields)){