---
title: "Discussion on \"2 Ways to Fake $_SERVER Variables in Laravel Feature Tests\" | Hashnode"
description: "Discussion on \"2 Ways to Fake $_SERVER Variables in Laravel Feature Tests\". Fake $_SERVER in Laravel feature tests by passing server vars per-request, or use withServerVariables() to apply them globally for the entire test method."
url: "https://hashnode.com/posts/laravel-testing-mock-server-variables-1-1-1/69add9943b6e21227e777342"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [2 Ways to Fake $\_SERVER Variables in Laravel Feature Tests](https://recca0120.hashnode.dev/laravel-testing-mock-server-variables-1-1-1?utm_source=hashnode&utm_medium=feed)

Fake $\_SERVER in Laravel feature tests by passing server vars per-request, or use withServerVariables() to apply them globally for the entire test method.

Mar 8 · 1 min read · recca0120.hashnode.dev  
Updated Apr 20  
Read the article

-   [#laravel](https://hashnode.com/tag/laravel)
-   [#phpunit](https://hashnode.com/tag/phpunit)
-   [#testing](https://hashnode.com/tag/testing)

## Written by

[recca0120](https://hashnode.com/@recca0120)

@recca0120 · Taipei, Taiwan

  
[View profile](https://hashnode.com/@recca0120)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
