Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/Codeception/Module/Symfony/BrowserAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Codeception\Module\Symfony;

use Codeception\Lib\InnerBrowser;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\Constraint\LogicalAnd;
use PHPUnit\Framework\Constraint\LogicalNot;
Expand Down Expand Up @@ -319,7 +320,13 @@ public function seePageIsAvailable(?string $url = null): void
{
if ($url !== null) {
$client = $this->getClient();
$client->request('GET', $url);

if ($this instanceof InnerBrowser) {
$this->amOnPage($url);
} else {
$client->request('GET', $url);
}

$this->assertStringContainsString($url, $client->getRequest()->getRequestUri());
}

Expand All @@ -338,7 +345,12 @@ public function seePageRedirectsTo(string $page, string $redirectsTo): void
{
$client = $this->getClient();
$client->followRedirects(false);
$client->request('GET', $page);

if ($this instanceof InnerBrowser) {
$this->amOnPage($page);
} else {
$client->request('GET', $page);
}

$this->assertThatForResponse(new ResponseIsRedirected(), 'The response is not a redirection.');

Expand All @@ -365,14 +377,20 @@ public function seePageRedirectsTo(string $page, string $redirectsTo): void
*/
public function submitSymfonyForm(string $name, array $fields): void
{
$client = $this->getClient();
$selector = sprintf('form[name=%s]', $name);

$params = [];
foreach ($fields as $key => $value) {
$params[$name . $key] = $value;
}

$client = $this->getClient();
if ($this instanceof InnerBrowser) {
$this->submitForm($selector, $params, sprintf('%s_submit', $name));

return;
}

$node = $client->getCrawler()->filter($selector);
$this->assertGreaterThan(0, $node->count(), sprintf('Form "%s" not found.', $selector));
$form = $node->form();
Expand Down
12 changes: 11 additions & 1 deletion src/Codeception/Module/Symfony/RouterAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Codeception\Module\Symfony;

use Codeception\Lib\InnerBrowser;
use PHPUnit\Framework\Assert;
use Stringable;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -161,7 +162,16 @@ private function assertRouteExists(string $routeName): void
/** @param array<string, scalar|Stringable|array<mixed>|null> $params */
private function openRoute(string $routeName, array $params = []): void
{
$this->getClient()->request('GET', $this->grabRouterService()->generate($routeName, $params));
$client = $this->getClient();
$url = $this->grabRouterService()->generate($routeName, $params);

if ($this instanceof InnerBrowser) {
$this->amOnPage($url);

return;
}

$client->request('GET', $url);
}

protected function grabRouterService(): RouterInterface
Expand Down