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 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; }
public function testAddHug() { // Note: The ::class syntax is PHP 5.5. You can also specify the full class // name as a string literal. $state = $this->prophesize(StateInterface::class); $state->set('hugs.last_recipient', 'Dries')->shouldBeCalled(); $tracker = new HugTracker($state->reveal()); $tracker->addHug('Dries'); }