Skip to content
This repository
Browse code

Merge branch 'hotfix/3250' into develop

Forward port #3250
  • Loading branch information...
commit bcc6a91756429ef083386deaeac393fcb2080a33 2 parents eacf415 + 2912c1a
Matthew Weier O'Phinney weierophinney authored
21 library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php
@@ -19,13 +19,28 @@
19 19 */
20 20 class LicenseTag extends Tag
21 21 {
22   -
23 22 /**
24 23 * @var string
25 24 */
26 25 protected $url = null;
27 26
28 27 /**
  28 + * @param array $options
  29 + */
  30 + public function __construct(array $options = array())
  31 + {
  32 + parent::__construct($options);
  33 +
  34 + if (isset($options['url'])) {
  35 + $this->setUrl($options['url']);
  36 + }
  37 +
  38 + if (empty($this->name)) {
  39 + $this->setName('license');
  40 + }
  41 + }
  42 +
  43 + /**
29 44 * fromReflection()
30 45 *
31 46 * @param ReflectionDocBlockTag $reflectionTagLicense
@@ -71,7 +86,9 @@ public function getUrl()
71 86 */
72 87 public function generate()
73 88 {
  89 + $output = '@' . $this->name
  90 + . (($this->url !== null) ? ' ' . $this->url : '')
  91 + . (($this->description !== null) ? ' ' . $this->description : '');
74 92 return $output;
75 93 }
76   -
77 94 }
13 tests/ZendTest/Code/Generator/DocBlockTagGeneratorTest.php
@@ -11,6 +11,7 @@
11 11 namespace ZendTest\Code\Generator;
12 12
13 13 use Zend\Code\Generator\DocBlock\Tag;
  14 +use Zend\Code\Generator\DocBlock\Tag\LicenseTag;
14 15
15 16 /**
16 17 * @category Zend
@@ -47,6 +48,18 @@ public function testCanPassDescriptionToConstructor()
47 48 $this->assertEquals('Foo', $tag->getDescription());
48 49 }
49 50
  51 + public function testCanGenerateLicenseTag()
  52 + {
  53 + $tag = new LicenseTag(array(
  54 + 'url' => 'http://test.license.com',
  55 + 'description' => 'Test License',
  56 + ));
  57 + $this->assertEquals(
  58 + '@license http://test.license.com Test License',
  59 + $tag->generate()
  60 + );
  61 + }
  62 +
50 63 public function testNameGetterAndSetterPersistValue()
51 64 {
52 65 $this->tag->setName('Foo');

0 comments on commit bcc6a91

Please sign in to comment.
Something went wrong with that request. Please try again.