/** * Returns either an existing aggregate-bucket for a given user+month combination - or creates * a new one to which the commits can be added later on. * * @param \Mrimann\CoMo\Domain\Model\Commit $commit * @return \Mrimann\CoMo\Domain\Model\AggregatedDataPerUser|object */ public function findByCommitterAndMonth(\Mrimann\CoMo\Domain\Model\Commit $commit) { $this->initializeOurSettings(); if ($this->settings['whoGetsCredits'] == 'committer') { $email = $commit->getCommitterEmail(); $name = $commit->getCommitterName(); } else { $email = $commit->getAuthorEmail(); $name = $commit->getAuthorName(); } $query = $this->createQuery(); $query->matching($query->logicalAnd($query->equals('month', $commit->getMonthIdentifier()), $query->equals('userEmail', $email))); $query->setLimit(1); $result = $query->execute(); if ($result->count()) { $result = $result->getFirst(); } else { $result = new \Mrimann\CoMo\Domain\Model\AggregatedDataPerUser(); $result->setMonth($commit->getMonthIdentifier()); $result->setUserEmail($email); $result->setUserName($name); $this->add($result); $this->persistenceManager->persistAll(); } return $result; }
/** * @test */ public function setCommitterEmailSetsCommitterEmail() { $this->fixture->setCommitterEmail('*****@*****.**'); $this->assertEquals($this->fixture->getCommitterEmail(), '*****@*****.**'); }