mirror of
https://github.com/humhub/humhub.git
synced 2025-01-18 06:38:14 +01:00
Added FunctionalTester::follow()
Added `HumHubDbTestCase::setProfileField()` and `HumHubDbTestCase::becomeFriendWith()` and `HumHubDbTestCase::follow()` and`HumHubDbTestCase::enableFriendships()`
This commit is contained in:
parent
61f1ccc002
commit
04b60dd69a
@ -101,8 +101,16 @@ class FunctionalTester extends \Codeception\Actor
|
||||
Friendship::add(Yii::$app->user->identity, $user);
|
||||
}
|
||||
|
||||
public function follow($username)
|
||||
{
|
||||
User::findOne(['username' => $username])->follow();
|
||||
}
|
||||
|
||||
public function setProfileField($field, $value)
|
||||
{
|
||||
$output = new \Codeception\Lib\Console\Output([]);
|
||||
$output->writeln("Set attribute $field : $value");
|
||||
|
||||
$user = Yii::$app->user->identity;
|
||||
$user->profile->setAttributes([$field => $value]);
|
||||
$user->profile->save();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace tests\codeception\_support;
|
||||
|
||||
use humhub\modules\friendship\models\Friendship;
|
||||
use Yii;
|
||||
use yii\base\Event;
|
||||
use yii\db\ActiveRecord;
|
||||
@ -172,6 +173,37 @@ class HumHubDbTestCase extends Test
|
||||
}
|
||||
}
|
||||
|
||||
public function setProfileField($field, $value, $user)
|
||||
{
|
||||
if(is_int($user)) {
|
||||
$user = User::findOne($user);
|
||||
} else if (is_string($user)) {
|
||||
$user = User::findOne(['username' => $user]);
|
||||
} else if (!$user) {
|
||||
$user = Yii::$app->user->identity;
|
||||
}
|
||||
|
||||
$user->profile->setAttributes([$field => $value]);
|
||||
$user->profile->save();
|
||||
}
|
||||
|
||||
public function becomeFriendWith($username)
|
||||
{
|
||||
$user = User::findOne(['username' => $username]);
|
||||
Friendship::add($user, Yii::$app->user->identity);
|
||||
Friendship::add(Yii::$app->user->identity, $user);
|
||||
}
|
||||
|
||||
public function follow($username)
|
||||
{
|
||||
User::findOne(['username' => $username])->follow();
|
||||
}
|
||||
|
||||
public function enableFriendships($enable = true)
|
||||
{
|
||||
Yii::$app->getModule('friendship')->settings->set('enable', $enable);
|
||||
}
|
||||
|
||||
public function setGroupPermission($groupId, $permission, $state = BasePermission::STATE_ALLOW)
|
||||
{
|
||||
$permissionManger = new PermissionManager();
|
||||
|
Loading…
x
Reference in New Issue
Block a user