$summit_id,
];
$name = str_random(16).'_access_level';
$template = <<
HTML;
$data = [
'name' => $name,
'description' => "this is a description",
'template_content' => $template,
'tag_name' => "droid",
'is_default' => true,
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitAccessLevelTypeApiController@add",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$access_level = json_decode($content);
$this->assertTrue(!is_null($access_level));
$this->assertTrue($access_level->name == $name);
return $access_level;
}
public function testUpdateAccessLevel($summit_id = 27){
$access_level_old = $this->testAddAccessLevel();
$params = [
'id' => $summit_id,
"level_id" => $access_level_old->id
];
$data = [
'description' => "this is a description update",
'is_default' => false,
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"PUT",
"OAuth2SummitAccessLevelTypeApiController@update",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$access_level = json_decode($content);
$this->assertTrue(!is_null($access_level));
$this->assertTrue($access_level->name == $access_level_old->name);
return $access_level;
}
public function testGetAllBySummit($summit_id=27){
$params = [
'id' => $summit_id,
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"GET",
"OAuth2SummitAccessLevelTypeApiController@getAllBySummit",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$data = json_decode($content);
$this->assertTrue(!is_null($data));
return $data;
}
/**
* @param int $summit_id
*/
public function testDeleteAccessLevel($summit_id=27){
$access_level_old = $this->testAddAccessLevel();
$params = [
'id' => $summit_id,
"level_id" => $access_level_old->id
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"DELETE",
"OAuth2SummitAccessLevelTypeApiController@delete",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(204);
}
}