public function testGetSetChanges() { $fixes = ['#1', '#2', '#3']; $changes = ['fixed' => $fixes, 'added' => ['Super awesome feature']]; $this->release->setAllChanges($changes); $this->assertEquals($changes, $this->release->getAllChanges()); $this->assertEquals($fixes, $this->release->getChanges('fixed')); $this->assertNull($this->release->getChanges('foobar')); $this->release->addChange('fixed', '#4'); $this->assertEquals(array_merge($fixes, ['#4']), $this->release->getChanges('fixed')); $this->release->addChange('new', 'foobar'); $this->assertEquals(['foobar'], $this->release->getChanges('new')); $newFixes = ['a']; $this->release->setChanges('fixed', $newFixes); $this->assertEquals($newFixes, $this->release->getChanges('fixed')); }
/** * @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()]; }
/** * Adds the release's changes to the given xml release node. * * @param SimpleXMLElement $releaseNode * @param Release $release */ protected function addChanges(SimpleXMLElement $releaseNode, Release $release) { $changesNode = $releaseNode->addChild('changes'); foreach ($release->getAllChanges() as $type => $changes) { $typeNode = $changesNode->addChild('type'); $typeNode->addAttribute('name', $type); foreach ($changes as $change) { $typeNode->addChild('change', $change); } } }