$summit_id, ]; $name = str_random(16).'_badge_type'; $template = <<

this is a badge

HTML; $data = [ 'name' => $name, 'description' => "this is a description", 'template_content' => $template, 'is_default' => $is_default ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "POST", "OAuth2SummitBadgeTypeApiController@add", $params, [], [], [], $headers, json_encode($data) ); $content = $response->getContent(); $this->assertResponseStatus(201); $badge_type = json_decode($content); $this->assertTrue(!is_null($badge_type)); $this->assertTrue($badge_type->name == $name); return $badge_type; } public function testUpdateBadgeFeatureType($summit_id = 27){ $badge_type_old = $this->testAddBadgeType($summit_id, false); $params = [ 'id' => $summit_id, "badge_type_id" => $badge_type_old->id ]; $data = [ 'description' => "this is a description update", 'is_default' => true, ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "PUT", "OAuth2SummitBadgeTypeApiController@update", $params, [], [], [], $headers, json_encode($data) ); $content = $response->getContent(); $this->assertResponseStatus(201); $badge_type = json_decode($content); $this->assertTrue(!is_null($badge_type)); $this->assertTrue($badge_type->name == $badge_type_old->name); return $badge_type; } 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", "OAuth2SummitBadgeTypeApiController@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 testDeleteBadgeFeatureType($summit_id=27){ $badge_type_old = $this->testAddBadgeType(); $params = [ 'id' => $summit_id, "feature_id" => $badge_type_old->id ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "DELETE", "OAuth2SummitBadgeTypeApiController@delete", $params, [], [], [], $headers ); $content = $response->getContent(); $this->assertResponseStatus(204); } public function testAssignAccessLevelToBadgeType($summit_id=27){ $badge_type_old = $this->testAddBadgeType(); $params = [ 'id' => $summit_id, "feature_id" => $badge_type_old->id, 'access_level_id' => 1 ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "PUT", "OAuth2SummitBadgeTypeApiController@addAccessLevelToBadgeType", $params, [], [], [], $headers ); $content = $response->getContent(); $this->assertResponseStatus(201); } public function testRemoveAccessLevelToBadgeType($summit_id=27){ $badge_type_old = $this->testAddBadgeType(); $params = [ 'id' => $summit_id, "feature_id" => $badge_type_old->id, 'access_level_id' => 1 ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "PUT", "OAuth2SummitBadgeTypeApiController@addAccessLevelToBadgeType", $params, [], [], [], $headers ); $content = $response->getContent(); $this->assertResponseStatus(201); $response = $this->action( "DELETE", "OAuth2SummitBadgeTypeApiController@removeAccessLevelFromBadgeType", $params, [], [], [], $headers ); $content = $response->getContent(); $this->assertResponseStatus(201); } }