'TEST GROUP '.str_random(16), 'members' => [self::$member2->getId()], 'summits' => [self::$summit->getId()], ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "POST", "OAuth2SummitAdministratorPermissionGroupApiController@add", $params, [], [], [], $headers, json_encode($data) ); $content = $response->getContent(); $this->assertResponseStatus(201); $group = json_decode($content); $this->assertTrue(!is_null($group)); $this->assertTrue(count($group->members) == 1); $this->assertTrue(count($group->summits) == 1); return $group; } public function testUpdateGroupOk(){ $group = $this->testAddGroupOK(); $params = [ 'group_id' => $group->id ]; $data = [ 'members' => [self::$member2->getId()], 'summits' => [], ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "PUT", "OAuth2SummitAdministratorPermissionGroupApiController@update", $params, [], [], [], $headers, json_encode($data) ); $content = $response->getContent(); $this->assertResponseStatus(201); $group = json_decode($content); $this->assertTrue(!is_null($group)); $this->assertTrue(count($group->members) == 1); $this->assertTrue(count($group->summits) == 0); } public function testGetAllOK(){ $group = $this->testAddGroupOK(); $params = [ 'expand' => 'summits,members' ]; $data = [ ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "GET", "OAuth2SummitAdministratorPermissionGroupApiController@getAll", $params, [], [], [], $headers, json_encode($data) ); $content = $response->getContent(); $this->assertResponseStatus(200); $groups = json_decode($content); $this->assertTrue(!is_null($groups)); } public function testGetByIdOK(){ $group = $this->testAddGroupOK(); $params = [ 'id' => $group->id, //'expand' => 'summits,members', ]; $data = [ ]; $headers = [ "HTTP_Authorization" => " Bearer " . $this->access_token, "CONTENT_TYPE" => "application/json" ]; $response = $this->action( "GET", "OAuth2SummitAdministratorPermissionGroupApiController@get", $params, [], [], [], $headers, json_encode($data) ); $content = $response->getContent(); $this->assertResponseStatus(200); $group = json_decode($content); $this->assertTrue(!is_null($group)); } }