addRecommender() 공개 메소드

public addRecommender ( Developer $developer )
$developer Developer
예제 #1
0
 public function testGlobalScore()
 {
     $dispatcher = new EventDispatcher();
     $testers = array('Activity', 'Composer', 'Followers', 'KnpBundles', 'Readme', 'Travis');
     foreach ($testers as $testerClass) {
         $fqcn = sprintf('\\Knp\\Bundle\\KnpBundlesBundle\\EventListener\\Scoring\\%sListener', $testerClass);
         $tester = new $fqcn();
         $dispatcher->addListener(BundleEvent::UPDATE_SCORE, array($tester, 'onScoreUpdate'));
     }
     $bundle = new Bundle();
     // activity (+4)
     $bundle->setLastCommitAt(new \DateTime('-10days'));
     // composer (+5)
     $bundle->setComposerName('bundle-composer-name');
     // followers (+10)
     $bundle->setNbFollowers(10);
     // recommendation (+5)
     $bundle->addRecommender(new Developer());
     // readme (+5)
     $bundle->setReadme(str_repeat('-', 500));
     // travis (+10)
     $bundle->setUsesTravisCi(true);
     $bundle->setTravisCiBuildStatus(true);
     $dispatcher->dispatch(BundleEvent::UPDATE_SCORE, new BundleEvent($bundle));
     $bundle->recalculateScore();
     $this->assertEquals(39, $bundle->getScore());
 }
예제 #2
0
 public function testRecommandationsScoreUpdate()
 {
     $bundle = new Bundle();
     for ($index = 0; $index < 5; ++$index) {
         $user = new Developer();
         $user->setName('Contributor #' . ($index + 1));
         $bundle->addRecommender($user);
     }
     $tester = new KnpBundlesListener();
     $tester->updateScore($bundle);
     $bundle->recalculateScore();
     $this->assertEquals(25, $bundle->getScore());
 }