Files
yii3-app/tests/Support/FunctionalTester.php
Sergei Predvoditelev 1d655bd18a Refactor tests (#384)
2025-08-19 07:47:00 +03:00

55 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Support;
use App\Environment;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Yiisoft\Yii\Runner\Http\HttpApplicationRunner;
use function dirname;
/**
* Inherited Methods
*
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause($vars = [])
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
public function sendRequest(ServerRequestInterface $request): ResponseInterface
{
$runner = new HttpApplicationRunner(
rootPath: dirname(__DIR__, 2),
environment: Environment::appEnv(),
);
$response = $runner->runAndGetResponse($request);
$body = $response->getBody();
if ($body->isSeekable()) {
$body->rewind();
}
return $response;
}
}