Add first integration test

This commit is contained in:
Mike van Riel
2015-06-24 08:42:24 +02:00
parent de7bc574ea
commit 97c3735b32
3 changed files with 78 additions and 1 deletions
@@ -0,0 +1,27 @@
<?php
require_once(__DIR__ . '/../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* This is a Description. A Summary and Description are separated by either
* two subsequent newlines (thus a whiteline in between as can be seen in this
* example), or when the Summary ends with a dot (`.`) and some form of
* whitespace.
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// Should contain the first line of the DocBlock
$summary = $docblock->getSummary();
// Contains an object of type Description; you can either cast it to string or use
// the render method to get a string representation of the Description.
//
// In subsequent examples we will be fiddling a bit more with the Description.
$description = $docblock->getDescription();
+4 -1
View File
@@ -10,7 +10,10 @@
> >
<testsuites> <testsuites>
<testsuite name="unit"> <testsuite name="unit">
<directory>./tests/</directory> <directory>./tests/unit</directory>
</testsuite>
<testsuite name="integration">
<directory>./tests/integration</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>
@@ -0,0 +1,47 @@
<?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;
use phpDocumentor\Reflection\DocBlock\Description;
/**
* @coversNothing
*/
class InterpretingDocBlocksTest extends \PHPUnit_Framework_TestCase
{
/**
* @link ../../examples/interpreting-a-simple-docblock.php
*/
public function testInterpretingASimpleDocBlock()
{
/**
* @var DocBlock $docblock
* @var string $summary
* @var Description $description
*/
include(__DIR__ . '/../../examples/interpreting-a-simple-docblock.php');
$descriptionText = <<<DESCRIPTION
This is a Description. A Summary and Description are separated by either
two subsequent newlines (thus a whiteline in between as can be seen in this
example), or when the Summary ends with a dot (`.`) and some form of
whitespace.
DESCRIPTION;
$this->assertInstanceOf(DocBlock::class, $docblock);
$this->assertSame('This is an example of a summary.', $summary);
$this->assertInstanceOf(Description::class, $description);
$this->assertSame($descriptionText, $description->render());
$this->assertEmpty($docblock->getTags());
}
}