setReadme() public méthode

Set readme
public setReadme ( string $readme )
$readme string
 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());
 }
    public function testCalculatedScore()
    {
        $bundleWithShortReadme = new Bundle();
        $bundleWithShortReadme->setReadme('This is a very short (and quite useless) readme');
        $bundle = new Bundle();
        $bundle->setReadme(<<<README
# KnpBundles

Open-source code of the [knpbundles.com](http://knpbundles.com)
website, written in Symfony2.

Any ideas are welcome!

[![Build Status](https://secure.travis-ci.org/KnpLabs/KnpBundles.png)](http://travis-ci.org/KnpLabs/KnpBundles)

Please note that this service was previously called Symfony2Bundles but we had
to change the name due to [trademark issues](http://knplabs.com/blog/symfony2bundles-becomes-knpbundle).
README
);
        $tester = new ReadmeListener();
        $tester->updateScore($bundleWithShortReadme);
        $bundleWithShortReadme->recalculateScore();
        $tester->updateScore($bundle);
        $bundle->recalculateScore();
        $this->assertEquals(0, $bundleWithShortReadme->getScore());
        $this->assertEquals(5, $bundle->getScore());
    }
Exemple #3
0
 /**
  * @test
  */
 public function shouldNotHaveChangesWithOnlyChangedScore()
 {
     $bundle = new Bundle('knplabs/KnpMenuBundle');
     $bundle->setScore(1000);
     $bundle->setReadme('readme number one');
     $bundle->setLastCommitAt(new \DateTime('-10 day'));
     $bundle->setNbFollowers(100);
     $bundle->setNbForks(10);
     $beforeChange = $bundle->getStatusHash();
     $bundle->setScore(1100);
     $afterChange = $bundle->getStatusHash();
     $this->assertEquals($beforeChange, $afterChange);
 }