mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
Added tests related to the namespaced tag support;
Restored ReturnTag::getTypesCollection() to "protected", to avoid potential BC breaks later.
This commit is contained in:
@@ -32,9 +32,7 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::getType
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::getTypes
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag
|
||||
*
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
@@ -77,41 +80,121 @@ class TagTest extends \PHPUnit_Framework_TestCase
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
}
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreUnreg = Tag::createInstance('@var mixed');
|
||||
$tagPreReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreUnreg
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreUnreg
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
require 'data:text/plain;base64,'. base64_encode(
|
||||
<<<TAG_HANDLER
|
||||
<?php
|
||||
class MyVarHandler extends \phpDocumentor\Reflection\DocBlock\Tag {}
|
||||
class MyTagHandler extends \phpDocumentor\Reflection\DocBlock\Tag {}
|
||||
TAG_HANDLER
|
||||
);
|
||||
|
||||
$this->assertTrue(Tag::registerTagHandler('var', '\MyVarHandler'));
|
||||
$this->assertTrue(Tag::registerTagHandler('var', '\MyTagHandler'));
|
||||
|
||||
$tagPostUnreg = Tag::createInstance('@var mixed');
|
||||
$tagPostReg = Tag::createInstance('@var mixed');
|
||||
$this->assertNotInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostUnreg
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostUnreg
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\MyVarHandler',
|
||||
$tagPostUnreg
|
||||
'\MyTagHandler',
|
||||
$tagPostReg
|
||||
);
|
||||
|
||||
$this->assertTrue(Tag::registerTagHandler('var', $currentHandler));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testTagHandlerCorrectRegistration
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||
*/
|
||||
public function testNamespacedTagHandlerCorrectRegistration()
|
||||
{
|
||||
$tagPreReg = Tag::createInstance('@T something');
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertNotInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
Tag::registerTagHandler('\MyNamespace\MyTag', '\MyTagHandler')
|
||||
);
|
||||
|
||||
$tagPostReg = Tag::createInstance(
|
||||
'@T something',
|
||||
new DocBlock(
|
||||
'',
|
||||
new Context('', array('T' => '\MyNamespace\MyTag'))
|
||||
)
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPostReg
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
Tag::registerTagHandler('\MyNamespace\MyTag', null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testTagHandlerCorrectRegistration
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||
*/
|
||||
public function testNamespacedTagHandlerIncorrectRegistration()
|
||||
{
|
||||
$tagPreReg = Tag::createInstance('@T something');
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertNotInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
Tag::registerTagHandler('MyNamespace\MyTag', '\MyTagHandler')
|
||||
);
|
||||
|
||||
$tagPostReg = Tag::createInstance(
|
||||
'@T something',
|
||||
new DocBlock(
|
||||
'',
|
||||
new Context('', array('T' => '\MyNamespace\MyTag'))
|
||||
)
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertNotInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPostReg
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use phpDocumentor\Reflection\DocBlock\Location;
|
||||
|
||||
/**
|
||||
* Test class for phpDocumentor\Reflection\DocBlock
|
||||
@@ -24,6 +25,9 @@ use phpDocumentor\Reflection\DocBlock\Context;
|
||||
*/
|
||||
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
@@ -38,7 +42,8 @@ class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock(
|
||||
$fixture,
|
||||
new Context('\MyNamespace', array('PHPDoc' => '\phpDocumentor'))
|
||||
new Context('\MyNamespace', array('PHPDoc' => '\phpDocumentor')),
|
||||
new Location(2)
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a short description.',
|
||||
@@ -58,6 +63,7 @@ DOCBLOCK;
|
||||
array('PHPDoc' => '\phpDocumentor'),
|
||||
$object->getContext()->getNamespaceAliases()
|
||||
);
|
||||
$this->assertSame(2, $object->getLocation()->getLineNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user