Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Issue #2912 - Fix for LicenseTag generation #3250

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+28 −0
Split
@@ -25,6 +25,22 @@ class LicenseTag extends Tag
*/
protected $url = null;
+ /**
+ * @param array $options
+ */
+ public function __construct(array $options = array())
+ {
+ parent::__construct($options);
+
+ if (isset($options['url'])) {
+ $this->setUrl($options['url']);
+ }
+
+ if(empty($this->name)) {
+ $this->setName('license');
+ }
+ }
+
/**
* fromReflection()
*
@@ -71,6 +87,9 @@ public function getUrl()
*/
public function generate()
{
+ $output = '@' . $this->name
+ . (($this->url != null) ? ' ' . $this->url : '')
+ . (($this->description != null) ? ' ' . $this->description : '');
return $output;
}
@@ -11,6 +11,7 @@
namespace ZendTest\Code\Generator;
use Zend\Code\Generator\DocBlock\Tag;
+use Zend\Code\Generator\DocBlock\Tag\LicenseTag;
/**
* @category Zend
@@ -47,6 +48,14 @@ public function testCanPassDescriptionToConstructor()
$this->assertEquals('Foo', $tag->getDescription());
}
+ public function testCanGenerateLicenseTag()
+ {
+ $tag = new LicenseTag(array('url' => 'http://test.license.com',
+ 'description' => 'Test License'));
+ $this->assertEquals('@license http://test.license.com Test License',
+ $tag->generate());
+ }
+
public function testNameGetterAndSetterPersistValue()
{
$this->tag->setName('Foo');