0 follower

Final Class Yiisoft\Yii\Testing\FunctionalTester

InheritanceYiisoft\Yii\Testing\FunctionalTester

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string|null $environment null, boolean $debug false, array $defaultMocks = ['Yiisoft\\Session\\SessionInterface' => 'Yiisoft\\Session\\NullSession'] )
$environment string|null
$debug boolean
$defaultMocks array

                public function __construct(
    private readonly ?string $environment = null,
    private readonly bool $debug = false,
    private readonly array $defaultMocks = [
        'Yiisoft\Session\SessionInterface' => 'Yiisoft\Session\NullSession',
    ]
) {
}

            
bootstrapApplication() public method

public void bootstrapApplication ( string|null $projectRootPath null )
$projectRootPath string|null

                public function bootstrapApplication(?string $projectRootPath = null): void
{
    if ($this->application !== null) {
        return;
    }
    if ($projectRootPath === null) {
        $projectRootPath = dirname(__DIR__, 5);
    }
    $this->application = new TestApplicationRunner(
        responseGrabber: new ResponseGrabber(),
        rootPath: $projectRootPath,
        debug: $this->debug,
        checkEvents: false,
        environment: $this->environment,
    );
    $this->application->addProviders([$this->getMockServiceProvider()]);
}

            
doRequest() public method

public Yiisoft\Yii\Testing\ResponseAccessor doRequest ( string $method, string $url, array $queryParams = [], array $postParams = [], mixed $body null, array $headers = [] )
$method string
$url string
$queryParams array
$postParams array
$body mixed
$headers array

                public function doRequest(
    string $method,
    string $url,
    array $queryParams = [],
    array $postParams = [],
    mixed $body = null,
    array $headers = [],
): ResponseAccessor {
    $this->ensureApplicationLoaded();
    $this->application?->withRequest($method, $url, $queryParams, $postParams, $body, $headers);
    $this->application?->run();
    return $this->application?->responseGrabber?->getResponse() ?? throw new RuntimeException(
        'Either $application or $response is null'
    );
}

            
getContainer() public method

public \Psr\Container\ContainerInterface getContainer ( )

                public function getContainer(): ContainerInterface
{
    $this->ensureApplicationLoaded();
    $this->application?->preloadContainer();
    return $this->application->container ?? throw new Exception('Container was not set.');
}

            
mockService() public method

public void mockService ( string $id, mixed $definition )
$id string
$definition mixed

                public function mockService(string $id, mixed $definition): void
{
    $this->getMockServiceProvider()->setDefinition($id, $definition);
}