You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing unit tests on classes that use Security as dependency get the "Class "Symfony\Component\Security\Core\Security" is declared "final" and cannot be mocked." warning.
How to reproduce
class A
{
/** @var Security */
private $security;
public function __construct(Security $security)
{
$this->security = $security;
}
}
class ATest
{
/** @var Security|ObjectProphecy */
private $security;
public function setUp()
{
$this->security = $this->prophesize(Security::class);
}
}
Run the test.
Possible Solution
Remove final? Or somehow when mocking the class mark the original class as not final.