Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
RememberPagesTest.php
1 <?php
2 /**
3  *
4  */
5 class RememberPagesTest extends CDbTestCase{
6 
7  public $fixtures = array(
8 
9  );
10 
11  public static function setUpBeforeClass(){
12 
13  Yii::app()->getModule('remember');
14  RememberedPage::model()->deleteAll();
15  }
16 
17  public function testRememberPages(){
18 
19  //Data to remember
20  $url = "http://gportal-dev-dev.gentics.com/";
21  $title = "gportal";
22  $page_id = "1";
23  $additional = '';
24  $collection_id = EncryptHelper::encrypt('ExampleCollectionId');
25 
26  $key = Yii::app()->getModule('remember')->sign(serialize($_GET));
27  $back_to_referer = null;
28  //Check that the keys match, and test "sign" method
29  $this->assertTrue(Yii::app()->getModule('remember')->sign(serialize($_GET)) === $key);
30 
31  $rememberedPage = new RememberedPage();
32  $this->assertInstanceOf('RememberedPage', $rememberedPage);
33  $collection_id = EncryptHelper::decrypt($collection_id);
34  //Check collection id was successfully decoded
35  $this->assertEquals($collection_id, 'ExampleCollectionId');
36 
37  $rememberedPage->collection_id = $collection_id;
38 
39  $rememberedPage->url = $url;
40  $rememberedPage->title = $title;
41  $rememberedPage->page_id = $page_id;
42  $rememberedPage->additional = unserialize($additional);
43  //Check that model was successfully saved to db
44  $this->assertTrue($rememberedPage->save());
45  }
46 
47  public function testRemindPages(){
48 
49  $collection_id = 'ExampleCollectionId';
50 
51  $criteria = new CDbCriteria();
52  $criteria->compare('collection_id', $collection_id);
53  $criteria->order = 'created DESC';
54  $criteria->limit = 99;
55 
56  $model = RememberedPage::model();
57  //Check that the model declaration exists
58  $this->assertEquals(gettype($model), 'object');
59  $pages = $model->findAll($criteria);
60  //The record was found
61  $this->assertEquals(1, count($pages));
62  //Check that it is object
63  $model = $pages[0];
64  $this->assertInstanceOf('RememberedPage', $model);
65  //Check the fields
66  $this->assertEquals($model->url , "http://gportal-dev-dev.gentics.com/");
67  $this->assertEquals($model->title , "gportal");
68  $this->assertEquals($model->page_id , 1);
69  $this->assertEquals($model->collection_id , 'ExampleCollectionId');
70  }
71 }