public function build() { if ($this->configuration['enabled']) { $message = $this->t('@to was the last person hugged', ['@to' => $this->hugTracker->getLastRecipient()]); } else { $message = $this->t('No hugs :-('); } return ['#markup' => $message]; }
public function testGetLastRecipient() { $state = $this->prophesize(StateInterface::class); $state->get('hugs.last_recipient')->willReturn('Dries'); $tracker = new HugTracker($state->reveal()); $this->assertEquals('Dries', $tracker->getLastRecipient()); }