Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
LikeTest.php
1 <?php
2 /**
3  * Gentics Portal.Node PHP
4  * Author & Copyright (c) by Gentics Software GmbH
5  * sales@gentics.com
6  * http://www.gentics.com
7  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8  * You must not use this software without a valid license agreement.
9  *
10  */
11 class LikeTest extends CDbTestCase
12 {
13  public $fixtures = array(
14  'users' => 'User',
15  'likes' => 'Like',
16  'profiles' => 'Profile'
17  );
18 
19 
20  public function setUp()
21  {
22  Yii::app()->getModule('like');
23  parent::setUp();
24  }
25 
26  function testGetLikes()
27  {
28  $like = Like::model()->findByPk($this->likes['sample1']['id']);
29  $this->assertCount(3, $like->getLikes());
30  }
31 
32  function testGetLikesQty()
33  {
34  $like = Like::model()->findByPk($this->likes['sample1']['id']);
35  $this->assertEquals(3, $like->getLikesQty());
36  }
37 
38  function testUserRelation()
39  {
40  $like = Like::model()->findByPk($this->likes['sample1']['id']);
41  $this->assertNotEmpty($like->user);
42  }
43 
44  function testProfileRelation()
45  {
46  $like = Like::model()->findByPk($this->likes['sample1']['id']);
47  $this->assertNotEmpty($like->profile);
48  }
49 
50  function testCreateDelete()
51  {
52  $like = new Like();
53  $like->content_id = 100;
54  $like->user_id = 1;
55  $this->assertTrue($like->save());
56  $this->assertTrue($like->delete());
57  }
58 
59  function testValidateFields()
60  {
61  $like = new Like();
62  $like->validate();
63 
64  $this->assertTrue($like->hasErrors('user_id'));
65  $this->assertTrue($like->hasErrors('content_id'));
66  }
67 }