Example #1
0
 public function sgCreateGroup()
 {
     $this->checkPermissions($_POST['_wpnonce'], 'sg-create-group');
     $groupsObj = new Groups();
     $groupsObj->returnMessages = true;
     if (mb_strlen($_POST['name']) > 0) {
         $result = $groupsObj->create(['name' => $_POST['name']]);
         $output['result'] = $result['result'];
         $output['messages'] = $result['messages']['error'];
     } else {
         $output['result'] = 0;
         $output['messages'][] = __('Передано недостаточно данных');
     }
     echo json_encode($output, JSON_UNESCAPED_UNICODE);
     die;
 }
Example #2
0
 /** @test **/
 public function it_can_remove_members_in_group()
 {
     $users = $this->createUsers(4);
     $group = Groups::create($users[0]->id, $this->data);
     $group->addMembers([$users[1]->id, $users[2]->id]);
     $this->assertEquals($group->fresh()->users->count(), 2);
     $group->leave([$users[2]->id]);
     $this->assertEquals(1, $group->fresh()->users->count());
 }
Example #3
0
 public function createGroup($owner)
 {
     $data = ['name' => 'Lorem'];
     return Groups::create($owner, $data);
 }