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()); }
public function hug($to, $from, $count) { $this->hugTracker->addHug($to); if (!$count) { $count = $this->config('hugs.settings')->get('default_count'); } return ['#theme' => 'hug_page', '#from' => $from, '#to' => $to, '#count' => $count]; }
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 hug($to, $from, $count) { // implement the hug tracker $this->hugTracker->addHug($to); // check for default count and return the hug page if (!$count) { $count = $this->config('hugs.settings')->get('default_count'); } // build the return array $return = ['#theme' => 'hug_page', '#from' => $from, '#to' => $to, '#count' => $count]; return $return; }