| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 | 
							- <?php
 
- /**
 
-  * phpDocumentor DocBlock Test
 
-  *
 
-  * PHP Version 5.3
 
-  *
 
-  * @author    Mike van Riel <mike.vanriel@naenius.com>
 
-  * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
 
-  * @license   http://www.opensource.org/licenses/mit-license.php MIT
 
-  * @link      http://phpdoc.org
 
-  */
 
- namespace phpDocumentor\Reflection;
 
- use phpDocumentor\Reflection\DocBlock\Context;
 
- use phpDocumentor\Reflection\DocBlock\Location;
 
- use phpDocumentor\Reflection\DocBlock\Tag\ReturnTag;
 
- /**
 
-  * Test class for phpDocumentor\Reflection\DocBlock
 
-  *
 
-  * @author    Mike van Riel <mike.vanriel@naenius.com>
 
-  * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
 
-  * @license   http://www.opensource.org/licenses/mit-license.php MIT
 
-  * @link      http://phpdoc.org
 
-  */
 
- class DocBlockTest extends \PHPUnit_Framework_TestCase
 
- {
 
-     /**
 
-      * @covers \phpDocumentor\Reflection\DocBlock
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testConstruct()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**
 
-  * This is a short description
 
-  *
 
-  * This is a long description
 
-  *
 
-  * @see \MyClass
 
-  * @return void
 
-  */
 
- DOCBLOCK;
 
-         $object = new DocBlock(
 
-             $fixture,
 
-             new Context('\MyNamespace', array('PHPDoc' => '\phpDocumentor')),
 
-             new Location(2)
 
-         );
 
-         $this->assertEquals(
 
-             'This is a short description',
 
-             $object->getShortDescription()
 
-         );
 
-         $this->assertEquals(
 
-             'This is a long description',
 
-             $object->getLongDescription()->getContents()
 
-         );
 
-         $this->assertCount(2, $object->getTags());
 
-         $this->assertTrue($object->hasTag('see'));
 
-         $this->assertTrue($object->hasTag('return'));
 
-         $this->assertFalse($object->hasTag('category'));
 
-         
 
-         $this->assertSame('MyNamespace', $object->getContext()->getNamespace());
 
-         $this->assertSame(
 
-             array('PHPDoc' => '\phpDocumentor'),
 
-             $object->getContext()->getNamespaceAliases()
 
-         );
 
-         $this->assertSame(2, $object->getLocation()->getLineNumber());
 
-     }
 
-     /**
 
-      * @covers \phpDocumentor\Reflection\DocBlock::splitDocBlock
 
-      *
 
-      * @return void
 
-      */
 
-     public function testConstructWithTagsOnly()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**
 
-  * @see \MyClass
 
-  * @return void
 
-  */
 
- DOCBLOCK;
 
-         $object = new DocBlock($fixture);
 
-         $this->assertEquals('', $object->getShortDescription());
 
-         $this->assertEquals('', $object->getLongDescription()->getContents());
 
-         $this->assertCount(2, $object->getTags());
 
-         $this->assertTrue($object->hasTag('see'));
 
-         $this->assertTrue($object->hasTag('return'));
 
-         $this->assertFalse($object->hasTag('category'));
 
-     }
 
-     /**
 
-      * @covers \phpDocumentor\Reflection\DocBlock::isTemplateStart
 
-      */
 
-     public function testIfStartOfTemplateIsDiscovered()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**#@+
 
-  * @see \MyClass
 
-  * @return void
 
-  */
 
- DOCBLOCK;
 
-         $object = new DocBlock($fixture);
 
-         $this->assertEquals('', $object->getShortDescription());
 
-         $this->assertEquals('', $object->getLongDescription()->getContents());
 
-         $this->assertCount(2, $object->getTags());
 
-         $this->assertTrue($object->hasTag('see'));
 
-         $this->assertTrue($object->hasTag('return'));
 
-         $this->assertFalse($object->hasTag('category'));
 
-         $this->assertTrue($object->isTemplateStart());
 
-     }
 
-     /**
 
-      * @covers \phpDocumentor\Reflection\DocBlock::isTemplateEnd
 
-      */
 
-     public function testIfEndOfTemplateIsDiscovered()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**#@-*/
 
- DOCBLOCK;
 
-         $object = new DocBlock($fixture);
 
-         $this->assertEquals('', $object->getShortDescription());
 
-         $this->assertEquals('', $object->getLongDescription()->getContents());
 
-         $this->assertTrue($object->isTemplateEnd());
 
-     }
 
-     /**
 
-      * @covers \phpDocumentor\Reflection\DocBlock::cleanInput
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testConstructOneLiner()
 
-     {
 
-         $fixture = '/** Short description and nothing more. */';
 
-         $object = new DocBlock($fixture);
 
-         $this->assertEquals(
 
-             'Short description and nothing more.',
 
-             $object->getShortDescription()
 
-         );
 
-         $this->assertEquals('', $object->getLongDescription()->getContents());
 
-         $this->assertCount(0, $object->getTags());
 
-     }
 
-     /**
 
-      * @covers \phpDocumentor\Reflection\DocBlock::__construct
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testConstructFromReflector()
 
-     {
 
-         $object = new DocBlock(new \ReflectionClass($this));
 
-         $this->assertEquals(
 
-             'Test class for phpDocumentor\Reflection\DocBlock',
 
-             $object->getShortDescription()
 
-         );
 
-         $this->assertEquals('', $object->getLongDescription()->getContents());
 
-         $this->assertCount(4, $object->getTags());
 
-         $this->assertTrue($object->hasTag('author'));
 
-         $this->assertTrue($object->hasTag('copyright'));
 
-         $this->assertTrue($object->hasTag('license'));
 
-         $this->assertTrue($object->hasTag('link'));
 
-         $this->assertFalse($object->hasTag('category'));
 
-     }
 
-     /**
 
-      * @expectedException \InvalidArgumentException
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testExceptionOnInvalidObject()
 
-     {
 
-         new DocBlock($this);
 
-     }
 
-     public function testDotSeperation()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**
 
-  * This is a short description.
 
-  * This is a long description.
 
-  * This is a continuation of the long description.
 
-  */
 
- DOCBLOCK;
 
-         $object = new DocBlock($fixture);
 
-         $this->assertEquals(
 
-             'This is a short description.',
 
-             $object->getShortDescription()
 
-         );
 
-         $this->assertEquals(
 
-             "This is a long description.\nThis is a continuation of the long "
 
-             ."description.",
 
-             $object->getLongDescription()->getContents()
 
-         );
 
-     }
 
-     /**
 
-      * @covers \phpDocumentor\Reflection\DocBlock::parseTags
 
-      * @expectedException \LogicException
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testInvalidTagBlock()
 
-     {
 
-         if (0 == ini_get('allow_url_include')) {
 
-             $this->markTestSkipped('"data" URIs for includes are required.');
 
-         }
 
-         include 'data:text/plain;base64,'. base64_encode(
 
-             <<<DOCBLOCK_EXTENSION
 
- <?php
 
- class MyReflectionDocBlock extends \phpDocumentor\Reflection\DocBlock {
 
-     protected function splitDocBlock(\$comment) {
 
-         return array('', '', 'Invalid tag block');
 
-     }
 
- }
 
- DOCBLOCK_EXTENSION
 
-         );
 
-         new \MyReflectionDocBlock('');
 
-         
 
-     }
 
-     public function testTagCaseSensitivity()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**
 
-  * This is a short description.
 
-  *
 
-  * This is a long description.
 
-  *
 
-  * @method null something()
 
-  * @Method({"GET", "POST"})
 
-  */
 
- DOCBLOCK;
 
-         $object = new DocBlock($fixture);
 
-         $this->assertEquals(
 
-             'This is a short description.',
 
-             $object->getShortDescription()
 
-         );
 
-         $this->assertEquals(
 
-             'This is a long description.',
 
-             $object->getLongDescription()->getContents()
 
-         );
 
-         $tags = $object->getTags();
 
-         $this->assertCount(2, $tags);
 
-         $this->assertTrue($object->hasTag('method'));
 
-         $this->assertTrue($object->hasTag('Method'));
 
-         $this->assertInstanceOf(
 
-             __NAMESPACE__ . '\DocBlock\Tag\MethodTag',
 
-             $tags[0]
 
-         );
 
-         $this->assertInstanceOf(
 
-             __NAMESPACE__ . '\DocBlock\Tag',
 
-             $tags[1]
 
-         );
 
-         $this->assertNotInstanceOf(
 
-             __NAMESPACE__ . '\DocBlock\Tag\MethodTag',
 
-             $tags[1]
 
-         );
 
-     }
 
-     /**
 
-      * @depends testConstructFromReflector
 
-      * @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testGetTagsByNameZeroAndOneMatch()
 
-     {
 
-         $object = new DocBlock(new \ReflectionClass($this));
 
-         $this->assertEmpty($object->getTagsByName('category'));
 
-         $this->assertCount(1, $object->getTagsByName('author'));
 
-     }
 
-     /**
 
-      * @depends testConstructWithTagsOnly
 
-      * @covers \phpDocumentor\Reflection\DocBlock::parseTags
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testParseMultilineTag()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**
 
-  * @return void Content on
 
-  *     multiple lines.
 
-  */
 
- DOCBLOCK;
 
-         $object = new DocBlock($fixture);
 
-         $this->assertCount(1, $object->getTags());
 
-     }
 
-     /**
 
-      * @depends testConstructWithTagsOnly
 
-      * @covers \phpDocumentor\Reflection\DocBlock::parseTags
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testParseMultilineTagWithLineBreaks()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**
 
-  * @return void Content on
 
-  *     multiple lines.
 
-  *
 
-  *     One more, after the break.
 
-  */
 
- DOCBLOCK;
 
-         $object = new DocBlock($fixture);
 
-         $this->assertCount(1, $tags = $object->getTags());
 
- 	    /** @var ReturnTag $tag */
 
- 	    $tag = reset($tags);
 
- 	    $this->assertEquals("Content on\n    multiple lines.\n\n    One more, after the break.", $tag->getDescription());
 
-     }
 
-     /**
 
-      * @depends testConstructWithTagsOnly
 
-      * @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
 
-      * 
 
-      * @return void
 
-      */
 
-     public function testGetTagsByNameMultipleMatch()
 
-     {
 
-         $fixture = <<<DOCBLOCK
 
- /**
 
-  * @param string
 
-  * @param int
 
-  * @return void
 
-  */
 
- DOCBLOCK;
 
-         $object = new DocBlock($fixture);
 
-         $this->assertEmpty($object->getTagsByName('category'));
 
-         $this->assertCount(1, $object->getTagsByName('return'));
 
-         $this->assertCount(2, $object->getTagsByName('param'));
 
-     }
 
- }
 
 
  |