Elentra API
  • Introduction
  • Developers
    • Getting Started
    • Quickstart Guide
      • Set up Repositories
      • Validate the setup
      • Exploring the API
      • Creating a new Module
      • Setup Routing
      • Introduction to Postman
      • Create a Controller
      • Using Eloquent Models
      • Input Validation
      • API Resource Authorization
  • Elentra API Standards
    • HTTP Methods & Status Codes
    • Routing & Parameters
      • Example Routing Patterns with HTTP Method
        • /courses/{course}/contacts
        • /courses/{course}/contacts?type={contact_type}
        • /courses/{course}/contacts/{contact}
        • /courses/{course}/syllabus
      • Common Mistakes
        • [GET] /admissions/file-review/file/rubric-score/{cycle_id}/{pool_id}/{subpool_id}
        • [DELETE] /notices/1,2,3
        • [GET] /cbe/curriculum/framework/{framework_id}/hierarchy-by-depth
        • [GET] /admissions/file-review/file/rubric-score/delete/{id}
        • [GET] /portfolio/entries/{entry_id}/get-file
        • [POST] /cbe/curriculum/updateframework
  • Automated Testing
    • Getting Started
      • Setting up a testing environment
      • Running Automated Tests
    • Seed Data
      • Folder Structure
      • Creating Seed Data
    • Functional Tests
      • Creating a Functional Test File
      • Testing HTTP Verbs
        • Creating an HTTP Test
        • GET Requests
        • POST / PUT / DELETE Requests
        • GraphQL Requests
      • Asserting API Response
      • Annotations
    • Code Style Linting
Powered by GitBook
On this page
  1. Automated Testing
  2. Functional Tests
  3. Testing HTTP Verbs

GET Requests

GET Request:

When calling a get method, two pieces of information are required:

  1. The URL (This could also contain the query parameters)

  2. The authentication token

Example:

/**
 * Test that the GET /events returns 200
 *
 * @test
 * @return void
 */
public function events_get_method_index_returns_200(): void
{
	$this->actingAsAdmin()
          ->authenticate()
          ->get('/events');
}

The URL in this example is /events

Use the method ->authenticate() to authenticate the user, so the token does not have to be passed in the request.

Example 2:

$this->actingAs(User::find(6))
  ->authenticate()
  ->get('/assessments/assessment-methods?course_id=2')

The value for “course_id” is 2 within the URL

The test does not call $this->actingAsAdmin() because the user in the test is not user 1 (default administrator)

PreviousCreating an HTTP TestNextPOST / PUT / DELETE Requests

Last updated 2 years ago