public function testRenderLink() { $log = new Log(); $log->setTitle('Change log'); $log->setDescription('My change log'); $release1 = new Release('1.0.0'); $release1->setLink('http://fuelphp.com'); $log->addRelease($release1); $release1 = new Release('0.1.0'); $release1->setLink('http://google.com'); $release1->setLinkName('a'); $log->addRelease($release1); $expected = <<<'EXPECTED' # Change log My change log ## [1.0.0] ## [0.1.0][a] [1.0.0] http://fuelphp.com [a] http://google.com EXPECTED; $result = $this->renderer->render($log); $this->assertEquals($expected, $result); }
/** * @param Release $release * * @return array */ protected function renderRelease(Release $release) { $date = null; if ($release->getDate() !== null) { $date = $release->getDate()->format('Y-m-d'); } return ['name' => $release->getName(), 'link' => $release->getLink(), 'linkName' => $release->getLinkName(), 'date' => $date, 'changes' => $release->getAllChanges()]; }
public function testMerge() { $thisRelease1 = new Release('1.0.0'); $thisRelease1->setAllChanges(['Added' => ['Added 1', 'Added 2'], 'Changed' => ['Changed 1']]); $this->log->addRelease($thisRelease1); $thisRelease1 = new Release('2.0.0'); $this->log->addRelease($thisRelease1); $otherLog = new Log(); $thisRelease3 = new Release('1.0.0'); $thisRelease3->setAllChanges(['Added' => ['Added 3', 'Added 4'], 'Removed' => ['Removed 1']]); $otherLog->addRelease($thisRelease3); $thisRelease4 = new Release('3.0.0'); $otherLog->addRelease($thisRelease4); $this->log->mergeLog($otherLog); $this->assertTrue($this->log->hasRelease('1.0.0')); $this->assertTrue($this->log->hasRelease('2.0.0')); $this->assertTrue($this->log->hasRelease('3.0.0')); $mergedRelease = $this->log->getRelease('1.0.0'); $this->assertEquals(['Added' => ['Added 1', 'Added 2', 'Added 3', 'Added 4'], 'Changed' => ['Changed 1'], 'Removed' => ['Removed 1']], $mergedRelease->getAllChanges()); }
/** * @param SimpleXMLElement $releases * @param Release $release */ protected function renderRelease($releases, $release) { $releaseNode = $releases->addChild('release'); $releaseNode->addChild('name', $release->getName()); $releaseNode->addChild('link', $release->getLink()); if ($release->getLinkName() !== null) { $releaseNode->addChild('linkName', $release->getLinkName()); } if ($release->getDate() !== null) { $releaseNode->addChild('date', $release->getDate()->format('Y-m-d')); } $this->addChanges($releaseNode, $release); }
public function testRender() { $log = new Log(); $log->setTitle('Change Log'); $log->setDescription('A log for changes!'); $release1 = new Release('1.0.0'); $release1->setLink('http://fuelphp.com'); $release1->setAllChanges(['Fixed' => ['fixed 1', 'fixed 2'], 'Changed' => ['changed 1']]); $release1->setDate(DateTime::createFromFormat('Y-m-d', '2015-01-29')); $log->addRelease($release1); $release2 = new Release('0.1.0'); $release2->setLink('http://google.com'); $release2->setLinkName('foobar'); $release2->setDate(DateTime::createFromFormat('Y-m-d', '2015-01-20')); $release2->setAllChanges(['Changed' => ['changed 2']]); $log->addRelease($release2); $result = $this->renderer->render($log); $this->assertJsonStringEqualsJsonFile(__DIR__ . '/../../resources/Parser-Json-testRender.json', $result); }
/** * Extracts and sets the Release name. * * @param Release $release * @param string $line */ protected function setName(Release $release, $line) { $matches = []; if (preg_match('/([\\w\\.-]{1,})/', $line, $matches)) { $release->setName($matches[0]); } }
/** * Adds a release to the Log. * Can be used to replace existing releases too. * * @param Release $release */ public function addRelease(Release $release) { $name = strtolower($release->getName()); $this->releases[$name] = $release; $this->sortReleases(); }
/** * Returns the YANKED tag if needed * * @param Release $release * * @return string */ protected function addYanked(Release $release) { $content = ''; if ($release->isYanked()) { $content = ' [YANKED]'; } return $content; }
public function testGetSetLinkName() { $name = 'abc'; $this->release->setLinkName($name); $this->assertEquals($name, $this->release->getLinkName()); }