public function testGamerinstance() { $gamerInstance = new Eventcounter(); $gamerInst = new Gamerinstance(); $gamerInstanceGet = $gamerInstance->setGamerInstance($gamerInst)->getGamerInstance(); $this->assertTrue($gamerInst == $gamerInstanceGet); }
/** * 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); } } }