1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
<?php
declare(strict_types=1);
/**
* 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.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
use phpDocumentor\Reflection\Types\ContextFactory;
use PHPUnit\Framework\TestCase;
/**
* @coversNothing
*/
class ReconstitutingADocBlockTest extends TestCase
{
/**
* Call Mockery::close after each test.
*/
public function tearDown(): void
{
m::close();
}
public function testReconstituteADocBlock(): void
{
/** @var string $docComment */
$docComment;
/** @var string $reconstitutedDocComment */
$reconstitutedDocComment;
include(__DIR__ . '/../../examples/03-reconstituting-a-docblock.php');
$this->assertSame($docComment, $reconstitutedDocComment);
}
/**
* Method
*
* Method which contains a modulo sign (%) in its description.
*
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
*
* @covers ::__construct
* @covers ::render
* @covers ::__toString
*/
public function testDescriptionCanContainPercent(): void
{
$factory = DocBlockFactory::createInstance();
$contextFactory = new ContextFactory();
$method = new \ReflectionMethod(self::class, 'testDescriptionCanContainPercent');
$docblock = $factory->create(
$method,
$contextFactory->createFromReflector($method->getDeclaringClass())
);
$tag1 = new Generic('JoinColumn', new Description('(name="column_id", referencedColumnName="id")'));
$tag2 = new Generic('JoinColumn', new Description('(name="column_id_2", referencedColumnName="id")'));
$tags = [
$tag1,
$tag2,
];
$fixture = $docblock->getDescription();
$expected = 'Method which contains a modulo sign (%) in its description.';
$this->assertSame($expected, (string) $fixture);
}
}
|