I am starting out with PHPUnit in a small project of mine, and the very first test I'd like to write is the one that hits an index.php script (or very soon, a route endpoint) and examines the response. In particular, I'd like to assert that the response body (i.e. HTML) contains a string, such as 'Hello World'. For such as trivial task,
- How do I instruct PHPUnit to make a GET request to a script/route?
- Does PHPUnit offer any facilities to perform HTTP tests?
- Do I have no choice but to use something like Guzzle?
Note, I do not want to mock the response (or the request for that matter). I want to perform an actual HTTP request and get an actual response from the server. Also,
- Would I need to instruct PHPUnit (through phpunit.xml?) to bootstrap my application behind the scenes before making any requests?
PHPUnit newbie here, sorry for the very basic question. Any help'd be appreciated!
Aucun commentaire:
Enregistrer un commentaire