12 public $fixtures = array(
13 'comments' =>
'Comment',
15 'AuthItem' =>
':AuthItem',
16 'AuthItemChild' =>
':AuthItemChild',
17 'AuthAssignment' =>
':AuthAssignment'
22 public function setUp()
25 $this->oldUser = Yii::app()->user;
28 public function tearDown()
30 Yii::app()->setComponent(
'user', $this->oldUser);
33 protected function getUserMock($methods)
35 $webUser = $this->getMock(
'CWebUser', $methods);
36 Yii::app()->setComponent(
'user', $webUser);
40 public function testCantDeleteNotLoggedIn()
45 public function testCanDeleteOwner()
47 $webUser = $this->getUserMock(array(
'getId',
'getIsInitialized'));
48 $webUser->expects($this->any())->method(
'getId')->will($this->returnValue($this->users[
'commenterWithoutRights'][
'id']));
49 $webUser->expects($this->any())->method(
'getIsInitialized')->will($this->returnValue(
true));
54 public function testCanDeleteModerator()
56 $webUser = $this->getUserMock(array(
'getId',
'__get'));
58 $webUser->expects($this->any())->method(
'__get')
59 ->will($this->returnValue($this->users[
'commentsModerator'][
'email']));
60 $webUser->expects($this->any())->method(
'getIsInitialized')->will($this->returnValue(
true));
64 public function testCanDeleteManageCommentsPermission()
66 $webUser = $this->getUserMock(array(
'getId',
'getIsInitialized',
'__get'));
67 $webUser->expects($this->any())->method(
'getId')->will($this->returnValue($this->users[
'manageComments'][
'id']));
68 $webUser->expects($this->any())->method(
'getIsInitialized')->will($this->returnValue(
true));
72 public function testCanApproveNotLoggedIn()
77 public function testCantApproveOwner()
79 $webUser = $this->getUserMock(array(
'__get',
'getId',
'getIsInitialized'));
80 $webUser->expects($this->any())->method(
'getIsInitialized')->will($this->returnValue(
true));
81 $webUser->expects($this->any())->method(
'__get')
82 ->will($this->returnValue($this->users[
'commenterWithoutRights'][
'email']));
83 $webUser->expects($this->any())->method(
'getId')
84 ->will($this->returnValue($this->users[
'commenterWithoutRights'][
'id']));
89 public function testCanApproveManageCommentsPermission()
91 $webUser = $this->getUserMock(array(
'getId',
'getIsInitialized',
'__get'));
92 $webUser->expects($this->any())->method(
'getId')->will($this->returnValue($this->users[
'manageComments'][
'id']));
93 $webUser->expects($this->any())->method(
'getIsInitialized')->will($this->returnValue(
true));
97 public function testIsEmailModerator()