From bfeb5a6e0f44dad1f2fe7cbde0b061036f829b54 Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Sat, 6 Apr 2024 13:54:46 +0200 Subject: [PATCH] Fix docs testing --- docs/testing.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/testing.md b/docs/testing.md index bacb6625..3003c1c0 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -83,7 +83,8 @@ $request = $request->withQueryParams($params); ### Add BasicAuth to the request ```php -$request = $this->withHttpBasicAuth($request); +$credentials = base64_encode('username:password'); +$request = $request->withHeader('Authorization', sprintf('Basic %s', $credentials)); ``` ### Invoking a request @@ -110,13 +111,15 @@ $this->assertJsonContentType($response); Asserting JSON response data: ```php -$this->assertJsonData($response, [ +$expected = [ 'user_id' => 1, 'username' => 'admin', 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'john.doe@example.com', -]); +]; + +$this->assertJsonData($expected, $response); ``` You can find more examples in: `tests/TestCase/Action/`