I am attempting to test the following Symfony 3.4 CLI command class with PHPUnit 7.
class SubscribeUsers extends ContainerAwareCommand
{
use LoggerTrait;
use DalcioTrait;
I have a bunch of traits, with this typical format:
DalcioTrait.php
trait DalcioTrait
{
/**
* @var Dalcio
*/
protected $dalcio;
/**
* @required
* @param Dalcio $dalcio
*/
public function setDalcio(Dalcio $dalcio)
{
$this->dalcio = $dalcio;
}
/**
* @return Dalcio
*/
public function getDalcio(): Dalcio
{
return $this->dalcio;
}
}
In my test I have the following:
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName()]);
and that is where it falls over because where I call $this->getLogger()
or $this->getDalcio()
in SubscribeUsers
it falls over because they are both NULL
.
I am using the Symfony 3.4 @required
annotation because I am now using autowired services and no longer explicitly calling setters in my service definitions.
Is there any way to have PHPUnit 7 recognise these annotations?