Skip to content

Commit

Permalink
Test that HttpFaker opens http scope on request
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Sep 13, 2024
1 parent 1e0e224 commit b37e6b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/app/Controller/GetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Spiral\Testing\Tests\App\Controller;

use Psr\Http\Message\ServerRequestInterface;
use Spiral\Core\Internal\Introspector;
use Spiral\Router\Annotation\Route;

class GetController
Expand All @@ -20,4 +21,10 @@ public function headers(ServerRequestInterface $request): array
{
return $request->getHeaders();
}

#[Route('/get/scopes', 'get.scopes')]
public function scopes(ServerRequestInterface $request): array
{
return Introspector::scopeNames();
}
}
13 changes: 13 additions & 0 deletions tests/src/Http/FakeHttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ public function testGetBodySame(): void
$response->assertBodySame('[]');
}

#[TestScope('http')]
public function testHttpScopeDoesNotConflict(): void
{
$response = $this->fakeHttp()->get('/get/query-params');
$response->assertBodySame('[]');
}

public function testAutoHttpScope(): void
{
$response = $this->fakeHttp()->get('/get/scopes');
$response->assertBodySame('["http-request","http","root"]');
}

public function testGetWithQueryParams(): void
{
$response = $this->fakeHttp()->get('/get/query-params', ['foo' => 'bar', 'baz' => ['foo1' => 'bar1']]);
Expand Down

0 comments on commit b37e6b4

Please sign in to comment.