Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[#3173] Incorrect creating instance Zend/Code/Generator/ClassGenerator.php by fromArray #3213

Closed
wants to merge 4 commits into from

2 participants

@neeckeloo

This is a fix for issue [#3173]. I had fromArray() method into Zend/Code/Generator/DocBlockGenerator class and modify ternary operator. I also fix CS.

tests/ZendTest/Code/Generator/DocBlockGeneratorTest.php
@@ -78,4 +79,22 @@ public function testGenerationOfDocBlock()
$this->assertEquals($expected, $this->docBlockGenerator->generate());
}
+ public function testCreateFormArray()
@weierophinney Owner

s/Form/From/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#3213] renamed test method
- s/Form/From/
0d40a88
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3213' into develop
Forward port #3213

Conflicts:
	library/Zend/Code/Generator/ClassGenerator.php
	tests/ZendTest/Code/Generator/ClassGeneratorTest.php
e43beaa
@weierophinney

@neeckeloo LOL -- I fixed it locally already while merging!

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3213] renamed test method
- s/Form/From/
9511e0d
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3213'
Close #3213
d0eb0af
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3213' into develop
Forward port #3213

Conflicts:
	library/Zend/Code/Generator/ClassGenerator.php
	tests/ZendTest/Code/Generator/ClassGeneratorTest.php
0d21ba8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 12, 2012
  1. @neeckeloo
  2. @neeckeloo

    Add unit tests

    neeckeloo authored
Commits on Dec 13, 2012
  1. @neeckeloo

    Fix PSR2

    neeckeloo authored
  2. @neeckeloo

    Fix method name

    neeckeloo authored
This page is out of date. Refresh to see the latest.
View
145 library/Zend/Code/Generator/ClassGenerator.php
@@ -68,9 +68,9 @@ class ClassGenerator extends AbstractGenerator
protected $methods = array();
/**
- * fromReflection() - build a Code Generation Php Object from a Class Reflection
+ * Build a Code Generation Php Object from a Class Reflection
*
- * @param ClassReflection $classReflection
+ * @param ClassReflection $classReflection
* @return ClassGenerator
*/
public static function fromReflection(ClassReflection $classReflection)
@@ -141,9 +141,8 @@ public static function fromReflection(ClassReflection $classReflection)
* @configkey properties
* @configkey methods
*
- *
* @throws Exception\InvalidArgumentException
- * @param array $array
+ * @param array $array
* @return ClassGenerator
*/
public static function fromArray(array $array)
@@ -151,6 +150,7 @@ public static function fromArray(array $array)
if (!isset($array['name'])) {
throw new Exception\InvalidArgumentException('Class generator requires that a name is provided for this object');
}
+
$cg = new static($array['name']);
foreach ($array as $name => $value) {
// normalize key
@@ -162,7 +162,8 @@ public static function fromArray(array $array)
$cg->setNamespaceName($value);
break;
case 'docblock':
- $cg->setDocBlock((!$value instanceof DocBlockGenerator) ? : DocBlockGenerator::fromArray($value));
+ $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $cg->setDocBlock($docBlock);
break;
case 'flags':
$cg->setFlags($value);
@@ -181,9 +182,20 @@ public static function fromArray(array $array)
break;
}
}
+
return $cg;
}
+ /**
+ * @param string $name
+ * @param string $namespaceName
+ * @param array|string $flags
+ * @param string $extends
+ * @param array $interfaces
+ * @param array $properties
+ * @param array $methods
+ * @param DocBlockGenerator $docBlock
+ */
public function __construct($name = null, $namespaceName = null, $flags = null, $extends = null,
$interfaces = array(), $properties = array(), $methods = array(), $docBlock = null)
{
@@ -214,9 +226,7 @@ public function __construct($name = null, $namespaceName = null, $flags = null,
}
/**
- * setName()
- *
- * @param string $name
+ * @param string $name
* @return ClassGenerator
*/
public function setName($name)
@@ -228,12 +238,11 @@ public function setName($name)
}
$this->name = $name;
+
return $this;
}
/**
- * getName()
- *
* @return string
*/
public function getName()
@@ -242,8 +251,6 @@ public function getName()
}
/**
- * getNamespaceName()
- *
* @return string
*/
public function getNamespaceName()
@@ -252,9 +259,7 @@ public function getNamespaceName()
}
/**
- * setNamespaceName()
- *
- * @param $namespaceName
+ * @param string $namespaceName
* @return ClassGenerator
*/
public function setNamespaceName($namespaceName)
@@ -265,7 +270,7 @@ public function setNamespaceName($namespaceName)
}
/**
- * @param FileGenerator $fileGenerator
+ * @param FileGenerator $fileGenerator
* @return ClassGenerator
*/
public function setContainingFileGenerator(FileGenerator $fileGenerator)
@@ -284,7 +289,7 @@ public function getContainingFileGenerator()
}
/**
- * @param DocBlockGenerator $docBlock
+ * @param DocBlockGenerator $docBlock
* @return ClassGenerator
*/
public function setDocBlock(DocBlockGenerator $docBlock)
@@ -294,10 +299,7 @@ public function setDocBlock(DocBlockGenerator $docBlock)
return $this;
}
-
/**
- * getDocBlock()
- *
* @return DocBlockGenerator
*/
public function getDocBlock()
@@ -305,6 +307,10 @@ public function getDocBlock()
return $this->docBlock;
}
+ /**
+ * @param array|string $flags
+ * @return \Zend\Code\Generator\ClassGenerator
+ */
public function setFlags($flags)
{
if (is_array($flags)) {
@@ -316,25 +322,34 @@ public function setFlags($flags)
}
// check that visibility is one of three
$this->flags = $flags;
+
return $this;
}
+ /**
+ * @param string $flag
+ * @return ClassGenerator
+ */
public function addFlag($flag)
{
$this->setFlags($this->flags | $flag);
+
return $this;
}
+ /**
+ * @param string $flag
+ * @return ClassGenerator
+ */
public function removeFlag($flag)
{
$this->setFlags($this->flags & ~$flag);
+
return $this;
}
/**
- * setAbstract()
- *
- * @param bool $isAbstract
+ * @param bool $isAbstract
* @return AbstractMemberGenerator
*/
public function setAbstract($isAbstract)
@@ -343,19 +358,15 @@ public function setAbstract($isAbstract)
}
/**
- * isAbstract()
- *
* @return bool
*/
public function isAbstract()
{
- return (boolean)($this->flags & self::FLAG_ABSTRACT);
+ return (boolean) ($this->flags & self::FLAG_ABSTRACT);
}
/**
- * setFinal()
- *
- * @param bool $isFinal
+ * @param bool $isFinal
* @return AbstractMemberGenerator
*/
public function setFinal($isFinal)
@@ -364,8 +375,6 @@ public function setFinal($isFinal)
}
/**
- * isFinal()
- *
* @return bool
*/
public function isFinal()
@@ -374,20 +383,17 @@ public function isFinal()
}
/**
- * setExtendedClass()
- *
- * @param string $extendedClass
+ * @param string $extendedClass
* @return ClassGenerator
*/
public function setExtendedClass($extendedClass)
{
$this->extendedClass = $extendedClass;
+
return $this;
}
/**
- * getExtendedClass()
- *
* @return string
*/
public function getExtendedClass()
@@ -396,20 +402,17 @@ public function getExtendedClass()
}
/**
- * setImplementedInterfaces()
- *
- * @param array $implementedInterfaces
+ * @param array $implementedInterfaces
* @return ClassGenerator
*/
public function setImplementedInterfaces(array $implementedInterfaces)
{
$this->implementedInterfaces = $implementedInterfaces;
+
return $this;
}
/**
- * getImplementedInterfaces
- *
* @return array
*/
public function getImplementedInterfaces()
@@ -418,9 +421,7 @@ public function getImplementedInterfaces()
}
/**
- * addProperties()
- *
- * @param array $properties
+ * @param array $properties
* @return ClassGenerator
*/
public function addProperties(array $properties)
@@ -443,9 +444,9 @@ public function addProperties(array $properties)
/**
* Add Property from scalars
*
- * @param string $name
- * @param string|array $defaultValue
- * @param int $flags
+ * @param string $name
+ * @param string|array $defaultValue
+ * @param int $flags
* @throws Exception\InvalidArgumentException
* @return ClassGenerator
*/
@@ -461,9 +462,9 @@ public function addProperty($name, $defaultValue = null, $flags = PropertyGenera
}
/**
- * add property from PropertyGenerator
+ * Add property from PropertyGenerator
*
- * @param string|PropertyGenerator $property
+ * @param string|PropertyGenerator $property
* @throws Exception\InvalidArgumentException
* @return ClassGenerator
*/
@@ -476,12 +477,11 @@ public function addPropertyFromGenerator(PropertyGenerator $property)
}
$this->properties[$propertyName] = $property;
+
return $this;
}
/**
- * getProperties()
- *
* @return PropertyGenerator[]
*/
public function getProperties()
@@ -490,9 +490,7 @@ public function getProperties()
}
/**
- * getProperty()
- *
- * @param string $propertyName
+ * @param string $propertyName
* @return PropertyGenerator|false
*/
public function getProperty($propertyName)
@@ -502,13 +500,12 @@ public function getProperty($propertyName)
return $property;
}
}
+
return false;
}
/**
- * hasProperty()
- *
- * @param string $propertyName
+ * @param string $propertyName
* @return bool
*/
public function hasProperty($propertyName)
@@ -517,9 +514,7 @@ public function hasProperty($propertyName)
}
/**
- * addMethods()
- *
- * @param array $methods
+ * @param array $methods
* @return ClassGenerator
*/
public function addMethods(array $methods)
@@ -535,17 +530,18 @@ public function addMethods(array $methods)
}
}
}
+
return $this;
}
/**
* Add Method from scalars
*
- * @param string $name
- * @param array $parameters
- * @param int $flags
- * @param string $body
- * @param string $docBlock
+ * @param string $name
+ * @param array $parameters
+ * @param int $flags
+ * @param string $body
+ * @param string $docBlock
* @throws Exception\InvalidArgumentException
* @return ClassGenerator
*/
@@ -561,11 +557,10 @@ public function addMethod($name = null, array $parameters = array(), $flags = Me
return $this->addMethodFromGenerator(new MethodGenerator($name, $parameters, $flags, $body, $docBlock));
}
-
/**
* Add Method from MethodGenerator
*
- * @param MethodGenerator $method
+ * @param MethodGenerator $method
* @throws Exception\InvalidArgumentException
* @return ClassGenerator
*/
@@ -578,12 +573,11 @@ public function addMethodFromGenerator(MethodGenerator $method)
}
$this->methods[$methodName] = $method;
+
return $this;
}
/**
- * getMethods()
- *
* @return MethodGenerator[]
*/
public function getMethods()
@@ -592,9 +586,7 @@ public function getMethods()
}
/**
- * getMethod()
- *
- * @param string $methodName
+ * @param string $methodName
* @return MethodGenerator|false
*/
public function getMethod($methodName)
@@ -604,13 +596,12 @@ public function getMethod($methodName)
return $method;
}
}
+
return false;
}
/**
- * hasMethod()
- *
- * @param string $methodName
+ * @param string $methodName
* @return bool
*/
public function hasMethod($methodName)
@@ -619,8 +610,6 @@ public function hasMethod($methodName)
}
/**
- * isSourceDirty()
- *
* @return bool
*/
public function isSourceDirty()
@@ -645,8 +634,6 @@ public function isSourceDirty()
}
/**
- * generate()
- *
* @return string
*/
public function generate()
View
75 library/Zend/Code/Generator/DocBlockGenerator.php
@@ -39,9 +39,9 @@ class DocBlockGenerator extends AbstractGenerator
protected $indentation = '';
/**
- * fromReflection() - Build a DocBlock generator object from a reflection object
+ * Build a DocBlock generator object from a reflection object
*
- * @param DocBlockReflection $reflectionDocBlock
+ * @param DocBlockReflection $reflectionDocBlock
* @return DocBlockGenerator
*/
public static function fromReflection(DocBlockReflection $reflectionDocBlock)
@@ -61,6 +61,43 @@ public static function fromReflection(DocBlockReflection $reflectionDocBlock)
return $docBlock;
}
+ /**
+ * Generate from array
+ *
+ * @configkey shortdescription string The short description for this doc block
+ * @configkey longdescription string The long description for this doc block
+ * @configkey tags array
+ *
+ * @throws Exception\InvalidArgumentException
+ * @param array $array
+ * @return DocBlockGenerator
+ */
+ public static function fromArray(array $array)
+ {
+ $docBlock = new static();
+
+ foreach ($array as $name => $value) {
+ // normalize key
+ switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
+ case 'shortdescription':
+ $docBlock->setShortDescription($value);
+ case 'longdescription':
+ $docBlock->setLongDescription($value);
+ break;
+ case 'tags':
+ $docBlock->setTags($value);
+ break;
+ }
+ }
+
+ return $docBlock;
+ }
+
+ /**
+ * @param string $shortDescription
+ * @param string $longDescription
+ * @param array $tags
+ */
public function __construct($shortDescription = null, $longDescription = null, array $tags = array())
{
if ($shortDescription !== null) {
@@ -72,24 +109,20 @@ public function __construct($shortDescription = null, $longDescription = null, a
if ($this->tags !== array()) {
$this->setTag($tags);
}
-
}
/**
- * setShortDescription()
- *
- * @param string $shortDescription
+ * @param string $shortDescription
* @return DocBlockGenerator
*/
public function setShortDescription($shortDescription)
{
$this->shortDescription = $shortDescription;
+
return $this;
}
/**
- * getShortDescription()
- *
* @return string
*/
public function getShortDescription()
@@ -98,20 +131,17 @@ public function getShortDescription()
}
/**
- * setLongDescription()
- *
- * @param string $longDescription
+ * @param string $longDescription
* @return DocBlockGenerator
*/
public function setLongDescription($longDescription)
{
$this->longDescription = $longDescription;
+
return $this;
}
/**
- * getLongDescription()
- *
* @return string
*/
public function getLongDescription()
@@ -120,9 +150,7 @@ public function getLongDescription()
}
/**
- * setTags()
- *
- * @param array $tags
+ * @param array $tags
* @return DocBlockGenerator
*/
public function setTags(array $tags)
@@ -135,9 +163,7 @@ public function setTags(array $tags)
}
/**
- * setTag()
- *
- * @param array|DocBlock\Tag $tag
+ * @param array|DocBlock\Tag $tag
* @throws Exception\InvalidArgumentException
* @return DocBlockGenerator
*/
@@ -158,9 +184,7 @@ public function setTag($tag)
}
/**
- * getTags
- *
- * @return DocBlock\Tag[]
+ * @return array
*/
public function getTags()
{
@@ -168,8 +192,6 @@ public function getTags()
}
/**
- * generate()
- *
* @return string
*/
public function generate()
@@ -194,9 +216,7 @@ public function generate()
}
/**
- * docCommentize()
- *
- * @param string $content
+ * @param string $content
* @return string
*/
protected function docCommentize($content)
@@ -213,6 +233,7 @@ protected function docCommentize($content)
$output .= self::LINE_FEED;
}
$output .= $indent . ' */' . self::LINE_FEED;
+
return $output;
}
View
89 tests/ZendTest/Code/Generator/ClassGeneratorTest.php
@@ -11,6 +11,7 @@
namespace ZendTest\Code\Generator;
use Zend\Code\Generator\ClassGenerator;
+use Zend\Code\Generator\DocBlockGenerator;
use Zend\Code\Generator\PropertyGenerator;
use Zend\Code\Generator\MethodGenerator;
use Zend\Code\Reflection\ClassReflection;
@@ -29,7 +30,7 @@ class ClassGeneratorTest extends \PHPUnit_Framework_TestCase
public function testConstruction()
{
$class = new ClassGenerator();
- $this->isInstanceOf($class, '\Zend\Code\Generator\ClassGenerator');
+ $this->isInstanceOf($class, 'Zend\Code\Generator\ClassGenerator');
}
public function testNameAccessors()
@@ -37,7 +38,6 @@ public function testNameAccessors()
$classGenerator = new ClassGenerator();
$classGenerator->setName('TestClass');
$this->assertEquals($classGenerator->getName(), 'TestClass');
-
}
public function testClassDocBlockAccessors()
@@ -73,7 +73,7 @@ public function testPropertyAccessors()
$classGenerator->addProperties(array(
'propOne',
new PropertyGenerator('propTwo')
- ));
+ ));
$properties = $classGenerator->getProperties();
$this->assertEquals(count($properties), 2);
@@ -96,7 +96,7 @@ public function testSetPropertyAlreadyExistsThrowsException()
$this->setExpectedException(
'Zend\Code\Generator\Exception\InvalidArgumentException',
'A property by name prop3 already exists in this class'
- );
+ );
$classGenerator->addProperty('prop3');
}
@@ -107,7 +107,7 @@ public function testSetPropertyNoArrayOrPropertyThrowsException()
$this->setExpectedException(
'Zend\Code\Generator\Exception\InvalidArgumentException',
'addProperty() expects string for name'
- );
+ );
$classGenerator->addProperty(true);
}
@@ -117,7 +117,7 @@ public function testMethodAccessors()
$classGenerator->addMethods(array(
'methodOne',
new MethodGenerator('methodTwo')
- ));
+ ));
$methods = $classGenerator->getMethods();
$this->assertEquals(count($methods), 2);
@@ -139,7 +139,7 @@ public function testSetMethodNoMethodOrArrayThrowsException()
$this->setExpectedException(
'Zend\Code\Generator\Exception\ExceptionInterface',
'addMethod() expects string for name'
- );
+ );
$classGenerator->addMethod(true);
}
@@ -154,7 +154,10 @@ public function testSetMethodNameAlreadyExistsThrowsException()
$classGenerator = new ClassGenerator();
$classGenerator->addMethodFromGenerator($methodA);
- $this->setExpectedException('Zend\Code\Generator\Exception\InvalidArgumentException', 'A method by name foo already exists in this class.');
+ $this->setExpectedException(
+ 'Zend\Code\Generator\Exception\InvalidArgumentException',
+ 'A method by name foo already exists in this class.'
+ );
$classGenerator->addMethodFromGenerator($methodB);
}
@@ -183,33 +186,19 @@ public function testHasProperty()
public function testToString()
{
- $classGenerator = new ClassGenerator(
- 'SampleClass',
- null,
- ClassGenerator::FLAG_ABSTRACT,
- 'ExtendedClassName',
- array('Iterator', 'Traversable'),
- array('foo', 'bar'),
- array('baz')
- );
-
-
$classGenerator = ClassGenerator::fromArray(
array(
'name' => 'SampleClass',
- //'abstract' => true,
'flags' => ClassGenerator::FLAG_ABSTRACT,
- 'name' => 'SampleClass',
'extendedClass' => 'ExtendedClassName',
'implementedInterfaces' => array('Iterator', 'Traversable'),
'properties' => array('foo',
array('name' => 'bar')
- ),
+ ),
'methods' => array(
array('name' => 'baz')
- ),
- ));
-
+ ),
+ ));
$expectedOutput = <<<EOS
abstract class SampleClass extends ExtendedClassName implements Iterator, Traversable
@@ -245,8 +234,8 @@ public function testClassFromReflectionThatImplementsInterfaces()
$code = $classGenerator->generate();
$expectedClassDef = 'class ClassWithInterface'
- . ' implements ZendTest\Code\Generator\TestAsset\OneInterface'
- . ', ZendTest\Code\Generator\TestAsset\TwoInterface';
+ . ' implements ZendTest\Code\Generator\TestAsset\OneInterface'
+ . ', ZendTest\Code\Generator\TestAsset\TwoInterface';
$this->assertContains($expectedClassDef, $code);
}
@@ -255,7 +244,7 @@ public function testClassFromReflectionThatImplementsInterfaces()
*/
public function testClassFromReflectionDiscardParentImplementedInterfaces()
{
- $reflClass = new ClassReflection('\ZendTest\Code\Generator\TestAsset\NewClassWithInterface');
+ $reflClass = new ClassReflection('ZendTest\Code\Generator\TestAsset\NewClassWithInterface');
$classGenerator = ClassGenerator::fromReflection($reflClass);
$classGenerator->setSourceDirty(true);
@@ -263,8 +252,8 @@ public function testClassFromReflectionDiscardParentImplementedInterfaces()
$code = $classGenerator->generate();
$expectedClassDef = 'class NewClassWithInterface'
- . ' extends ZendTest\Code\Generator\TestAsset\ClassWithInterface'
- . ' implements ZendTest\Code\Generator\TestAsset\ThreeInterface';
+ . ' extends ZendTest\Code\Generator\TestAsset\ClassWithInterface'
+ . ' implements ZendTest\Code\Generator\TestAsset\ThreeInterface';
$this->assertContains($expectedClassDef, $code);
}
@@ -274,8 +263,9 @@ public function testClassFromReflectionDiscardParentImplementedInterfaces()
public function testSetextendedclassShouldIgnoreEmptyClassnameOnGenerate()
{
$classGeneratorClass = new ClassGenerator();
- $classGeneratorClass->setName( 'MyClass' )
- ->setExtendedClass('');
+ $classGeneratorClass
+ ->setName('MyClass')
+ ->setExtendedClass('');
$expected = <<<CODE
class MyClass
@@ -285,7 +275,7 @@ class MyClass
}
CODE;
- $this->assertEquals( $expected, $classGeneratorClass->generate() );
+ $this->assertEquals($expected, $classGeneratorClass->generate());
}
/**
@@ -294,8 +284,9 @@ class MyClass
public function testSetextendedclassShouldNotIgnoreNonEmptyClassnameOnGenerate()
{
$classGeneratorClass = new ClassGenerator();
- $classGeneratorClass->setName( 'MyClass' )
- ->setExtendedClass('ParentClass');
+ $classGeneratorClass
+ ->setName('MyClass')
+ ->setExtendedClass('ParentClass');
$expected = <<<CODE
class MyClass extends ParentClass
@@ -305,7 +296,7 @@ class MyClass extends ParentClass
}
CODE;
- $this->assertEquals( $expected, $classGeneratorClass->generate() );
+ $this->assertEquals($expected, $classGeneratorClass->generate());
}
/**
@@ -362,4 +353,30 @@ public function testPassingANamespacedClassnameShouldGenerateAClassnameWithoutIt
$received = $classGeneratorClass->generate();
$this->assertContains('class FunClass', $received, $received);
}
+
+ public function testCreateFromArrayWithDocBlockFromArray()
+ {
+ $classGenerator = ClassGenerator::fromArray(
+ array(
+ 'name' => 'SampleClass',
+ 'docblock' => array(
+ 'shortdescription' => 'foo',
+ ),
+ ));
+
+ $docBlock = $classGenerator->getDocBlock();
+ $this->assertInstanceOf('Zend\Code\Generator\DocBlockGenerator', $docBlock);
+ }
+
+ public function testCreateFromArrayWithDocBlockInstance()
+ {
+ $classGenerator = ClassGenerator::fromArray(
+ array(
+ 'name' => 'SampleClass',
+ 'docblock' => new DocBlockGenerator('foo'),
+ ));
+
+ $docBlock = $classGenerator->getDocBlock();
+ $this->assertInstanceOf('Zend\Code\Generator\DocBlockGenerator', $docBlock);
+ }
}
View
23 tests/ZendTest/Code/Generator/DocBlockGeneratorTest.php
@@ -23,7 +23,9 @@
*/
class DocBlockGeneratorTest extends \PHPUnit_Framework_TestCase
{
- /** @var DocBlockGenerator */
+ /**
+ * @var DocBlockGenerator
+ */
protected $docBlockGenerator;
protected function setUp()
@@ -66,7 +68,6 @@ public function testTagGettersAndSetters()
EOS;
$this->assertEquals($target, $this->docBlockGenerator->generate());
-
}
public function testGenerationOfDocBlock()
@@ -78,4 +79,22 @@ public function testGenerationOfDocBlock()
$this->assertEquals($expected, $this->docBlockGenerator->generate());
}
+ public function testCreateFromArray()
+ {
+ $docBlock = DocBlockGenerator::fromArray(array(
+ 'shortdescription' => 'foo',
+ 'longdescription' => 'bar',
+ 'tags' => array(
+ array(
+ 'name' => 'foo',
+ 'description' => 'bar',
+ )
+ ),
+ ));
+
+ $this->assertEquals('foo', $docBlock->getShortDescription());
+ $this->assertEquals('bar', $docBlock->getLongDescription());
+ $this->assertCount(1, $docBlock->getTags());
+ }
+
}
Something went wrong with that request. Please try again.