Skip to content

Commit

Permalink
fix: revert some changes that broke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jan 24, 2024
1 parent c0b8f5d commit 6dfebf3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Expand Up @@ -12,7 +12,7 @@ parameters:
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
# All Yii setters accept `null` but their phpdoc is incorrect.
- message: '~^Parameter #1 \$value of method yii\\web\\Request::set(.*)\(\) expects (.*), null given.$~'
- message: '~^Parameter #1 \$(.+) of method yii\\web\\Request::set(.+)\(\) expects (.+), null given.$~'
path: 'src/'
- message: '~^Variable \$_COOKIE in isset\(\) always exists and is not nullable.$~'
path: 'src/'
Expand Down
4 changes: 2 additions & 2 deletions src/Codeception/Lib/Connector/Yii2.php
Expand Up @@ -329,9 +329,9 @@ public function doRequest(object $request): \Symfony\Component\BrowserKit\Respon
$yiiRequest = $app->getRequest();
if ($request->getContent() !== null) {
$yiiRequest->setRawBody($request->getContent());
$yiiRequest->setBodyParams([]);
$yiiRequest->setBodyParams(null);
} else {
$yiiRequest->setRawBody('');
$yiiRequest->setRawBody(null);
$yiiRequest->setBodyParams($_POST);
}
$yiiRequest->setQueryParams($_GET);
Expand Down
34 changes: 1 addition & 33 deletions src/Codeception/Module/Yii2.php
Expand Up @@ -690,36 +690,6 @@ public function amOnRoute(string $route, array $params = []): void
$this->amOnPage(Url::to($params));
}

/**
* Opens the page for the given relative URI or route.
*
* ``` php
* <?php
* // opens front page
* $I->amOnPage('/');
* // opens /register page
* $I->amOnPage('/register');
* ```
*
* @param string $page the page URI
*/
public function amOnPage(string $page): void
{
parent::amOnPage($page);
}

/**
* To support to use the behavior of urlManager component
* for the methods like this: amOnPage(), sendAjaxRequest() and etc.
* @param array $parameters
* @param array $files
* @param array $server
*/
protected function clientRequest(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true): SymfonyCrawler
{
return parent::clientRequest($method, \Yii::$app->urlManager->createUrl($uri), $parameters, $files, $server, $content, $changeHistory);
}

/**
* Gets a component from the Yii container. Throws an exception if the
* component is not available
Expand All @@ -729,12 +699,10 @@ protected function clientRequest(string $method, string $uri, array $parameters
* $mailer = $I->grabComponent('mailer');
* ```
*
* @param $component
* @return mixed
* @throws \Codeception\Exception\ModuleException
* @deprecated in your tests you can use \Yii::$app directly.
*/
public function grabComponent(mixed $component)
public function grabComponent(string $component): null|object
{
try {
return $this->getClient()->getComponent($component);
Expand Down

0 comments on commit 6dfebf3

Please sign in to comment.