/** * test add, 등록된 target_id 를 등록 * * @return void */ public function testAddExistsSession() { $session = $this->session; $counter = new SessionCounter($session); $counter->init('id-session', 'default'); // add to not exists session $session->shouldReceive('get')->andReturn(['id-session' => ['targetId']]); $session->shouldReceive('set'); $counter->add('targetId'); }
/** * add counter log * * @param string $targetId targetId * @param MemberEntityInterface $author user instance * @param int $point point * @return void * @throws Exceptions\LoginRequiredException */ public function add($targetId, MemberEntityInterface $author = null, $point = 1) { $author = $this->getUser($author); if ($this->invoked($targetId, $author) === true) { throw new Exceptions\InvokedException(); } if ($this->isSession() === true && $author instanceof Guest) { $this->session->add($targetId); $ip = $this->request->ip(); $this->repo->insert($this->name, $this->option, $targetId, '', $ip, $point); } if ($author->getId() != '') { $ip = $this->request->ip(); $this->repo->insert($this->name, $this->option, $targetId, $author->getId(), $ip, $point); } }