7 public $fixtures = array(
9 'friendships' =>
'Friendship'
12 public static function setUpBeforeClass()
14 Yii::app()->getModule(
'friends');
17 public function testCreateDelete()
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());
27 public function testRelations()
29 $friendship = $this->friendships(
'sample1');
30 $this->assertNotNull($friendship->user1);
31 $this->assertNotNull($friendship->user2);
36 public function testMeFriend()
38 $friendship = $this->friendships(
'sample1');
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));
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));
51 public function testMyRequest()
53 $friendship = $this->friendships(
'sample1');
54 $this->assertTrue($friendship->myRequest($this->users(
'sample1')->id));
55 $this->assertFalse($friendship->myRequest($this->users(
'sample2')->id));