public function testEvent() { $eventlog = new Eventlog(); $event = new Event(); $eventGet = $eventlog->setEvent($event)->getEvent(); $this->assertTrue($event == $eventGet); }
/** * The method registers events in the database. * In case the person for whom the event to be registered exists, the function * creates a new entry in the db and increments the counter. * If the object exists, the method increments a counter. * * @param integer $eventCategoryId * @param integer $gamerIdentity * @param integer $gamerTypeId */ public function register($eventCategoryId, $gamerIdentity, $gamerTypeId) { $gamerInstance = $this->gamerInstanceModel->getInstance($gamerIdentity, $gamerTypeId); if ($gamerInstance) { $event = $this->eventModel->findOneById($eventCategoryId); $eventLogEntity = new Eventlog(); $eventLogEntity->setEvent($event)->setGamerInstance($gamerInstance)->setDate(new \DateTime('NOW')); $this->eventLogModel->create($eventLogEntity, true); try { $eventCounterEntity = $this->eventCounterModel->findOneBy(['gamerinstance' => $gamerInstance, 'event' => $event]); $eventCounterEntity->setCounter($eventCounterEntity->getCounter() + 1); $this->eventCounterModel->update($eventCounterEntity, true); } catch (\Exception $e) { $eventCounterEntity = new Eventcounter(); $eventCounterEntity->setEvent($event); $eventCounterEntity->setGamerInstance($gamerInstance); $eventCounterEntity->setCounter($eventCounterEntity->getCounter() + 1); $this->eventCounterModel->update($eventCounterEntity, true); } } }