setComposerName() public method

Set Composer name
public setComposerName ( $name )
Exemplo n.º 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());
 }
Exemplo n.º 2
0
 public function testComposerScoreDetail()
 {
     $bundle = new Bundle();
     $bundle->setComposerName(null);
     $tester = new ComposerListener();
     $tester->updateScore($bundle);
     $bundle->recalculateScore();
     $this->assertEquals(0, $bundle->getScore());
     $bundle->setComposerName('composer-name-bundle');
     $tester->updateScore($bundle);
     $bundle->recalculateScore();
     $this->assertEquals(5, $bundle->getScore());
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function shouldNotUpdateVersionsHistoryWithWrongData()
 {
     $json = 'I am wrong json';
     $bundle = new Bundle('KnpLabs/KnpMenuBundle');
     $bundle->setComposerName('knplabs/knp-menu-bundle');
     $httpClient = $this->getMockBuilder('Github\\HttpClient\\HttpClient')->setMethods(array('get'))->disableOriginalConstructor()->getMock();
     $httpClient->expects($this->once())->method('get')->will($this->returnValue($json));
     $githubRepo = $this->getRepo($httpClient);
     $githubRepo->updateVersionsHistory($bundle);
     $this->assertNull($bundle->getVersionsHistory());
 }
Exemplo n.º 4
0
 /**
  * @param string $composer
  * @param Bundle $bundle
  */
 private function updateComposerFile($composer, Bundle $bundle)
 {
     $composer = json_decode($composer, true);
     if (JSON_ERROR_NONE !== json_last_error()) {
         return;
     }
     if (isset($composer['name'])) {
         $bundle->setComposerName($composer['name']);
     }
     if (isset($composer['license'])) {
         $bundle->setLicenseType(is_array($composer['license']) ? implode(', ', $composer['license']) : $composer['license']);
     }
 }
Exemplo n.º 5
0
 private function updateComposerFile($gitRepo, Entity\Bundle $bundle)
 {
     $composerFilename = 'composer.json';
     $composerName = null;
     if ($gitRepo->hasFile($composerFilename)) {
         $composer = json_decode($gitRepo->getFileContent($composerFilename));
         $composerName = isset($composer->name) ? $composer->name : null;
     }
     $bundle->setComposerName($composerName);
 }