/** * Basic create group test */ public function testCreateGroup() { $owner = UserFactory::createUser(); $name = Utils::CreateRandomString(); $description = Utils::CreateRandomString(); $alias = Utils::CreateRandomString(); $response = GroupController::apiCreate(new Request(array('auth_token' => self::login($owner), 'name' => $name, 'alias' => $alias, 'description' => $description))); $this->assertEquals('ok', $response['status']); $groups = GroupsDAO::search(new Groups(array('name' => $name))); $group = $groups[0]; $this->assertNotNull($group); $this->assertEquals($description, $group->getDescription()); $this->assertEquals($owner->getUserId(), $group->getOwnerId()); }
/** * Create group * * @param type $owner * @param type $name * @param type $description */ public static function createGroup($owner = null, $name = null, $description = null, $alias = null) { if (is_null($owner)) { $owner = UserFactory::createUser(); } if (is_null($name)) { $name = Utils::CreateRandomString(); } if (is_null($description)) { $description = Utils::CreateRandomString(); } if (is_null($alias)) { $alias = Utils::CreateRandomString(); } $r = new Request(array("auth_token" => OmegaupTestCase::login($owner), "name" => $name, "description" => $description, "alias" => $alias)); $response = GroupController::apiCreate($r); $groups = GroupsDAO::search(new Groups(array("alias" => $alias))); return array("request" => $r, "response" => $response, "owner" => $owner, "group" => $groups[0]); }