Вход Регистрация
Файл: gapps/vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/DescriptionTest.php
Строк: 104
<?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<mike@phpdoc.org>
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
 * @link      http://phpdoc.org
 */

namespace phpDocumentorReflectionDocBlock;

use 
Mockery as m;
use 
phpDocumentorReflectionDocBlockTagsFormatterPassthroughFormatter;
use 
phpDocumentorReflectionDocBlockTagsGeneric;

/**
 * @coversDefaultClass phpDocumentorReflectionDocBlockDescription
 */
class DescriptionTest extends PHPUnit_Framework_TestCase
{
    
/**
     * @covers ::__construct
     * @covers ::render
     * @uses phpDocumentorReflectionDocBlockTagsGeneric
     * @uses phpDocumentorReflectionDocBlockTagsBaseTag
     * @uses phpDocumentorReflectionDocBlockTagsFormatterPassthroughFormatter
     */
    
public function testDescriptionCanRenderUsingABodyWithPlaceholdersAndTags()
    {
        
$body 'This is a %1$s body.';
        
$expected 'This is a {@internal significant } body.';
        
$tags = [new Generic('internal', new Description('significant '))];

        
$fixture = new Description($body$tags);

        
// without formatter (thus the PassthroughFormatter by default)
        
$this->assertSame($expected$fixture->render());

        
// with a custom formatter
        
$formatter m::mock(PassthroughFormatter::class);
        
$formatter->shouldReceive('format')->with($tags[0])->andReturn('@internal significant ');
        
$this->assertSame($expected$fixture->render($formatter));
    }

    
/**
     * @covers ::__construct
     * @covers ::render
     * @covers ::__toString
     * @uses phpDocumentorReflectionDocBlockTagsGeneric
     * @uses phpDocumentorReflectionDocBlockTagsBaseTag
     * @uses phpDocumentorReflectionDocBlockTagsFormatterPassthroughFormatter
     */
    
public function testDescriptionCanBeCastToString()
    {
        
$body 'This is a %1$s body.';
        
$expected 'This is a {@internal significant } body.';
        
$tags = [new Generic('internal', new Description('significant '))];

        
$fixture = new Description($body$tags);

        
$this->assertSame($expected, (string)$fixture);
    }

    
/**
     * @covers ::__construct
     * @expectedException InvalidArgumentException
     */
    
public function testBodyTemplateMustBeAString()
    {
        new 
Description([]);
    }
}
Онлайн: 0
Реклама