Closed
Description
Symfony version(s) affected: v4.1.9
Description
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.