References Client
Reference
C
Class

ApiPlatform\Symfony\Bundle\Test\Client

Convenient test client that makes requests to a Kernel object.

class ApiPlatform\Symfony\Bundle\Test\Client implements Symfony\Contracts\HttpClient\HttpClientInterface
{
    public __construct(Symfony\Bundle\FrameworkBundle\KernelBrowser $kernelBrowser, array $defaultOptions)
    public setDefaultOptions(array $defaultOptions): null
    public request(string $method, string $url, array $options): Symfony\Contracts\HttpClient\ResponseInterface
    public stream(Symfony\Contracts\HttpClient\ResponseInterface|Traversable|array $responses, null|float $timeout): Symfony\Contracts\HttpClient\ResponseStreamInterface
    public getResponse(): ApiPlatform\Symfony\Bundle\Test\Response
    public getKernelBrowser(): Symfony\Bundle\FrameworkBundle\KernelBrowser
    public getContainer(): Symfony\Component\DependencyInjection\ContainerInterface
    public getCookieJar(): Symfony\Component\BrowserKit\CookieJar
    public getKernel(): Symfony\Component\HttpKernel\KernelInterface
    public getProfile(): Symfony\Component\HttpKernel\Profiler\Profile|false
    public enableProfiler(): null
    public disableReboot(): null
    public enableReboot(): null
    public loginUser(Symfony\Component\Security\Core\User\UserInterface $user, string $firewallContext): ApiPlatform\Symfony\Bundle\Test\Client
    public withOptions(array $options): static
}

Methods

__construct

public __construct(Symfony\Bundle\FrameworkBundle\KernelBrowser $kernelBrowser, array $defaultOptions)

Parameters

kernelBrowserSymfony\Bundle\FrameworkBundle\KernelBrowser
defaultOptionsarrayDefault options for the requests

See also

  • [HttpClientInterface::OPTIONS_DEFAULTS for available options](HttpClientInterface::OPTIONS_DEFAULTS for available options)

setDefaultOptions

Sets the default options for the requests.

public setDefaultOptions(array $defaultOptions): null

Parameters

defaultOptionsarray

Returns

null

See also

  • [HttpClientInterface::OPTIONS_DEFAULTS for available options](HttpClientInterface::OPTIONS_DEFAULTS for available options)

request

Requests an HTTP resource.Responses MUST be lazy, but their status code MUST be checked even if none of their public methods are called.Implementations are not required to support all options described above; they can also support more custom options; but in any case, they MUST throw a TransportExceptionInterface when an unsupported option is passed.

public request(string $method, string $url, array $options): Symfony\Contracts\HttpClient\ResponseInterface

Parameters

methodstring
urlstring
optionsarray

Returns

Symfony\Contracts\HttpClient\ResponseInterface

stream

Yields responses chunk by chunk as they complete.

public stream(Symfony\Contracts\HttpClient\ResponseInterface|Traversable|array $responses, null|float $timeout): Symfony\Contracts\HttpClient\ResponseStreamInterface

Parameters

responsesSymfony\Contracts\HttpClient\ResponseInterface
Traversable
array
timeoutfloat

Returns

Symfony\Contracts\HttpClient\ResponseStreamInterface

getResponse

Gets the latest response.

Returns

<a href="/docs/main/references/Symfony/Bundle/Test/Response">ApiPlatform\Symfony\Bundle\Test\Response</a>

getKernelBrowser

Gets the underlying test client.

public getKernelBrowser(): Symfony\Bundle\FrameworkBundle\KernelBrowser

Returns

Symfony\Bundle\FrameworkBundle\KernelBrowser

getContainer

Returns the container.

public getContainer(): Symfony\Component\DependencyInjection\ContainerInterface

Returns

Symfony\Component\DependencyInjection\ContainerInterface

getCookieJar

Returns the CookieJar instance.

public getCookieJar(): Symfony\Component\BrowserKit\CookieJar

Returns

Symfony\Component\BrowserKit\CookieJar

getKernel

Returns the kernel.

public getKernel(): Symfony\Component\HttpKernel\KernelInterface

Returns

Symfony\Component\HttpKernel\KernelInterface

getProfile

Gets the profile associated with the current Response.

public getProfile(): Symfony\Component\HttpKernel\Profiler\Profile|false

Returns

Symfony\Component\HttpKernel\Profiler\Profile
false

enableProfiler

Enables the profiler for the very next request.If the profiler is not enabled, the call to this method does nothing.

public enableProfiler(): null

Returns

null

disableReboot

Disables kernel reboot between requests.By default, the Client reboots the Kernel for each request. This method allows to keep the same kernel across requests.

public disableReboot(): null

Returns

null

enableReboot

Enables kernel reboot between requests.

public enableReboot(): null

Returns

null

loginUser

public loginUser(Symfony\Component\Security\Core\User\UserInterface $user, string $firewallContext): ApiPlatform\Symfony\Bundle\Test\Client

Parameters

userSymfony\Component\Security\Core\User\UserInterface
firewallContextstring

Returns

<a href="/docs/main/references/Symfony/Bundle/Test/Client">ApiPlatform\Symfony\Bundle\Test\Client</a>

withOptions

public withOptions(array $options): static

Parameters

optionsarray

Returns

static

Made with love by

Les-Tilleuls.coop can help you design and develop your APIs and web projects, and train your teams in API Platform, Symfony, Next.js, Kubernetes and a wide range of other technologies.

Learn more

Copyright © 2023 Kévin Dunglas

Sponsored by Les-Tilleuls.coop