mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Make Context leaner and enable third parties to create them
Contexts are necessary for factories to resolve QSEN into FQSENs based on partial namespaces and namespace aliases. These provide DocBlocks with the namespace name and namespace aliases. The new ContextFactory will enable third parties who don't use phpDocumentor's Reflection component to construct a Context based on a class reflector or namespace name (and file contents).
This commit is contained in:
committed by
Mike van Riel
parent
f5e35e0629
commit
f3f4d07808
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright 2010-2015 Mike van Riel<[email protected]>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use Mockery as m;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Context
|
||||
*/
|
||||
class ContextTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getNamespace
|
||||
*/
|
||||
public function testProvidesANormalizedNamespace()
|
||||
{
|
||||
$fixture = new Context('\My\Space');
|
||||
$this->assertSame('My\Space', $fixture->getNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getNamespace
|
||||
*/
|
||||
public function testInterpretsNamespaceNamedGlobalAsRootNamespace()
|
||||
{
|
||||
$fixture = new Context('global');
|
||||
$this->assertSame('', $fixture->getNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getNamespace
|
||||
*/
|
||||
public function testInterpretsNamespaceNamedDefaultAsRootNamespace()
|
||||
{
|
||||
$fixture = new Context('default');
|
||||
$this->assertSame('', $fixture->getNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getNamespaceAliases
|
||||
*/
|
||||
public function testProvidesNormalizedNamespaceAliases()
|
||||
{
|
||||
$fixture = new Context('', ['Space' => '\My\Space']);
|
||||
$this->assertSame(['Space' => 'My\Space'], $fixture->getNamespaceAliases());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user