Fixes implementation of Example tag

This commit is contained in:
Jaapio
2017-08-18 23:00:12 +02:00
parent a8d791f8c9
commit c054cfdfe1
2 changed files with 169 additions and 50 deletions
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Tags\Example;
/**
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Example
*/
class ExampleTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ::create
* @covers ::__construct
* @covers ::getContent
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testExampleWithoutContent()
{
$tag = Example::create('"example1.php"');
$this->assertEquals('"example1.php"', $tag->getContent());
$this->assertEquals('', $tag->getDescription());
}
/**
* @covers ::create
* @covers ::__construct
* @covers ::getFilePath
* @covers ::getDescription
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testWithDescription()
{
$tag = Example::create('"example1.php" some text');
$this->assertEquals('example1.php', $tag->getFilePath());
$this->assertEquals('some text', $tag->getDescription());
}
/**
* @covers ::create
* @covers ::__construct
* @covers ::getFilePath
* @covers ::getStartingLine
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testStartlineIsParsed()
{
$tag = Example::create('"example1.php" 10');
$this->assertEquals('example1.php', $tag->getFilePath());
$this->assertEquals(10, $tag->getStartingLine());
}
/**
* @covers ::create
* @covers ::__construct
* @covers ::getFilePath
* @covers ::getStartingLine
* @covers ::getDescription
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testAllowOmitingLineCount()
{
$tag = Example::create('"example1.php" 10 some text');
$this->assertEquals('example1.php', $tag->getFilePath());
$this->assertEquals(10, $tag->getStartingLine());
$this->assertEquals('some text', $tag->getDescription());
}
/**
* @covers ::create
* @covers ::__construct
* @covers ::getFilePath
* @covers ::getStartingLine
* @covers ::getLineCount
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testLengthIsParsed()
{
$tag = Example::create('"example1.php" 10 5');
$this->assertEquals('example1.php', $tag->getFilePath());
$this->assertEquals(10, $tag->getStartingLine());
$this->assertEquals(5, $tag->getLineCount());
}
/**
* @covers ::create
* @covers ::__construct
* @covers ::getFilePath
* @covers ::getStartingLine
* @covers ::getLineCount
* @covers ::getDescription
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*/
public function testFullExample()
{
$tag = Example::create('"example1.php" 10 5 test text');
$this->assertEquals('example1.php', $tag->getFilePath());
$this->assertEquals(10, $tag->getStartingLine());
$this->assertEquals(5, $tag->getLineCount());
$this->assertEquals('test text', $tag->getDescription());
}
}