Skip to content
Draft
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"php": "^8.0",
"phpunit/phpunit": "^9.6 || ^10.0 || ^11.0 || ^12.0",
"symfony/browser-kit": "^5.4 || ^6.4 || ^7.0 || ^8.0",
"symfony/deprecation-contracts": "^2.0 || ^3.0",
"symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0 || ^8.0"
},
"require-dev": {
Expand Down
48 changes: 30 additions & 18 deletions src/Test/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ public function __set($name, $value): void
throw new \Exception(\sprintf('There is no property with name "%s"', $name));
}

@trigger_error('Setting "environment" property is deprecated, please use static::$env.', \E_USER_DEPRECATED);
trigger_deprecation(
'liip/functional-test-bundle',
'4.5.1',
'Setting "environment" property is deprecated, please use static::$env.',
);

static::$env = $value;
}
Expand All @@ -293,7 +297,11 @@ public function __isset($name)
throw new \Exception(\sprintf('There is no property with name "%s"', $name));
}

@trigger_error('Checking "environment" property is deprecated, please use static::$env.', \E_USER_DEPRECATED);
trigger_deprecation(
'liip/functional-test-bundle',
'4.5.1',
'Checking "environment" property is deprecated, please use static::$env.',
);

return true;
}
Expand All @@ -307,7 +315,11 @@ public function __get($name)
throw new \Exception(\sprintf('There is no property with name "%s"', $name));
}

@trigger_error('Getting "environment" property is deprecated, please use static::$env.', \E_USER_DEPRECATED);
trigger_deprecation(
'liip/functional-test-bundle',
'4.5.1',
'Getting "environment" property is deprecated, please use static::$env.',
);

return static::$env;
}
Expand Down Expand Up @@ -465,7 +477,11 @@ public function fetchCrawler(string $path, string $method = 'GET', bool $authent
*/
public function loginAs(UserInterface $user, string $firewallName): self
{
@trigger_error(\sprintf('"%s()" is deprecated, use loginClient() after creating a client.', __METHOD__), \E_USER_DEPRECATED);
trigger_deprecation(
'liip/functional-test-bundle',
'4.2.0',
'"loginAs()" is deprecated, use "loginClient()" after creating a client.',
);

$this->firewallLogins[$firewallName] = $user;

Expand All @@ -479,13 +495,11 @@ public function loginClient(KernelBrowser $client, UserInterface $user, string $
{
// Available since Symfony 5.1
if (method_exists($client, 'loginUser')) {
@trigger_error(
\sprintf(
'"%s()" is deprecated, use loginUser() from Symfony 5.1+ instead %s',
__METHOD__,
'https://symfony.com/doc/5.4/testing.html#logging-in-users-authentication'
),
\E_USER_DEPRECATED
trigger_deprecation(
'liip/functional-test-bundle',
'4.7.0',
'"loginClient()" is deprecated, use "loginUser()" from Symfony 5.1+ instead %s',
'https://symfony.com/doc/5.1/testing.html#logging-in-users-authentication'
);

$client->loginUser($user);
Expand Down Expand Up @@ -586,13 +600,11 @@ protected function createClientWithParams(array $params, ?string $username = nul

// Available since Symfony 5.1
if (method_exists($client, 'loginUser')) {
@trigger_error(
\sprintf(
'"%s()" is deprecated, use loginUser() from Symfony 5.1+ instead %s',
__METHOD__,
'https://symfony.com/doc/5.4/testing.html#logging-in-users-authentication'
),
\E_USER_DEPRECATED
trigger_deprecation(
Copy link
Collaborator Author

@alexislefebvre alexislefebvre Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is called by other methods:

Deprecated the following methods, use [loginUser() from Symfony 5.1+](https://symfony.com/doc/5.4/testing.html#logging-in-users-authentication) instead of:
- `makeClient`
- `makeAuthenticatedClient`
- `makeClientWithCredentials`
- `loginAs`
- `loginClient`
- `createClientWithParams`

I’m not sure that __METHOD__ returned this method or the method that called it.

TODO: check it. And if necessary, add deprecations to the caller methods.

'liip/functional-test-bundle',
'4.7.0',
'"createClientWithParams()" is deprecated, use "loginUser()" from Symfony 5.1+ instead %s',
'https://symfony.com/doc/5.1/testing.html#logging-in-users-authentication'
);

$client->loginUser($user);
Expand Down