Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
FriendshipTest.php
1 <?php
2 /**
3  *
4  */
6 {
7  public $fixtures = array(
8  'users' => 'User',
9  'friendships' => 'Friendship'
10  );
11 
12  public static function setUpBeforeClass()
13  {
14  Yii::app()->getModule('friends');
15  }
16 
17  public function testCreateDelete()
18  {
19  $friendship = new Friendship();
20  $friendship->user1_id = $this->users('sample2')->id;
21  $friendship->user2_id = $this->users('sample3')->id;
22  $friendship->status = Friendship::STATUS_NOT_APPROVED;
23  $this->assertTrue($friendship->save());
24  $this->assertTrue($friendship->delete());
25  }
26 
27  public function testRelations()
28  {
29  $friendship = $this->friendships('sample1');
30  $this->assertNotNull($friendship->user1);
31  $this->assertNotNull($friendship->user2);
32 
33  return $friendship;
34  }
35 
36  public function testMeFriend()
37  {
38  $friendship = $this->friendships('sample1');
39 
40  $this->assertEquals($friendship->me($this->users('sample1')->id)->email, $this->users('sample1')->email);
41  $this->assertEquals($friendship->me($this->users('sample2')->id)->email, $this->users('sample2')->email);
42  $this->assertNull($friendship->me($this->users('sample3')->id));
43 
44  $this->assertEquals($friendship->friend($this->users('sample1')->id)->email, $this->users('sample2')->email);
45  $this->assertEquals($friendship->friend($this->users('sample2')->id)->email, $this->users('sample1')->email);
46  $this->assertNull($friendship->friend($this->users('sample3')->id));
47 
48  return $friendship;
49  }
50 
51  public function testMyRequest()
52  {
53  $friendship = $this->friendships('sample1');
54  $this->assertTrue($friendship->myRequest($this->users('sample1')->id));
55  $this->assertFalse($friendship->myRequest($this->users('sample2')->id));
56  }
57 
58 
59 }