Skip to content

Commit 97c3735

Browse files
committed
Add first integration test
1 parent de7bc57 commit 97c3735

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
require_once(__DIR__ . '/../vendor/autoload.php');
3+
4+
use phpDocumentor\Reflection\DocBlockFactory;
5+
6+
$docComment = <<<DOCCOMMENT
7+
/**
8+
* This is an example of a summary.
9+
*
10+
* This is a Description. A Summary and Description are separated by either
11+
* two subsequent newlines (thus a whiteline in between as can be seen in this
12+
* example), or when the Summary ends with a dot (`.`) and some form of
13+
* whitespace.
14+
*/
15+
DOCCOMMENT;
16+
17+
$factory = DocBlockFactory::createInstance();
18+
$docblock = $factory->create($docComment);
19+
20+
// Should contain the first line of the DocBlock
21+
$summary = $docblock->getSummary();
22+
23+
// Contains an object of type Description; you can either cast it to string or use
24+
// the render method to get a string representation of the Description.
25+
//
26+
// In subsequent examples we will be fiddling a bit more with the Description.
27+
$description = $docblock->getDescription();

phpunit.xml.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
>
1111
<testsuites>
1212
<testsuite name="unit">
13-
<directory>./tests/</directory>
13+
<directory>./tests/unit</directory>
1414
</testsuite>
15+
<testsuite name="integration">
16+
<directory>./tests/integration</directory>
17+
</testsuite>
1518
</testsuites>
1619
<filter>
1720
<whitelist>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* This file is part of phpDocumentor.
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*
8+
* @copyright 2010-2015 Mike van Riel<[email protected]>
9+
* @license http://www.opensource.org/licenses/mit-license.php MIT
10+
* @link http://phpdoc.org
11+
*/
12+
13+
namespace phpDocumentor\Reflection;
14+
15+
use phpDocumentor\Reflection\DocBlock\Description;
16+
17+
/**
18+
* @coversNothing
19+
*/
20+
class InterpretingDocBlocksTest extends \PHPUnit_Framework_TestCase
21+
{
22+
/**
23+
* @link ../../examples/interpreting-a-simple-docblock.php
24+
*/
25+
public function testInterpretingASimpleDocBlock()
26+
{
27+
/**
28+
* @var DocBlock $docblock
29+
* @var string $summary
30+
* @var Description $description
31+
*/
32+
include(__DIR__ . '/../../examples/interpreting-a-simple-docblock.php');
33+
34+
$descriptionText = <<<DESCRIPTION
35+
This is a Description. A Summary and Description are separated by either
36+
two subsequent newlines (thus a whiteline in between as can be seen in this
37+
example), or when the Summary ends with a dot (`.`) and some form of
38+
whitespace.
39+
DESCRIPTION;
40+
41+
$this->assertInstanceOf(DocBlock::class, $docblock);
42+
$this->assertSame('This is an example of a summary.', $summary);
43+
$this->assertInstanceOf(Description::class, $description);
44+
$this->assertSame($descriptionText, $description->render());
45+
$this->assertEmpty($docblock->getTags());
46+
}
47+
}

0 commit comments

Comments
 (0)