Laravel 5: Testing – Cheatsheet: Laravel specific PHPUnit testing assertion

Cheatsheet – Laravel Specific PHPUnit Testing Assertion

All PHPUnit docs page with all methods and annotations – see here

[one_third]
assertSuccessful
assertStatus
assertRedirect
assertHeader
assertHeaderMissing
assertPlainCookie
assertCookie
assertCookieExpired
assertCookieMissing
assertSee
assertSeeInOrder
[/one_third][one_third]
assertDontSee
assertSeeText
assertDontSeeText
assertSeeTextInOrder
assertJson
assertExactJson
assertJsonFragment
assertJsonMissing
assertJsonMissingExact
assertJsonStructure
assertJsonCount
[/one_third][one_third_last]
assertJsonValidationErrors
assertViewIs
assertViewHas
assertViewHasAll
assertViewMissing
assertSessionHas
assertSessionHasAll
assertSessionHasErrors
assertSessionHasErrorsIn
assertSessionMissing
[/one_third_last]


LARAVEL SPECIFIC TESTING HELPER METHODS

Check HTTP code
assertSuccessful

assertStatus

Redirects
assertRedirect

Headers
assertHeader

assertHeader

Cookies
assertPlainCookie

assertCookie

assertCookieExpired

assertCookieMissing

Check response page code – including HTML tags
assertSee

assertSeeInOrder

assertDontSee

Check response page code – text only
assertSeeText

assertDontSeeText

assertSeeTextInOrder

JSON
assertJson

assertExactJson

assertJsonFragment

assertJsonMissing

assertJsonMissingExact

assertJsonStructure

assertJsonCount

assertJsonValidationErrors

decodeResponseJson

Views
assertViewIs

assertViewHas

assertViewHasAll

assertViewMissing

Session
assertSessionHas

assertSessionHasAll

assertSessionHasErrors

assertSessionHasErrorsIn

assertSessionMissing

Authentication Assertions
assertCredentials

assertInvalidCredentials

 

 

 

HTTP tests – see Laravel docs.