update v 1.0.7.5
This commit is contained in:
97
vendor/phpdocumentor/reflection-docblock/tests/integration/InterpretingDocBlocksTest.php
vendored
Normal file
97
vendor/phpdocumentor/reflection-docblock/tests/integration/InterpretingDocBlocksTest.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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 phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
class InterpretingDocBlocksTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterpretingASimpleDocBlock()
|
||||
{
|
||||
/**
|
||||
* @var DocBlock $docblock
|
||||
* @var string $summary
|
||||
* @var Description $description
|
||||
*/
|
||||
include(__DIR__ . '/../../examples/01-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());
|
||||
}
|
||||
|
||||
public function testInterpretingTags()
|
||||
{
|
||||
/**
|
||||
* @var DocBlock $docblock
|
||||
* @var boolean $hasSeeTag
|
||||
* @var Tag[] $tags
|
||||
* @var See[] $seeTags
|
||||
*/
|
||||
include(__DIR__ . '/../../examples/02-interpreting-tags.php');
|
||||
|
||||
$this->assertTrue($hasSeeTag);
|
||||
$this->assertCount(1, $tags);
|
||||
$this->assertCount(1, $seeTags);
|
||||
|
||||
$this->assertInstanceOf(See::class, $tags[0]);
|
||||
$this->assertInstanceOf(See::class, $seeTags[0]);
|
||||
|
||||
$seeTag = $seeTags[0];
|
||||
$this->assertSame('\\' . StandardTagFactory::class, (string)$seeTag->getReference());
|
||||
$this->assertSame('', (string)$seeTag->getDescription());
|
||||
}
|
||||
|
||||
public function testDescriptionsCanEscapeAtSignsAndClosingBraces()
|
||||
{
|
||||
/**
|
||||
* @var string $docComment
|
||||
* @var DocBlock $docblock
|
||||
* @var Description $description
|
||||
* @var string $receivedDocComment
|
||||
* @var string $foundDescription
|
||||
*/
|
||||
|
||||
include(__DIR__ . '/../../examples/playing-with-descriptions/02-escaping.php');
|
||||
$this->assertSame(<<<'DESCRIPTION'
|
||||
You can escape the @-sign by surrounding it with braces, for example: @. And escape a closing brace within an
|
||||
inline tag by adding an opening brace in front of it like this: }.
|
||||
|
||||
Here are example texts where you can see how they could be used in a real life situation:
|
||||
|
||||
This is a text with an {@internal inline tag where a closing brace (}) is shown}.
|
||||
Or an {@internal inline tag with a literal {@link} in it}.
|
||||
|
||||
Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
|
||||
DESCRIPTION
|
||||
,
|
||||
$foundDescription
|
||||
)
|
||||
;
|
||||
}
|
||||
}
|
||||
35
vendor/phpdocumentor/reflection-docblock/tests/integration/ReconstitutingADocBlockTest.php
vendored
Normal file
35
vendor/phpdocumentor/reflection-docblock/tests/integration/ReconstitutingADocBlockTest.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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 phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
class ReconstitutingADocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testReconstituteADocBlock()
|
||||
{
|
||||
/**
|
||||
* @var string $docComment
|
||||
* @var string $reconstitutedDocComment
|
||||
*/
|
||||
include(__DIR__ . '/../../examples/03-reconstituting-a-docblock.php');
|
||||
|
||||
$this->assertSame($docComment, $reconstitutedDocComment);
|
||||
}
|
||||
}
|
||||
39
vendor/phpdocumentor/reflection-docblock/tests/integration/UsingTagsTest.php
vendored
Normal file
39
vendor/phpdocumentor/reflection-docblock/tests/integration/UsingTagsTest.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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 phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
class UsingTagsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAddingYourOwnTagUsingAStaticMethodAsFactory()
|
||||
{
|
||||
/**
|
||||
* @var object[] $customTagObjects
|
||||
* @var string $docComment
|
||||
* @var string $reconstitutedDocComment
|
||||
*/
|
||||
include(__DIR__ . '/../../examples/04-adding-your-own-tag.php');
|
||||
|
||||
$this->assertInstanceOf(\MyTag::class, $customTagObjects[0]);
|
||||
$this->assertSame('my-tag', $customTagObjects[0]->getName());
|
||||
$this->assertSame('I have a description', (string)$customTagObjects[0]->getDescription());
|
||||
$this->assertSame($docComment, $reconstitutedDocComment);
|
||||
}
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Description Test
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DescriptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(1, $parsedContents);
|
||||
$this->assertSame($fixture, $parsedContents[0]);
|
||||
}
|
||||
|
||||
public function testInlineTagParsing()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a {@link http://phpdoc.org/ description} that uses inline
|
||||
tags.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(3, $parsedContents);
|
||||
$this->assertSame('This is text for a ', $parsedContents[0]);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag\LinkTag',
|
||||
$parsedContents[1]
|
||||
);
|
||||
$this->assertSame(
|
||||
' that uses inline
|
||||
tags.',
|
||||
$parsedContents[2]
|
||||
);
|
||||
}
|
||||
|
||||
public function testInlineTagAtStartParsing()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
{@link http://phpdoc.org/ This} is text for a description that uses inline
|
||||
tags.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(3, $parsedContents);
|
||||
|
||||
$this->assertSame('', $parsedContents[0]);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag\LinkTag',
|
||||
$parsedContents[1]
|
||||
);
|
||||
$this->assertSame(
|
||||
' is text for a description that uses inline
|
||||
tags.',
|
||||
$parsedContents[2]
|
||||
);
|
||||
}
|
||||
|
||||
public function testNestedInlineTagParsing()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description with {@internal inline tag with
|
||||
{@link http://phpdoc.org another inline tag} in it}.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(3, $parsedContents);
|
||||
|
||||
$this->assertSame(
|
||||
'This is text for a description with ',
|
||||
$parsedContents[0]
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$parsedContents[1]
|
||||
);
|
||||
$this->assertSame('.', $parsedContents[2]);
|
||||
|
||||
$parsedDescription = $parsedContents[1]->getParsedDescription();
|
||||
$this->assertCount(3, $parsedDescription);
|
||||
$this->assertSame("inline tag with\n", $parsedDescription[0]);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag\LinkTag',
|
||||
$parsedDescription[1]
|
||||
);
|
||||
$this->assertSame(' in it', $parsedDescription[2]);
|
||||
}
|
||||
|
||||
public function testLiteralOpeningDelimiter()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description containing { that is literal.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(1, $parsedContents);
|
||||
$this->assertSame($fixture, $parsedContents[0]);
|
||||
}
|
||||
|
||||
public function testNestedLiteralOpeningDelimiter()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description containing {@internal inline tag that has { that
|
||||
is literal}.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(3, $parsedContents);
|
||||
$this->assertSame(
|
||||
'This is text for a description containing ',
|
||||
$parsedContents[0]
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$parsedContents[1]
|
||||
);
|
||||
$this->assertSame('.', $parsedContents[2]);
|
||||
|
||||
$this->assertSame(
|
||||
array('inline tag that has { that
|
||||
is literal'),
|
||||
$parsedContents[1]->getParsedDescription()
|
||||
);
|
||||
}
|
||||
|
||||
public function testLiteralClosingDelimiter()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description with {} that is not a tag.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(1, $parsedContents);
|
||||
$this->assertSame(
|
||||
'This is text for a description with } that is not a tag.',
|
||||
$parsedContents[0]
|
||||
);
|
||||
}
|
||||
|
||||
public function testNestedLiteralClosingDelimiter()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description with {@internal inline tag with {} that is not an
|
||||
inline tag}.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(3, $parsedContents);
|
||||
$this->assertSame(
|
||||
'This is text for a description with ',
|
||||
$parsedContents[0]
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$parsedContents[1]
|
||||
);
|
||||
$this->assertSame('.', $parsedContents[2]);
|
||||
|
||||
$this->assertSame(
|
||||
array('inline tag with } that is not an
|
||||
inline tag'),
|
||||
$parsedContents[1]->getParsedDescription()
|
||||
);
|
||||
}
|
||||
|
||||
public function testInlineTagEscapingSequence()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description with literal {{@}link}.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(1, $parsedContents);
|
||||
$this->assertSame(
|
||||
'This is text for a description with literal {@link}.',
|
||||
$parsedContents[0]
|
||||
);
|
||||
}
|
||||
|
||||
public function testNestedInlineTagEscapingSequence()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description with an {@internal inline tag with literal
|
||||
{{@}link{} in it}.
|
||||
LONGDESC;
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
$this->assertCount(3, $parsedContents);
|
||||
$this->assertSame(
|
||||
'This is text for a description with an ',
|
||||
$parsedContents[0]
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$parsedContents[1]
|
||||
);
|
||||
$this->assertSame('.', $parsedContents[2]);
|
||||
|
||||
$this->assertSame(
|
||||
array('inline tag with literal
|
||||
{@link} in it'),
|
||||
$parsedContents[1]->getParsedDescription()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Covers Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\CoversTag can create
|
||||
* a link for the covers doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new CoversTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exReference, $tag->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exReference
|
||||
return array(
|
||||
array(
|
||||
'covers',
|
||||
'Foo::bar()',
|
||||
'Foo::bar()',
|
||||
'',
|
||||
'Foo::bar()'
|
||||
),
|
||||
array(
|
||||
'covers',
|
||||
'Foo::bar() Testing',
|
||||
'Foo::bar() Testing',
|
||||
'Testing',
|
||||
'Foo::bar()',
|
||||
),
|
||||
array(
|
||||
'covers',
|
||||
'Foo::bar() Testing comments',
|
||||
'Foo::bar() Testing comments',
|
||||
'Testing comments',
|
||||
'Foo::bar()',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Deprecated Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DeprecatedTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @deprecated doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exVersion
|
||||
) {
|
||||
$tag = new DeprecatedTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exVersion, $tag->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exVersion
|
||||
return array(
|
||||
array(
|
||||
'deprecated',
|
||||
'1.0 First release.',
|
||||
'1.0 First release.',
|
||||
'First release.',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'deprecated',
|
||||
"1.0\nFirst release.",
|
||||
"1.0\nFirst release.",
|
||||
'First release.',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'deprecated',
|
||||
"1.0\nFirst\nrelease.",
|
||||
"1.0\nFirst\nrelease.",
|
||||
"First\nrelease.",
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'deprecated',
|
||||
'Unfinished release',
|
||||
'Unfinished release',
|
||||
'Unfinished release',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'deprecated',
|
||||
'1.0',
|
||||
'1.0',
|
||||
'',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'deprecated',
|
||||
'GIT: $Id$',
|
||||
'GIT: $Id$',
|
||||
'',
|
||||
'GIT: $Id$'
|
||||
),
|
||||
array(
|
||||
'deprecated',
|
||||
'GIT: $Id$ Dev build',
|
||||
'GIT: $Id$ Dev build',
|
||||
'Dev build',
|
||||
'GIT: $Id$'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Example Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ExampleTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can
|
||||
* understand the @source DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exStartingLine
|
||||
* @param string $exLineCount
|
||||
* @param string $exFilepath
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exStartingLine,
|
||||
$exLineCount,
|
||||
$exFilePath
|
||||
) {
|
||||
$tag = new ExampleTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exStartingLine, $tag->getStartingLine());
|
||||
$this->assertEquals($exLineCount, $tag->getLineCount());
|
||||
$this->assertEquals($exFilePath, $tag->getFilePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type,
|
||||
// $content,
|
||||
// $exContent,
|
||||
// $exDescription,
|
||||
// $exStartingLine,
|
||||
// $exLineCount,
|
||||
// $exFilePath
|
||||
return array(
|
||||
array(
|
||||
'example',
|
||||
'file.php',
|
||||
'file.php',
|
||||
'',
|
||||
1,
|
||||
null,
|
||||
'file.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'Testing comments',
|
||||
'Testing comments',
|
||||
'comments',
|
||||
1,
|
||||
null,
|
||||
'Testing'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'file.php 2 Testing',
|
||||
'file.php 2 Testing',
|
||||
'Testing',
|
||||
2,
|
||||
null,
|
||||
'file.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'file.php 2 3 Testing comments',
|
||||
'file.php 2 3 Testing comments',
|
||||
'Testing comments',
|
||||
2,
|
||||
3,
|
||||
'file.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'file.php 2 -1 Testing comments',
|
||||
'file.php 2 -1 Testing comments',
|
||||
'-1 Testing comments',
|
||||
2,
|
||||
null,
|
||||
'file.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'file.php -1 1 Testing comments',
|
||||
'file.php -1 1 Testing comments',
|
||||
'-1 1 Testing comments',
|
||||
1,
|
||||
null,
|
||||
'file.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'"file with spaces.php" Testing comments',
|
||||
'"file with spaces.php" Testing comments',
|
||||
'Testing comments',
|
||||
1,
|
||||
null,
|
||||
'file with spaces.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'"file with spaces.php" 2 Testing comments',
|
||||
'"file with spaces.php" 2 Testing comments',
|
||||
'Testing comments',
|
||||
2,
|
||||
null,
|
||||
'file with spaces.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'"file with spaces.php" 2 3 Testing comments',
|
||||
'"file with spaces.php" 2 3 Testing comments',
|
||||
'Testing comments',
|
||||
2,
|
||||
3,
|
||||
'file with spaces.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'"file with spaces.php" 2 -3 Testing comments',
|
||||
'"file with spaces.php" 2 -3 Testing comments',
|
||||
'-3 Testing comments',
|
||||
2,
|
||||
null,
|
||||
'file with spaces.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'"file with spaces.php" -2 3 Testing comments',
|
||||
'"file with spaces.php" -2 3 Testing comments',
|
||||
'-2 3 Testing comments',
|
||||
1,
|
||||
null,
|
||||
'file with spaces.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'file%20with%20spaces.php Testing comments',
|
||||
'file%20with%20spaces.php Testing comments',
|
||||
'Testing comments',
|
||||
1,
|
||||
null,
|
||||
'file with spaces.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'folder/file%20with%20spaces.php Testing comments',
|
||||
'folder/file%20with%20spaces.php Testing comments',
|
||||
'Testing comments',
|
||||
1,
|
||||
null,
|
||||
'folder/file with spaces.php'
|
||||
),
|
||||
array(
|
||||
'example',
|
||||
'http://example.com/file%20with%20spaces.php Testing comments',
|
||||
'http://example.com/file%20with%20spaces.php Testing comments',
|
||||
'Testing comments',
|
||||
1,
|
||||
null,
|
||||
'http://example.com/file%20with%20spaces.php'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Link Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Ben Selby <benmatselby@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\LinkTag
|
||||
*
|
||||
* @author Ben Selby <benmatselby@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @link doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exDescription
|
||||
* @param string $exLink
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exLink
|
||||
) {
|
||||
$tag = new LinkTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exLink, $tag->getLink());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exLink
|
||||
return array(
|
||||
array(
|
||||
'link',
|
||||
'http://www.phpdoc.org/',
|
||||
'http://www.phpdoc.org/',
|
||||
'http://www.phpdoc.org/',
|
||||
'http://www.phpdoc.org/'
|
||||
),
|
||||
array(
|
||||
'link',
|
||||
'http://www.phpdoc.org/ Testing',
|
||||
'http://www.phpdoc.org/ Testing',
|
||||
'Testing',
|
||||
'http://www.phpdoc.org/'
|
||||
),
|
||||
array(
|
||||
'link',
|
||||
'http://www.phpdoc.org/ Testing comments',
|
||||
'http://www.phpdoc.org/ Testing comments',
|
||||
'Testing comments',
|
||||
'http://www.phpdoc.org/'
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Method Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @param string $signature The signature to test.
|
||||
* @param bool $valid Whether the given signature is expected to
|
||||
* be valid.
|
||||
* @param string $expected_name The method name that is expected from this
|
||||
* signature.
|
||||
* @param string $expected_return The return type that is expected from this
|
||||
* signature.
|
||||
* @param bool $paramCount Number of parameters in the signature.
|
||||
* @param string $description The short description mentioned in the
|
||||
* signature.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
|
||||
* @dataProvider getTestSignatures
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct(
|
||||
$signature,
|
||||
$valid,
|
||||
$expected_name,
|
||||
$expected_return,
|
||||
$expected_isStatic,
|
||||
$paramCount,
|
||||
$description
|
||||
) {
|
||||
ob_start();
|
||||
$tag = new MethodTag('method', $signature);
|
||||
$stdout = ob_get_clean();
|
||||
|
||||
$this->assertSame(
|
||||
$valid,
|
||||
empty($stdout),
|
||||
'No error should have been output if the signature is valid'
|
||||
);
|
||||
|
||||
if (!$valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->assertEquals($expected_name, $tag->getMethodName());
|
||||
$this->assertEquals($expected_return, $tag->getType());
|
||||
$this->assertEquals($description, $tag->getDescription());
|
||||
$this->assertEquals($expected_isStatic, $tag->isStatic());
|
||||
$this->assertCount($paramCount, $tag->getArguments());
|
||||
}
|
||||
|
||||
public function getTestSignatures()
|
||||
{
|
||||
return array(
|
||||
// TODO: Verify this case
|
||||
// array(
|
||||
// 'foo',
|
||||
// false, 'foo', '', false, 0, ''
|
||||
// ),
|
||||
array(
|
||||
'foo()',
|
||||
true, 'foo', 'void', false, 0, ''
|
||||
),
|
||||
array(
|
||||
'foo() description',
|
||||
true, 'foo', 'void', false, 0, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo()',
|
||||
true, 'foo', 'int', false, 0, ''
|
||||
),
|
||||
array(
|
||||
'int foo() description',
|
||||
true, 'foo', 'int', false, 0, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo($a, $b)',
|
||||
true, 'foo', 'int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo() foo(int $a, int $b)',
|
||||
true, 'foo', 'int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo(int $a, int $b)',
|
||||
true, 'foo', 'int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'null|int foo(int $a, int $b)',
|
||||
true, 'foo', 'null|int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo(null|int $a, int $b)',
|
||||
true, 'foo', 'int', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'\Exception foo() foo(Exception $a, Exception $b)',
|
||||
true, 'foo', '\Exception', false, 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo() foo(Exception $a, Exception $b) description',
|
||||
true, 'foo', 'int', false, 2, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo() foo(\Exception $a, \Exception $b) description',
|
||||
true, 'foo', 'int', false, 2, 'description'
|
||||
),
|
||||
array(
|
||||
'void()',
|
||||
true, 'void', 'void', false, 0, ''
|
||||
),
|
||||
array(
|
||||
'static foo()',
|
||||
true, 'foo', 'static', false, 0, ''
|
||||
),
|
||||
array(
|
||||
'static void foo()',
|
||||
true, 'foo', 'void', true, 0, ''
|
||||
),
|
||||
array(
|
||||
'static static foo()',
|
||||
true, 'foo', 'static', true, 0, ''
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Param tag test.
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ParamTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ParamTag can
|
||||
* understand the @param DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $extractedType
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedVarName
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$extractedType,
|
||||
$extractedTypes,
|
||||
$extractedVarName,
|
||||
$extractedDescription
|
||||
) {
|
||||
$tag = new ParamTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($extractedType, $tag->getType());
|
||||
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||
$this->assertEquals($extractedVarName, $tag->getVariableName());
|
||||
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParsesInputsIntoCorrectFields()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstructor()
|
||||
{
|
||||
return array(
|
||||
array('param', 'int', 'int', array('int'), '', ''),
|
||||
array('param', '$bob', '', array(), '$bob', ''),
|
||||
array(
|
||||
'param',
|
||||
'int Number of bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'int $bob',
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'int $bob Number of bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"int Description \n on multiple lines",
|
||||
'int',
|
||||
array('int'),
|
||||
'',
|
||||
"Description \n on multiple lines"
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"int \n\$bob Variable name on a new line",
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Variable name on a new line"
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"\nint \$bob Type on a new line",
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Type on a new line"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Return tag test.
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ReturnTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag can
|
||||
* understand the @return DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $extractedType
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$extractedType,
|
||||
$extractedTypes,
|
||||
$extractedDescription
|
||||
) {
|
||||
$tag = new ReturnTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($extractedType, $tag->getType());
|
||||
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParsesInputsIntoCorrectFields()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstructor()
|
||||
{
|
||||
return array(
|
||||
array('return', '', '', array(), ''),
|
||||
array('return', 'int', 'int', array('int'), ''),
|
||||
array(
|
||||
'return',
|
||||
'int Number of Bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'Number of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'int|double Number of Bobs',
|
||||
'int|double',
|
||||
array('int', 'double'),
|
||||
'Number of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
"int Number of \n Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of \n Bobs"
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
" int Number of Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
"int\nNumber of Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor See Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SeeTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
|
||||
* for the @see doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new SeeTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exReference, $tag->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exReference
|
||||
return array(
|
||||
array(
|
||||
'see',
|
||||
'Foo::bar()',
|
||||
'Foo::bar()',
|
||||
'',
|
||||
'Foo::bar()'
|
||||
),
|
||||
array(
|
||||
'see',
|
||||
'Foo::bar() Testing',
|
||||
'Foo::bar() Testing',
|
||||
'Testing',
|
||||
'Foo::bar()',
|
||||
),
|
||||
array(
|
||||
'see',
|
||||
'Foo::bar() Testing comments',
|
||||
'Foo::bar() Testing comments',
|
||||
'Testing comments',
|
||||
'Foo::bar()',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Since Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SinceTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @since doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exVersion
|
||||
) {
|
||||
$tag = new SinceTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exVersion, $tag->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exVersion
|
||||
return array(
|
||||
array(
|
||||
'since',
|
||||
'1.0 First release.',
|
||||
'1.0 First release.',
|
||||
'First release.',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'since',
|
||||
"1.0\nFirst release.",
|
||||
"1.0\nFirst release.",
|
||||
'First release.',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'since',
|
||||
"1.0\nFirst\nrelease.",
|
||||
"1.0\nFirst\nrelease.",
|
||||
"First\nrelease.",
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'since',
|
||||
'Unfinished release',
|
||||
'Unfinished release',
|
||||
'Unfinished release',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'since',
|
||||
'1.0',
|
||||
'1.0',
|
||||
'',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'since',
|
||||
'GIT: $Id$',
|
||||
'GIT: $Id$',
|
||||
'',
|
||||
'GIT: $Id$'
|
||||
),
|
||||
array(
|
||||
'since',
|
||||
'GIT: $Id$ Dev build',
|
||||
'GIT: $Id$ Dev build',
|
||||
'Dev build',
|
||||
'GIT: $Id$'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Source Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SourceTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class SourceTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can
|
||||
* understand the @source DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exStartingLine
|
||||
* @param string $exLineCount
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exStartingLine,
|
||||
$exLineCount
|
||||
) {
|
||||
$tag = new SourceTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exStartingLine, $tag->getStartingLine());
|
||||
$this->assertEquals($exLineCount, $tag->getLineCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exStartingLine, $exLineCount
|
||||
return array(
|
||||
array(
|
||||
'source',
|
||||
'2',
|
||||
'2',
|
||||
'',
|
||||
2,
|
||||
null
|
||||
),
|
||||
array(
|
||||
'source',
|
||||
'Testing',
|
||||
'Testing',
|
||||
'Testing',
|
||||
1,
|
||||
null
|
||||
),
|
||||
array(
|
||||
'source',
|
||||
'2 Testing',
|
||||
'2 Testing',
|
||||
'Testing',
|
||||
2,
|
||||
null
|
||||
),
|
||||
array(
|
||||
'source',
|
||||
'2 3 Testing comments',
|
||||
'2 3 Testing comments',
|
||||
'Testing comments',
|
||||
2,
|
||||
3
|
||||
),
|
||||
array(
|
||||
'source',
|
||||
'2 -1 Testing comments',
|
||||
'2 -1 Testing comments',
|
||||
'-1 Testing comments',
|
||||
2,
|
||||
null
|
||||
),
|
||||
array(
|
||||
'source',
|
||||
'-1 1 Testing comments',
|
||||
'-1 1 Testing comments',
|
||||
'-1 1 Testing comments',
|
||||
1,
|
||||
null
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Throws tag test.
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ThrowsTag
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ThrowsTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag can
|
||||
* understand the @throws DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $extractedType
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$extractedType,
|
||||
$extractedTypes,
|
||||
$extractedDescription
|
||||
) {
|
||||
$tag = new ThrowsTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($extractedType, $tag->getType());
|
||||
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParsesInputsIntoCorrectFields()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstructor()
|
||||
{
|
||||
return array(
|
||||
array('throws', '', '', array(), ''),
|
||||
array('throws', 'int', 'int', array('int'), ''),
|
||||
array(
|
||||
'throws',
|
||||
'int Number of Bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'Number of Bobs'
|
||||
),
|
||||
array(
|
||||
'throws',
|
||||
'int|double Number of Bobs',
|
||||
'int|double',
|
||||
array('int', 'double'),
|
||||
'Number of Bobs'
|
||||
),
|
||||
array(
|
||||
'throws',
|
||||
"int Number of \n Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of \n Bobs"
|
||||
),
|
||||
array(
|
||||
'throws',
|
||||
" int Number of Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
),
|
||||
array(
|
||||
'throws',
|
||||
"int\nNumber of Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Uses Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\UsesTag can create
|
||||
* a link for the @uses doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new UsesTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exReference, $tag->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exReference
|
||||
return array(
|
||||
array(
|
||||
'uses',
|
||||
'Foo::bar()',
|
||||
'Foo::bar()',
|
||||
'',
|
||||
'Foo::bar()'
|
||||
),
|
||||
array(
|
||||
'uses',
|
||||
'Foo::bar() Testing',
|
||||
'Foo::bar() Testing',
|
||||
'Testing',
|
||||
'Foo::bar()',
|
||||
),
|
||||
array(
|
||||
'uses',
|
||||
'Foo::bar() Testing comments',
|
||||
'Foo::bar() Testing comments',
|
||||
'Testing comments',
|
||||
'Foo::bar()',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Var Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
|
||||
* understand the @var doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exType
|
||||
* @param string $exVariable
|
||||
* @param string $exDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exType,
|
||||
$exVariable,
|
||||
$exDescription
|
||||
) {
|
||||
$tag = new VarTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exType, $tag->getType());
|
||||
$this->assertEquals($exVariable, $tag->getVariableName());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exType, $exVariable, $exDescription
|
||||
return array(
|
||||
array(
|
||||
'var',
|
||||
'int',
|
||||
'int',
|
||||
'',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'var',
|
||||
'int $bob',
|
||||
'int',
|
||||
'$bob',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'var',
|
||||
'int $bob Number of bobs',
|
||||
'int',
|
||||
'$bob',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'var',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
''
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Version Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VersionTag
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class VersionTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||
* a link for the @version doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exDescription
|
||||
* @param string $exVersion
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VersionTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exVersion
|
||||
) {
|
||||
$tag = new VersionTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exVersion, $tag->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exVersion
|
||||
return array(
|
||||
array(
|
||||
'version',
|
||||
'1.0 First release.',
|
||||
'1.0 First release.',
|
||||
'First release.',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'version',
|
||||
"1.0\nFirst release.",
|
||||
"1.0\nFirst release.",
|
||||
'First release.',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'version',
|
||||
"1.0\nFirst\nrelease.",
|
||||
"1.0\nFirst\nrelease.",
|
||||
"First\nrelease.",
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'version',
|
||||
'Unfinished release',
|
||||
'Unfinished release',
|
||||
'Unfinished release',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'version',
|
||||
'1.0',
|
||||
'1.0',
|
||||
'',
|
||||
'1.0'
|
||||
),
|
||||
array(
|
||||
'version',
|
||||
'GIT: $Id$',
|
||||
'GIT: $Id$',
|
||||
'',
|
||||
'GIT: $Id$'
|
||||
),
|
||||
array(
|
||||
'version',
|
||||
'GIT: $Id$ Dev build',
|
||||
'GIT: $Id$ Dev build',
|
||||
'Dev build',
|
||||
'GIT: $Id$'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,313 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Var Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
* @author Daniel O'Connor <daniel.oconnor@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class TagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTagLine()
|
||||
{
|
||||
Tag::createInstance('Invalid tag line');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagHandlerUnregistration()
|
||||
{
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreUnreg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreUnreg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreUnreg
|
||||
);
|
||||
|
||||
Tag::registerTagHandler('var', null);
|
||||
|
||||
$tagPostUnreg = Tag::createInstance('@var mixed');
|
||||
$this->assertNotInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostUnreg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostUnreg
|
||||
);
|
||||
|
||||
Tag::registerTagHandler('var', $currentHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagHandlerCorrectRegistration()
|
||||
{
|
||||
if (0 == ini_get('allow_url_include')) {
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
}
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
include 'data:text/plain;base64,'. base64_encode(
|
||||
<<<TAG_HANDLER
|
||||
<?php
|
||||
class MyTagHandler extends \phpDocumentor\Reflection\DocBlock\Tag {}
|
||||
TAG_HANDLER
|
||||
);
|
||||
|
||||
$this->assertTrue(Tag::registerTagHandler('var', '\MyTagHandler'));
|
||||
|
||||
$tagPostReg = Tag::createInstance('@var mixed');
|
||||
$this->assertNotInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPostReg
|
||||
);
|
||||
|
||||
$this->assertTrue(Tag::registerTagHandler('var', $currentHandler));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testTagHandlerCorrectRegistration
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNamespacedTagHandlerCorrectRegistration()
|
||||
{
|
||||
$tagPreReg = Tag::createInstance('@T something');
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertNotInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
Tag::registerTagHandler('\MyNamespace\MyTag', '\MyTagHandler')
|
||||
);
|
||||
|
||||
$tagPostReg = Tag::createInstance(
|
||||
'@T something',
|
||||
new DocBlock(
|
||||
'',
|
||||
new Context('', array('T' => '\MyNamespace\MyTag'))
|
||||
)
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPostReg
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
Tag::registerTagHandler('\MyNamespace\MyTag', null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testTagHandlerCorrectRegistration
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNamespacedTagHandlerIncorrectRegistration()
|
||||
{
|
||||
$tagPreReg = Tag::createInstance('@T something');
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertNotInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
Tag::registerTagHandler('MyNamespace\MyTag', '\MyTagHandler')
|
||||
);
|
||||
|
||||
$tagPostReg = Tag::createInstance(
|
||||
'@T something',
|
||||
new DocBlock(
|
||||
'',
|
||||
new Context('', array('T' => '\MyNamespace\MyTag'))
|
||||
)
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertNotInstanceOf(
|
||||
'\MyTagHandler',
|
||||
$tagPostReg
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNonExistentTagHandlerRegistration()
|
||||
{
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
$this->assertFalse(Tag::registerTagHandler('var', 'Non existent'));
|
||||
|
||||
$tagPostReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIncompatibleTagHandlerRegistration()
|
||||
{
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
Tag::registerTagHandler('var', __NAMESPACE__ . '\TagTest')
|
||||
);
|
||||
|
||||
$tagPostReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
|
||||
* understand the @var doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exDescription
|
||||
) {
|
||||
$tag = new Tag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($content, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exDescription
|
||||
return array(
|
||||
array(
|
||||
'unknown',
|
||||
'some content',
|
||||
'some content',
|
||||
),
|
||||
array(
|
||||
'unknown',
|
||||
'',
|
||||
'',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Collection Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Type;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Type\Collection
|
||||
*
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getContext
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$collection = new Collection();
|
||||
$this->assertCount(0, $collection);
|
||||
$this->assertEquals('', $collection->getContext()->getNamespace());
|
||||
$this->assertCount(0, $collection->getContext()->getNamespaceAliases());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithTypes()
|
||||
{
|
||||
$collection = new Collection(array('integer', 'string'));
|
||||
$this->assertCount(2, $collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithNamespace()
|
||||
{
|
||||
$collection = new Collection(array(), new Context('\My\Space'));
|
||||
$this->assertEquals('My\Space', $collection->getContext()->getNamespace());
|
||||
|
||||
$collection = new Collection(array(), new Context('My\Space'));
|
||||
$this->assertEquals('My\Space', $collection->getContext()->getNamespace());
|
||||
|
||||
$collection = new Collection(array(), null);
|
||||
$this->assertEquals('', $collection->getContext()->getNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithNamespaceAliases()
|
||||
{
|
||||
$fixture = array('a' => 'b');
|
||||
$collection = new Collection(array(), new Context(null, $fixture));
|
||||
$this->assertEquals(
|
||||
array('a' => '\b'),
|
||||
$collection->getContext()->getNamespaceAliases()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fixture
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpand
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAdd($fixture, $expected)
|
||||
{
|
||||
$collection = new Collection(
|
||||
array(),
|
||||
new Context('\My\Space', array('Alias' => '\My\Space\Aliasing'))
|
||||
);
|
||||
$collection->add($fixture);
|
||||
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fixture
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpandWithoutNamespace
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddWithoutNamespace($fixture, $expected)
|
||||
{
|
||||
$collection = new Collection(
|
||||
array(),
|
||||
new Context(null, array('Alias' => '\My\Space\Aliasing'))
|
||||
);
|
||||
$collection->add($fixture);
|
||||
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
* @expectedException InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddWithInvalidArgument()
|
||||
{
|
||||
$collection = new Collection();
|
||||
$collection->add(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the types and their expected values to test the retrieval of
|
||||
* types.
|
||||
*
|
||||
* @param string $method Name of the method consuming this data provider.
|
||||
* @param string $namespace Name of the namespace to user as basis.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function provideTypesToExpand($method, $namespace = '\My\Space\\')
|
||||
{
|
||||
return array(
|
||||
array('', array()),
|
||||
array(' ', array()),
|
||||
array('int', array('int')),
|
||||
array('int ', array('int')),
|
||||
array('string', array('string')),
|
||||
array('DocBlock', array($namespace.'DocBlock')),
|
||||
array('DocBlock[]', array($namespace.'DocBlock[]')),
|
||||
array(' DocBlock ', array($namespace.'DocBlock')),
|
||||
array('\My\Space\DocBlock', array('\My\Space\DocBlock')),
|
||||
array('Alias\DocBlock', array('\My\Space\Aliasing\DocBlock')),
|
||||
array(
|
||||
'DocBlock|Tag',
|
||||
array($namespace .'DocBlock', $namespace .'Tag')
|
||||
),
|
||||
array(
|
||||
'DocBlock|null',
|
||||
array($namespace.'DocBlock', 'null')
|
||||
),
|
||||
array(
|
||||
'\My\Space\DocBlock|Tag',
|
||||
array('\My\Space\DocBlock', $namespace.'Tag')
|
||||
),
|
||||
array(
|
||||
'DocBlock[]|null',
|
||||
array($namespace.'DocBlock[]', 'null')
|
||||
),
|
||||
array(
|
||||
'DocBlock[]|int[]',
|
||||
array($namespace.'DocBlock[]', 'int[]')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the types and their expected values to test the retrieval of
|
||||
* types when no namespace is available.
|
||||
*
|
||||
* @param string $method Name of the method consuming this data provider.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function provideTypesToExpandWithoutNamespace($method)
|
||||
{
|
||||
return $this->provideTypesToExpand($method, '\\');
|
||||
}
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor DocBlock Test
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use phpDocumentor\Reflection\DocBlock\Location;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag\ReturnTag;
|
||||
|
||||
/**
|
||||
* Test class for phpDocumentor\Reflection\DocBlock
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a short description
|
||||
*
|
||||
* This is a long description
|
||||
*
|
||||
* @see \MyClass
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock(
|
||||
$fixture,
|
||||
new Context('\MyNamespace', array('PHPDoc' => '\phpDocumentor')),
|
||||
new Location(2)
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a short description',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a long description',
|
||||
$object->getLongDescription()->getContents()
|
||||
);
|
||||
$this->assertCount(2, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('see'));
|
||||
$this->assertTrue($object->hasTag('return'));
|
||||
$this->assertFalse($object->hasTag('category'));
|
||||
|
||||
$this->assertSame('MyNamespace', $object->getContext()->getNamespace());
|
||||
$this->assertSame(
|
||||
array('PHPDoc' => '\phpDocumentor'),
|
||||
$object->getContext()->getNamespaceAliases()
|
||||
);
|
||||
$this->assertSame(2, $object->getLocation()->getLineNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::splitDocBlock
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithTagsOnly()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* @see \MyClass
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals('', $object->getShortDescription());
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertCount(2, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('see'));
|
||||
$this->assertTrue($object->hasTag('return'));
|
||||
$this->assertFalse($object->hasTag('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::isTemplateStart
|
||||
*/
|
||||
public function testIfStartOfTemplateIsDiscovered()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**#@+
|
||||
* @see \MyClass
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals('', $object->getShortDescription());
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertCount(2, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('see'));
|
||||
$this->assertTrue($object->hasTag('return'));
|
||||
$this->assertFalse($object->hasTag('category'));
|
||||
$this->assertTrue($object->isTemplateStart());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::isTemplateEnd
|
||||
*/
|
||||
public function testIfEndOfTemplateIsDiscovered()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**#@-*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals('', $object->getShortDescription());
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertTrue($object->isTemplateEnd());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::cleanInput
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructOneLiner()
|
||||
{
|
||||
$fixture = '/** Short description and nothing more. */';
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals(
|
||||
'Short description and nothing more.',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertCount(0, $object->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructFromReflector()
|
||||
{
|
||||
$object = new DocBlock(new \ReflectionClass($this));
|
||||
$this->assertEquals(
|
||||
'Test class for phpDocumentor\Reflection\DocBlock',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertCount(4, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('author'));
|
||||
$this->assertTrue($object->hasTag('copyright'));
|
||||
$this->assertTrue($object->hasTag('license'));
|
||||
$this->assertTrue($object->hasTag('link'));
|
||||
$this->assertFalse($object->hasTag('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionOnInvalidObject()
|
||||
{
|
||||
new DocBlock($this);
|
||||
}
|
||||
|
||||
public function testDotSeperation()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a short description.
|
||||
* This is a long description.
|
||||
* This is a continuation of the long description.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals(
|
||||
'This is a short description.',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals(
|
||||
"This is a long description.\nThis is a continuation of the long "
|
||||
."description.",
|
||||
$object->getLongDescription()->getContents()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
* @expectedException \LogicException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTagBlock()
|
||||
{
|
||||
if (0 == ini_get('allow_url_include')) {
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
}
|
||||
|
||||
include 'data:text/plain;base64,'. base64_encode(
|
||||
<<<DOCBLOCK_EXTENSION
|
||||
<?php
|
||||
class MyReflectionDocBlock extends \phpDocumentor\Reflection\DocBlock {
|
||||
protected function splitDocBlock(\$comment) {
|
||||
return array('', '', 'Invalid tag block');
|
||||
}
|
||||
}
|
||||
DOCBLOCK_EXTENSION
|
||||
);
|
||||
new \MyReflectionDocBlock('');
|
||||
|
||||
}
|
||||
|
||||
public function testTagCaseSensitivity()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a short description.
|
||||
*
|
||||
* This is a long description.
|
||||
*
|
||||
* @method null something()
|
||||
* @Method({"GET", "POST"})
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals(
|
||||
'This is a short description.',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a long description.',
|
||||
$object->getLongDescription()->getContents()
|
||||
);
|
||||
$tags = $object->getTags();
|
||||
$this->assertCount(2, $tags);
|
||||
$this->assertTrue($object->hasTag('method'));
|
||||
$this->assertTrue($object->hasTag('Method'));
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\DocBlock\Tag\MethodTag',
|
||||
$tags[0]
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\DocBlock\Tag',
|
||||
$tags[1]
|
||||
);
|
||||
$this->assertNotInstanceOf(
|
||||
__NAMESPACE__ . '\DocBlock\Tag\MethodTag',
|
||||
$tags[1]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstructFromReflector
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetTagsByNameZeroAndOneMatch()
|
||||
{
|
||||
$object = new DocBlock(new \ReflectionClass($this));
|
||||
$this->assertEmpty($object->getTagsByName('category'));
|
||||
$this->assertCount(1, $object->getTagsByName('author'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testParseMultilineTag()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* @return void Content on
|
||||
* multiple lines.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertCount(1, $object->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testParseMultilineTagWithLineBreaks()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* @return void Content on
|
||||
* multiple lines.
|
||||
*
|
||||
* One more, after the break.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertCount(1, $tags = $object->getTags());
|
||||
/** @var ReturnTag $tag */
|
||||
$tag = reset($tags);
|
||||
$this->assertEquals("Content on\n multiple lines.\n\n One more, after the break.", $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetTagsByNameMultipleMatch()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* @param string
|
||||
* @param int
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEmpty($object->getTagsByName('category'));
|
||||
$this->assertCount(1, $object->getTagsByName('return'));
|
||||
$this->assertCount(2, $object->getTagsByName('param'));
|
||||
}
|
||||
}
|
||||
174
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/DescriptionFactoryTest.php
vendored
Normal file
174
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/DescriptionFactoryTest.php
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Link;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class DescriptionFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @dataProvider provideSimpleExampleDescriptions
|
||||
*/
|
||||
public function testDescriptionCanParseASimpleString($contents)
|
||||
{
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$tagFactory->shouldReceive('create')->never();
|
||||
|
||||
$factory = new DescriptionFactory($tagFactory);
|
||||
$description = $factory->create($contents, new Context(''));
|
||||
|
||||
$this->assertSame($contents, $description->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @dataProvider provideEscapeSequences
|
||||
*/
|
||||
public function testEscapeSequences($contents, $expected)
|
||||
{
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$tagFactory->shouldReceive('create')->never();
|
||||
|
||||
$factory = new DescriptionFactory($tagFactory);
|
||||
$description = $factory->create($contents, new Context(''));
|
||||
|
||||
$this->assertSame($expected, $description->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Link
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testDescriptionCanParseAStringWithInlineTag()
|
||||
{
|
||||
$contents = 'This is text for a {@link http://phpdoc.org/ description} that uses an inline tag.';
|
||||
$context = new Context('');
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$tagFactory->shouldReceive('create')
|
||||
->once()
|
||||
->with('@link http://phpdoc.org/ description', $context)
|
||||
->andReturn(new Link('http://phpdoc.org/', new Description('description')))
|
||||
;
|
||||
|
||||
$factory = new DescriptionFactory($tagFactory);
|
||||
$description = $factory->create($contents, $context);
|
||||
|
||||
$this->assertSame($contents, $description->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Link
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testDescriptionCanParseAStringStartingWithInlineTag()
|
||||
{
|
||||
$contents = '{@link http://phpdoc.org/ This} is text for a description that starts with an inline tag.';
|
||||
$context = new Context('');
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$tagFactory->shouldReceive('create')
|
||||
->once()
|
||||
->with('@link http://phpdoc.org/ This', $context)
|
||||
->andReturn(new Link('http://phpdoc.org/', new Description('This')))
|
||||
;
|
||||
|
||||
$factory = new DescriptionFactory($tagFactory);
|
||||
$description = $factory->create($contents, $context);
|
||||
|
||||
$this->assertSame($contents, $description->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testIfSuperfluousStartingSpacesAreRemoved()
|
||||
{
|
||||
$factory = new DescriptionFactory(m::mock(TagFactory::class));
|
||||
$descriptionText = <<<DESCRIPTION
|
||||
This is a multiline
|
||||
description that you commonly
|
||||
see with tags.
|
||||
|
||||
It does have a multiline code sample
|
||||
that should align, no matter what
|
||||
|
||||
All spaces superfluous spaces on the
|
||||
second and later lines should be
|
||||
removed but the code sample should
|
||||
still be indented.
|
||||
DESCRIPTION;
|
||||
|
||||
$expectedDescription = <<<DESCRIPTION
|
||||
This is a multiline
|
||||
description that you commonly
|
||||
see with tags.
|
||||
|
||||
It does have a multiline code sample
|
||||
that should align, no matter what
|
||||
|
||||
All spaces superfluous spaces on the
|
||||
second and later lines should be
|
||||
removed but the code sample should
|
||||
still be indented.
|
||||
DESCRIPTION;
|
||||
|
||||
$description = $factory->create($descriptionText, new Context(''));
|
||||
|
||||
$this->assertSame($expectedDescription, $description->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a series of example strings that the parser should correctly interpret and return.
|
||||
*
|
||||
* @return string[][]
|
||||
*/
|
||||
public function provideSimpleExampleDescriptions()
|
||||
{
|
||||
return [
|
||||
['This is text for a description.'],
|
||||
['This is text for a description containing { that is literal.'],
|
||||
['This is text for a description containing } that is literal.'],
|
||||
['This is text for a description with {just a text} that is not a tag.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function provideEscapeSequences()
|
||||
{
|
||||
return [
|
||||
['This is text for a description with a {@}.', 'This is text for a description with a @.'],
|
||||
['This is text for a description with a {}.', 'This is text for a description with a }.'],
|
||||
];
|
||||
}
|
||||
}
|
||||
75
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/DescriptionTest.php
vendored
Normal file
75
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/DescriptionTest.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
class DescriptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::render
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
*/
|
||||
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 \phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
*/
|
||||
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([]);
|
||||
}
|
||||
}
|
||||
201
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/SerializerTest.php
vendored
Normal file
201
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/SerializerTest.php
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Serializer
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class SerializerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getDocComment
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses phpDocumentor\Reflection\DocBlock
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
*/
|
||||
public function testReconstructsADocCommentFromADocBlock()
|
||||
{
|
||||
$expected = <<<'DOCCOMMENT'
|
||||
/**
|
||||
* This is a summary
|
||||
*
|
||||
* This is a description
|
||||
*
|
||||
* @unknown-tag Test description for the unknown tag
|
||||
*/
|
||||
DOCCOMMENT;
|
||||
|
||||
$fixture = new Serializer();
|
||||
|
||||
$docBlock = new DocBlock(
|
||||
'This is a summary',
|
||||
new Description('This is a description'),
|
||||
[
|
||||
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDocComment($docBlock));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getDocComment
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses phpDocumentor\Reflection\DocBlock
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
*/
|
||||
public function testAddPrefixToDocBlock()
|
||||
{
|
||||
$expected = <<<'DOCCOMMENT'
|
||||
aa/**
|
||||
aa * This is a summary
|
||||
aa *
|
||||
aa * This is a description
|
||||
aa *
|
||||
aa * @unknown-tag Test description for the unknown tag
|
||||
aa */
|
||||
DOCCOMMENT;
|
||||
|
||||
$fixture = new Serializer(2, 'a');
|
||||
|
||||
$docBlock = new DocBlock(
|
||||
'This is a summary',
|
||||
new Description('This is a description'),
|
||||
[
|
||||
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDocComment($docBlock));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getDocComment
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses phpDocumentor\Reflection\DocBlock
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
*/
|
||||
public function testAddPrefixToDocBlockExceptFirstLine()
|
||||
{
|
||||
$expected = <<<'DOCCOMMENT'
|
||||
/**
|
||||
aa * This is a summary
|
||||
aa *
|
||||
aa * This is a description
|
||||
aa *
|
||||
aa * @unknown-tag Test description for the unknown tag
|
||||
aa */
|
||||
DOCCOMMENT;
|
||||
|
||||
$fixture = new Serializer(2, 'a', false);
|
||||
|
||||
$docBlock = new DocBlock(
|
||||
'This is a summary',
|
||||
new Description('This is a description'),
|
||||
[
|
||||
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDocComment($docBlock));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getDocComment
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses phpDocumentor\Reflection\DocBlock
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
*/
|
||||
public function testWordwrapsAroundTheGivenAmountOfCharacters()
|
||||
{
|
||||
$expected = <<<'DOCCOMMENT'
|
||||
/**
|
||||
* This is a
|
||||
* summary
|
||||
*
|
||||
* This is a
|
||||
* description
|
||||
*
|
||||
* @unknown-tag
|
||||
* Test
|
||||
* description
|
||||
* for the
|
||||
* unknown tag
|
||||
*/
|
||||
DOCCOMMENT;
|
||||
|
||||
$fixture = new Serializer(0, '', true, 15);
|
||||
|
||||
$docBlock = new DocBlock(
|
||||
'This is a summary',
|
||||
new Description('This is a description'),
|
||||
[
|
||||
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDocComment($docBlock));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInitializationFailsIfIndentIsNotAnInteger()
|
||||
{
|
||||
new Serializer([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInitializationFailsIfIndentStringIsNotAString()
|
||||
{
|
||||
new Serializer(0, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInitializationFailsIfIndentFirstLineIsNotABoolean()
|
||||
{
|
||||
new Serializer(0, '', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInitializationFailsIfLineLengthIsNotNullNorAnInteger()
|
||||
{
|
||||
new Serializer(0, '', false, []);
|
||||
}
|
||||
}
|
||||
361
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/StandardTagFactoryTest.php
vendored
Normal file
361
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/StandardTagFactoryTest.php
vendored
Normal file
@@ -0,0 +1,361 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Author;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||
use phpDocumentor\Reflection\Fqsen;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass phpDocumentor\Reflection\DocBlock\StandardTagFactory
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testCreatingAGenericTag()
|
||||
{
|
||||
$expectedTagName = 'unknown-tag';
|
||||
$expectedDescriptionText = 'This is a description';
|
||||
$expectedDescription = new Description($expectedDescriptionText);
|
||||
$context = new Context('');
|
||||
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory
|
||||
->shouldReceive('create')
|
||||
->once()
|
||||
->with($expectedDescriptionText, $context)
|
||||
->andReturn($expectedDescription)
|
||||
;
|
||||
|
||||
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
|
||||
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
|
||||
|
||||
/** @var Generic $tag */
|
||||
$tag = $tagFactory->create('@' . $expectedTagName . ' This is a description', $context);
|
||||
|
||||
$this->assertInstanceOf(Generic::class, $tag);
|
||||
$this->assertSame($expectedTagName, $tag->getName());
|
||||
$this->assertSame($expectedDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Author
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*/
|
||||
public function testCreatingASpecificTag()
|
||||
{
|
||||
$context = new Context('');
|
||||
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
|
||||
|
||||
/** @var Author $tag */
|
||||
$tag = $tagFactory->create('@author Mike van Riel <me@mikevanriel.com>', $context);
|
||||
|
||||
$this->assertInstanceOf(Author::class, $tag);
|
||||
$this->assertSame('author', $tag->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\See
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*/
|
||||
public function testAnEmptyContextIsCreatedIfNoneIsProvided()
|
||||
{
|
||||
$fqsen = '\Tag';
|
||||
$resolver = m::mock(FqsenResolver::class)
|
||||
->shouldReceive('resolve')
|
||||
->with('Tag', m::type(Context::class))
|
||||
->andReturn(new Fqsen($fqsen))
|
||||
->getMock()
|
||||
;
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory->shouldIgnoreMissing();
|
||||
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
|
||||
|
||||
/** @var See $tag */
|
||||
$tag = $tagFactory->create('@see Tag');
|
||||
|
||||
$this->assertInstanceOf(See::class, $tag);
|
||||
$this->assertSame($fqsen, (string)$tag->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Author
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
*/
|
||||
public function testPassingYourOwnSetOfTagHandlers()
|
||||
{
|
||||
$context = new Context('');
|
||||
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class), ['user' => Author::class]);
|
||||
|
||||
/** @var Author $tag */
|
||||
$tag = $tagFactory->create('@user Mike van Riel <me@mikevanriel.com>', $context);
|
||||
|
||||
$this->assertInstanceOf(Author::class, $tag);
|
||||
$this->assertSame('author', $tag->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The tag "@user/myuser" does not seem to be wellformed, please check it for errors
|
||||
*/
|
||||
public function testExceptionIsThrownIfProvidedTagIsNotWellformed()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'For some reason this test fails; once I have access to a RegEx analyzer I will have to test the regex'
|
||||
)
|
||||
;
|
||||
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
|
||||
$tagFactory->create('@user[myuser');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::addParameter
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
*/
|
||||
public function testAddParameterToServiceLocator()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
$tagFactory->addParameter('myParam', 'myValue');
|
||||
|
||||
$this->assertAttributeSame(
|
||||
[FqsenResolver::class => $resolver, 'myParam' => 'myValue'],
|
||||
'serviceLocator',
|
||||
$tagFactory
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::addService
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
*/
|
||||
public function testAddServiceToServiceLocator()
|
||||
{
|
||||
$service = new PassthroughFormatter();
|
||||
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
$tagFactory->addService($service);
|
||||
|
||||
$this->assertAttributeSame(
|
||||
[FqsenResolver::class => $resolver, PassthroughFormatter::class => $service],
|
||||
'serviceLocator',
|
||||
$tagFactory
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::addService
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
*/
|
||||
public function testInjectConcreteServiceForInterfaceToServiceLocator()
|
||||
{
|
||||
$interfaceName = Formatter::class;
|
||||
$service = new PassthroughFormatter();
|
||||
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
$tagFactory->addService($service, $interfaceName);
|
||||
|
||||
$this->assertAttributeSame(
|
||||
[FqsenResolver::class => $resolver, $interfaceName => $service],
|
||||
'serviceLocator',
|
||||
$tagFactory
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::registerTagHandler
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Author
|
||||
*/
|
||||
public function testRegisteringAHandlerForANewTag()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
|
||||
$tagFactory->registerTagHandler('my-tag', Author::class);
|
||||
|
||||
// Assert by trying to create one
|
||||
$tag = $tagFactory->create('@my-tag Mike van Riel <me@mikevanriel.com>');
|
||||
$this->assertInstanceOf(Author::class, $tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::registerTagHandler
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testHandlerRegistrationFailsIfProvidedTagNameIsNotAString()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
|
||||
$tagFactory->registerTagHandler([], Author::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::registerTagHandler
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testHandlerRegistrationFailsIfProvidedTagNameIsEmpty()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
|
||||
$tagFactory->registerTagHandler('', Author::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::registerTagHandler
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testHandlerRegistrationFailsIfProvidedTagNameIsNamespaceButNotFullyQualified()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
|
||||
$tagFactory->registerTagHandler('Name\Spaced\Tag', Author::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::registerTagHandler
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testHandlerRegistrationFailsIfProvidedHandlerIsNotAString()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
|
||||
$tagFactory->registerTagHandler('my-tag', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::registerTagHandler
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testHandlerRegistrationFailsIfProvidedHandlerIsEmpty()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
|
||||
$tagFactory->registerTagHandler('my-tag', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::registerTagHandler
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testHandlerRegistrationFailsIfProvidedHandlerIsNotAnExistingClassName()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
|
||||
$tagFactory->registerTagHandler('my-tag', 'IDoNotExist');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::registerTagHandler
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testHandlerRegistrationFailsIfProvidedHandlerDoesNotImplementTheTagInterface()
|
||||
{
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$tagFactory = new StandardTagFactory($resolver);
|
||||
|
||||
$tagFactory->registerTagHandler('my-tag', 'stdClass');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||
* @uses phpDocumentor\Reflection\Docblock\Description
|
||||
* @uses phpDocumentor\Reflection\Docblock\Tags\Return_
|
||||
* @uses phpDocumentor\Reflection\Docblock\Tags\BaseTag
|
||||
*/
|
||||
public function testReturntagIsMappedCorrectly()
|
||||
{
|
||||
$context = new Context('');
|
||||
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory
|
||||
->shouldReceive('create')
|
||||
->once()
|
||||
->with('', $context)
|
||||
->andReturn(new Description(''))
|
||||
;
|
||||
|
||||
$typeResolver = new TypeResolver();
|
||||
|
||||
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
|
||||
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
|
||||
$tagFactory->addService($typeResolver, TypeResolver::class);
|
||||
|
||||
|
||||
/** @var Return_ $tag */
|
||||
$tag = $tagFactory->create('@return mixed', $context);
|
||||
|
||||
$this->assertInstanceOf(Return_::class, $tag);
|
||||
$this->assertSame('return', $tag->getName());
|
||||
}
|
||||
}
|
||||
148
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/AuthorTest.php
vendored
Normal file
148
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/AuthorTest.php
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Author
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class AuthorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Author('Mike van Riel', 'mike@phpdoc.org');
|
||||
|
||||
$this->assertSame('author', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Author('Mike van Riel', 'mike@phpdoc.org');
|
||||
|
||||
$this->assertSame('@author Mike van Riel<mike@phpdoc.org>', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Author('Mike van Riel', 'mike@phpdoc.org');
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getAuthorName
|
||||
*/
|
||||
public function testHasTheAuthorName()
|
||||
{
|
||||
$expected = 'Mike van Riel';
|
||||
|
||||
$fixture = new Author($expected, 'mike@phpdoc.org');
|
||||
|
||||
$this->assertSame($expected, $fixture->getAuthorName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getAuthorName
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInitializationFailsIfAuthorNameIsNotAString()
|
||||
{
|
||||
new Author([], 'mike@phpdoc.org');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getEmail
|
||||
*/
|
||||
public function testHasTheAuthorMailAddress()
|
||||
{
|
||||
$expected = 'mike@phpdoc.org';
|
||||
|
||||
$fixture = new Author('Mike van Riel', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getEmail());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInitializationFailsIfEmailIsNotAString()
|
||||
{
|
||||
new Author('Mike van Riel', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInitializationFailsIfEmailIsNotValid()
|
||||
{
|
||||
new Author('Mike van Riel', 'mike');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Author('Mike van Riel', 'mike@phpdoc.org');
|
||||
|
||||
$this->assertSame('Mike van Riel<mike@phpdoc.org>', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::<public>
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$fixture = Author::create('Mike van Riel <mike@phpdoc.org>');
|
||||
|
||||
$this->assertSame('Mike van Riel<mike@phpdoc.org>', (string)$fixture);
|
||||
$this->assertSame('Mike van Riel', $fixture->getAuthorName());
|
||||
$this->assertSame('mike@phpdoc.org', $fixture->getEmail());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::<public>
|
||||
*/
|
||||
public function testFactoryMethodReturnsNullIfItCouldNotReadBody()
|
||||
{
|
||||
$this->assertNull(Author::create('dfgr<'));
|
||||
}
|
||||
}
|
||||
155
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/CoversTest.php
vendored
Normal file
155
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/CoversTest.php
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Fqsen;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Covers
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class CoversTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('covers', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('@covers \DateTime Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getReference
|
||||
*/
|
||||
public function testHasReferenceToFqsen()
|
||||
{
|
||||
$expected = new Fqsen('\DateTime');
|
||||
|
||||
$fixture = new Covers($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Covers(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('\DateTime Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Covers::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Fqsen
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$context = new Context('');
|
||||
|
||||
$fqsen = new Fqsen('\DateTime');
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory
|
||||
->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
$resolver->shouldReceive('resolve')->with('DateTime', $context)->andReturn($fqsen);
|
||||
|
||||
$fixture = Covers::create('DateTime My Description', $descriptionFactory, $resolver, $context);
|
||||
|
||||
$this->assertSame('\DateTime My Description', (string)$fixture);
|
||||
$this->assertSame($fqsen, $fixture->getReference());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
$this->assertNull(Covers::create([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotEmpty()
|
||||
{
|
||||
$this->assertNull(Covers::create(''));
|
||||
}
|
||||
}
|
||||
166
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/DeprecatedTest.php
vendored
Normal file
166
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/DeprecatedTest.php
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Deprecated
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class DeprecatedTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Deprecated('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('deprecated', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Deprecated('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('@deprecated 1.0 Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Deprecated('1.0', new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getVersion
|
||||
*/
|
||||
public function testHasVersionNumber()
|
||||
{
|
||||
$expected = '1.0';
|
||||
|
||||
$fixture = new Deprecated($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Deprecated('1.0', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Deprecated('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('1.0 Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$version = '1.0';
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Deprecated::create('1.0 My Description', $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('1.0 My Description', (string)$fixture);
|
||||
$this->assertSame($version, $fixture->getVersion());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethodCreatesEmptyDeprecatedTag()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory->shouldReceive('create')->never();
|
||||
|
||||
$fixture = Deprecated::create('', $descriptionFactory, new Context(''));
|
||||
|
||||
$this->assertSame('', (string)$fixture);
|
||||
$this->assertSame(null, $fixture->getVersion());
|
||||
$this->assertSame(null, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfVersionIsNotString()
|
||||
{
|
||||
$this->assertNull(Deprecated::create([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex()
|
||||
{
|
||||
$this->assertNull(Deprecated::create('dkhf<'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
*/
|
||||
class PassthroughFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::format
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
*/
|
||||
public function testFormatterCallsToStringAndReturnsAStandardRepresentation()
|
||||
{
|
||||
$expected = '@unknown-tag This is a description';
|
||||
|
||||
$fixture = new PassthroughFormatter();
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$fixture->format(new Generic('unknown-tag', new Description('This is a description')))
|
||||
);
|
||||
}
|
||||
}
|
||||
146
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/GenericTest.php
vendored
Normal file
146
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/GenericTest.php
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
<?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
|
||||
* @generic http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class GenericTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Generic('generic', new Description('Description'));
|
||||
|
||||
$this->assertSame('generic', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Generic('generic', new Description('Description'));
|
||||
|
||||
$this->assertSame('@generic Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Generic('generic', new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Generic('generic', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Generic('generic', new Description('Description'));
|
||||
|
||||
$this->assertSame('Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$generics = 'generic';
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Generic::create('My Description', 'generic', $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('My Description', (string)$fixture);
|
||||
$this->assertSame($generics, $fixture->getName());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfNameIsNotString()
|
||||
{
|
||||
Generic::create('', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfNameIsNotEmpty()
|
||||
{
|
||||
Generic::create('', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfNameContainsIllegalCharacters()
|
||||
{
|
||||
Generic::create('', 'name/myname');
|
||||
}
|
||||
}
|
||||
158
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/LinkTest.php
vendored
Normal file
158
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/LinkTest.php
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Link
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class LinkTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Link('http://this.is.my/link', new Description('Description'));
|
||||
|
||||
$this->assertSame('link', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Link('http://this.is.my/link', new Description('Description'));
|
||||
|
||||
$this->assertSame('@link http://this.is.my/link Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Link('http://this.is.my/link', new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getLink
|
||||
*/
|
||||
public function testHasLinkUrl()
|
||||
{
|
||||
$expected = 'http://this.is.my/link';
|
||||
|
||||
$fixture = new Link($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getLink());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Link('http://this.is.my/link', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Link('http://this.is.my/link', new Description('Description'));
|
||||
|
||||
$this->assertSame('http://this.is.my/link Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$links = 'http://this.is.my/link';
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Link::create('http://this.is.my/link My Description', $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('http://this.is.my/link My Description', (string)$fixture);
|
||||
$this->assertSame($links, $fixture->getLink());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethodCreatesEmptyLinkTag()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory->shouldReceive('create')->never();
|
||||
|
||||
$fixture = Link::create('', $descriptionFactory, new Context(''));
|
||||
|
||||
$this->assertSame('', (string)$fixture);
|
||||
$this->assertSame('', $fixture->getLink());
|
||||
$this->assertSame(null, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfVersionIsNotString()
|
||||
{
|
||||
$this->assertNull(Link::create([]));
|
||||
}
|
||||
}
|
||||
410
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/MethodTest.php
vendored
Normal file
410
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/MethodTest.php
vendored
Normal file
@@ -0,0 +1,410 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Array_;
|
||||
use phpDocumentor\Reflection\Types\Compound;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\Object_;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
use phpDocumentor\Reflection\Types\Void_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Method
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Method('myMethod');
|
||||
|
||||
$this->assertSame('method', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::isStatic
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$arguments = [
|
||||
['name' => 'argument1', 'type' => new String_()],
|
||||
['name' => 'argument2', 'type' => new Object_()]
|
||||
];
|
||||
$fixture = new Method('myMethod', $arguments, new Void_(), true, new Description('My Description'));
|
||||
|
||||
$this->assertSame(
|
||||
'@method static void myMethod(string $argument1, object $argument2) My Description',
|
||||
$fixture->render()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Method('myMethod');
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getMethodName
|
||||
*/
|
||||
public function testHasMethodName()
|
||||
{
|
||||
$expected = 'myMethod';
|
||||
|
||||
$fixture = new Method($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getMethodName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getArguments
|
||||
*/
|
||||
public function testHasArguments()
|
||||
{
|
||||
$arguments = [
|
||||
[ 'name' => 'argument1', 'type' => new String_() ]
|
||||
];
|
||||
|
||||
$fixture = new Method('myMethod', $arguments);
|
||||
|
||||
$this->assertSame($arguments, $fixture->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getArguments
|
||||
*/
|
||||
public function testArgumentsMayBePassedAsString()
|
||||
{
|
||||
$arguments = ['argument1'];
|
||||
$expected = [
|
||||
[ 'name' => $arguments[0], 'type' => new Void_() ]
|
||||
];
|
||||
|
||||
$fixture = new Method('myMethod', $arguments);
|
||||
|
||||
$this->assertEquals($expected, $fixture->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getArguments
|
||||
*/
|
||||
public function testArgumentTypeCanBeInferredAsVoid()
|
||||
{
|
||||
$arguments = [ [ 'name' => 'argument1' ] ];
|
||||
$expected = [
|
||||
[ 'name' => $arguments[0]['name'], 'type' => new Void_() ]
|
||||
];
|
||||
|
||||
$fixture = new Method('myMethod', $arguments);
|
||||
|
||||
$this->assertEquals($expected, $fixture->getArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getReturnType
|
||||
*/
|
||||
public function testHasReturnType()
|
||||
{
|
||||
$expected = new String_();
|
||||
|
||||
$fixture = new Method('myMethod', [], $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getReturnType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getReturnType
|
||||
*/
|
||||
public function testReturnTypeCanBeInferredAsVoid()
|
||||
{
|
||||
$fixture = new Method('myMethod', []);
|
||||
|
||||
$this->assertEquals(new Void_(), $fixture->getReturnType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::isStatic
|
||||
*/
|
||||
public function testMethodCanBeStatic()
|
||||
{
|
||||
$expected = false;
|
||||
$fixture = new Method('myMethod', [], null, $expected);
|
||||
$this->assertSame($expected, $fixture->isStatic());
|
||||
|
||||
$expected = true;
|
||||
$fixture = new Method('myMethod', [], null, $expected);
|
||||
$this->assertSame($expected, $fixture->isStatic());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Method('myMethod', [], null, false, $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::isStatic
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$arguments = [
|
||||
['name' => 'argument1', 'type' => new String_()],
|
||||
['name' => 'argument2', 'type' => new Object_()]
|
||||
];
|
||||
$fixture = new Method('myMethod', $arguments, new Void_(), true, new Description('My Description'));
|
||||
|
||||
$this->assertSame(
|
||||
'static void myMethod(string $argument1, object $argument2) My Description',
|
||||
(string)$fixture
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Fqsen
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$expectedArguments = [
|
||||
[ 'name' => 'argument1', 'type' => new String_() ],
|
||||
[ 'name' => 'argument2', 'type' => new Void_() ]
|
||||
];
|
||||
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Method::create(
|
||||
'static void myMethod(string $argument1, $argument2) My Description',
|
||||
$resolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('static void myMethod(string $argument1, void $argument2) My Description', (string)$fixture);
|
||||
$this->assertSame('myMethod', $fixture->getMethodName());
|
||||
$this->assertEquals($expectedArguments, $fixture->getArguments());
|
||||
$this->assertInstanceOf(Void_::class, $fixture->getReturnType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
public function collectionReturnTypesProvider()
|
||||
{
|
||||
return [
|
||||
['int[]', Array_::class, Integer::class, Compound::class],
|
||||
['int[][]', Array_::class, Array_::class, Compound::class],
|
||||
['Object[]', Array_::class, Object_::class, Compound::class],
|
||||
['array[]', Array_::class, Array_::class, Compound::class],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider collectionReturnTypesProvider
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\Types\Array_
|
||||
* @uses \phpDocumentor\Reflection\Types\Compound
|
||||
* @uses \phpDocumentor\Reflection\Types\Integer
|
||||
* @uses \phpDocumentor\Reflection\Types\Object_
|
||||
* @param string $returnType
|
||||
* @param string $expectedType
|
||||
* @param string $expectedValueType
|
||||
* @param string null $expectedKeyType
|
||||
*/
|
||||
public function testCollectionReturnTypes(
|
||||
$returnType,
|
||||
$expectedType,
|
||||
$expectedValueType = null,
|
||||
$expectedKeyType = null
|
||||
) { $resolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory->shouldReceive('create')->with('', null)->andReturn(new Description(''));
|
||||
|
||||
$fixture = Method::create("$returnType myMethod(\$arg)", $resolver, $descriptionFactory);
|
||||
$returnType = $fixture->getReturnType();
|
||||
$this->assertInstanceOf($expectedType, $returnType);
|
||||
|
||||
if ($returnType instanceof Array_) {
|
||||
$this->assertInstanceOf($expectedValueType, $returnType->getValueType());
|
||||
$this->assertInstanceOf($expectedKeyType, $returnType->getKeyType());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
Method::create([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsEmpty()
|
||||
{
|
||||
Method::create('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodReturnsNullIfBodyIsIncorrect()
|
||||
{
|
||||
$this->assertNull(Method::create('body('));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
Method::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
Method::create('body', new TypeResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCreationFailsIfBodyIsNotString()
|
||||
{
|
||||
new Method([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCreationFailsIfBodyIsEmpty()
|
||||
{
|
||||
new Method('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCreationFailsIfStaticIsNotBoolean()
|
||||
{
|
||||
new Method('body', [], null, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCreationFailsIfArgumentRecordContainsInvalidEntry()
|
||||
{
|
||||
new Method('body', [ [ 'name' => 'myName', 'unknown' => 'nah' ] ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Fqsen
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testCreateMethodParenthesisMissing()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Method::create(
|
||||
'static void myMethod My Description',
|
||||
$resolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('static void myMethod() My Description', (string)$fixture);
|
||||
$this->assertSame('myMethod', $fixture->getMethodName());
|
||||
$this->assertEquals([], $fixture->getArguments());
|
||||
$this->assertInstanceOf(Void_::class, $fixture->getReturnType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
}
|
||||
228
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/ParamTest.php
vendored
Normal file
228
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/ParamTest.php
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Param
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class ParamTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Param('myParameter', null, false, new Description('Description'));
|
||||
|
||||
$this->assertSame('param', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::isVariadic
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Param('myParameter', new String_(), true, new Description('Description'));
|
||||
$this->assertSame('@param string ...$myParameter Description', $fixture->render());
|
||||
|
||||
$fixture = new Param('myParameter', new String_(), false, new Description('Description'));
|
||||
$this->assertSame('@param string $myParameter Description', $fixture->render());
|
||||
|
||||
$fixture = new Param('myParameter', null, false, new Description('Description'));
|
||||
$this->assertSame('@param $myParameter Description', $fixture->render());
|
||||
|
||||
$fixture = new Param('myParameter');
|
||||
$this->assertSame('@param $myParameter', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Param('myParameter');
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getVariableName
|
||||
*/
|
||||
public function testHasVariableName()
|
||||
{
|
||||
$expected = 'myParameter';
|
||||
|
||||
$fixture = new Param($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getVariableName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getType
|
||||
*/
|
||||
public function testHasType()
|
||||
{
|
||||
$expected = new String_();
|
||||
|
||||
$fixture = new Param('myParameter', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::isVariadic
|
||||
*/
|
||||
public function testIfParameterIsVariadic()
|
||||
{
|
||||
$fixture = new Param('myParameter', new String_(), false);
|
||||
$this->assertFalse($fixture->isVariadic());
|
||||
|
||||
$fixture = new Param('myParameter', new String_(), true);
|
||||
$this->assertTrue($fixture->isVariadic());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Param('1.0', null, false, $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::isVariadic
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Param('myParameter', new String_(), true, new Description('Description'));
|
||||
|
||||
$this->assertSame('string ...$myParameter Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Param::create('string ...$myParameter My Description', $typeResolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string ...$myParameter My Description', (string)$fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertTrue($fixture->isVariadic());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
Param::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
Param::create([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
Param::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
Param::create('body', new TypeResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfVariableNameIsNotString()
|
||||
{
|
||||
new Param([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfVariadicIsNotBoolean()
|
||||
{
|
||||
new Param('', null, []);
|
||||
}
|
||||
}
|
||||
201
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/PropertyReadTest.php
vendored
Normal file
201
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/PropertyReadTest.php
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class PropertyReadTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new PropertyRead('myProperty', null, new Description('Description'));
|
||||
|
||||
$this->assertSame('property-read', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new PropertyRead('myProperty', new String_(), new Description('Description'));
|
||||
$this->assertSame('@property-read string $myProperty Description', $fixture->render());
|
||||
|
||||
$fixture = new PropertyRead('myProperty', null, new Description('Description'));
|
||||
$this->assertSame('@property-read $myProperty Description', $fixture->render());
|
||||
|
||||
$fixture = new PropertyRead('myProperty');
|
||||
$this->assertSame('@property-read $myProperty', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new PropertyRead('myProperty');
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getVariableName
|
||||
*/
|
||||
public function testHasVariableName()
|
||||
{
|
||||
$expected = 'myProperty';
|
||||
|
||||
$fixture = new PropertyRead($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getVariableName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getType
|
||||
*/
|
||||
public function testHasType()
|
||||
{
|
||||
$expected = new String_();
|
||||
|
||||
$fixture = new PropertyRead('myProperty', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new PropertyRead('1.0', null, $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new PropertyRead('myProperty', new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('string $myProperty Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = PropertyRead::create('string $myProperty My Description', $typeResolver, $descriptionFactory,
|
||||
$context);
|
||||
|
||||
$this->assertSame('string $myProperty My Description', (string)$fixture);
|
||||
$this->assertSame('myProperty', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
PropertyRead::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
PropertyRead::create([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
PropertyRead::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
PropertyRead::create('body', new TypeResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfVariableNameIsNotString()
|
||||
{
|
||||
new PropertyRead([]);
|
||||
}
|
||||
}
|
||||
200
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/PropertyTest.php
vendored
Normal file
200
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/PropertyTest.php
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Property
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Property('myProperty', null, new Description('Description'));
|
||||
|
||||
$this->assertSame('property', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Property('myProperty', new String_(), new Description('Description'));
|
||||
$this->assertSame('@property string $myProperty Description', $fixture->render());
|
||||
|
||||
$fixture = new Property('myProperty', null, new Description('Description'));
|
||||
$this->assertSame('@property $myProperty Description', $fixture->render());
|
||||
|
||||
$fixture = new Property('myProperty');
|
||||
$this->assertSame('@property $myProperty', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Property('myProperty');
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getVariableName
|
||||
*/
|
||||
public function testHasVariableName()
|
||||
{
|
||||
$expected = 'myProperty';
|
||||
|
||||
$fixture = new Property($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getVariableName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getType
|
||||
*/
|
||||
public function testHasType()
|
||||
{
|
||||
$expected = new String_();
|
||||
|
||||
$fixture = new Property('myProperty', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Property('1.0', null, $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Property('myProperty', new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('string $myProperty Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Property::create('string $myProperty My Description', $typeResolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string $myProperty My Description', (string)$fixture);
|
||||
$this->assertSame('myProperty', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
Property::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
Property::create([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
Property::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
Property::create('body', new TypeResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfVariableNameIsNotString()
|
||||
{
|
||||
new Property([]);
|
||||
}
|
||||
}
|
||||
201
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/PropertyWriteTest.php
vendored
Normal file
201
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/PropertyWriteTest.php
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class PropertyWriteTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new PropertyWrite('myProperty', null, new Description('Description'));
|
||||
|
||||
$this->assertSame('property-write', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new PropertyWrite('myProperty', new String_(), new Description('Description'));
|
||||
$this->assertSame('@property-write string $myProperty Description', $fixture->render());
|
||||
|
||||
$fixture = new PropertyWrite('myProperty', null, new Description('Description'));
|
||||
$this->assertSame('@property-write $myProperty Description', $fixture->render());
|
||||
|
||||
$fixture = new PropertyWrite('myProperty');
|
||||
$this->assertSame('@property-write $myProperty', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new PropertyWrite('myProperty');
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getVariableName
|
||||
*/
|
||||
public function testHasVariableName()
|
||||
{
|
||||
$expected = 'myProperty';
|
||||
|
||||
$fixture = new PropertyWrite($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getVariableName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getType
|
||||
*/
|
||||
public function testHasType()
|
||||
{
|
||||
$expected = new String_();
|
||||
|
||||
$fixture = new PropertyWrite('myProperty', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new PropertyWrite('1.0', null, $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new PropertyWrite('myProperty', new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('string $myProperty Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = PropertyWrite::create('string $myProperty My Description', $typeResolver, $descriptionFactory,
|
||||
$context);
|
||||
|
||||
$this->assertSame('string $myProperty My Description', (string)$fixture);
|
||||
$this->assertSame('myProperty', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
PropertyWrite::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
PropertyWrite::create([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
PropertyWrite::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
PropertyWrite::create('body', new TypeResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfVariableNameIsNotString()
|
||||
{
|
||||
new PropertyWrite([]);
|
||||
}
|
||||
}
|
||||
170
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/ReturnTest.php
vendored
Normal file
170
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/ReturnTest.php
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Return_
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class ReturnTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Return_(new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('return', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Return_(new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('@return string Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Return_(new String_(), new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getType
|
||||
*/
|
||||
public function testHasType()
|
||||
{
|
||||
$expected = new String_();
|
||||
|
||||
$fixture = new Return_($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Return_(new String_(), $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Return_(new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('string Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
|
||||
$type = new String_();
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Return_::create('string My Description', $resolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string My Description', (string)$fixture);
|
||||
$this->assertEquals($type, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
$this->assertNull(Return_::create([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotEmpty()
|
||||
{
|
||||
$this->assertNull(Return_::create(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
Return_::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
Return_::create('body', new TypeResolver());
|
||||
}
|
||||
}
|
||||
173
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/SeeTest.php
vendored
Normal file
173
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/SeeTest.php
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Fqsen;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\See
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class SeeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new See(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('see', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new See(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('@see \DateTime Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new See(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getReference
|
||||
*/
|
||||
public function testHasReferenceToFqsen()
|
||||
{
|
||||
$expected = new Fqsen('\DateTime');
|
||||
|
||||
$fixture = new See($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new See(new Fqsen('\DateTime'), $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new See(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('\DateTime Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Fqsen
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$context = new Context('');
|
||||
|
||||
$fqsen = new Fqsen('\DateTime');
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory
|
||||
->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
$resolver->shouldReceive('resolve')->with('DateTime', $context)->andReturn($fqsen);
|
||||
|
||||
$fixture = See::create('DateTime My Description', $resolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('\DateTime My Description', (string)$fixture);
|
||||
$this->assertSame($fqsen, $fixture->getReference());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
$this->assertNull(See::create([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotEmpty()
|
||||
{
|
||||
$this->assertNull(See::create(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
See::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
See::create('body', new FqsenResolver());
|
||||
}
|
||||
}
|
||||
166
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/SinceTest.php
vendored
Normal file
166
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/SinceTest.php
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Since
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class SinceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Since('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('since', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Since('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('@since 1.0 Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Since('1.0', new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getVersion
|
||||
*/
|
||||
public function testHasVersionNumber()
|
||||
{
|
||||
$expected = '1.0';
|
||||
|
||||
$fixture = new Since($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Since('1.0', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Since('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('1.0 Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$version = '1.0';
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Since::create('1.0 My Description', $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('1.0 My Description', (string)$fixture);
|
||||
$this->assertSame($version, $fixture->getVersion());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethodCreatesEmptySinceTag()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory->shouldReceive('create')->never();
|
||||
|
||||
$fixture = Since::create('', $descriptionFactory, new Context(''));
|
||||
|
||||
$this->assertSame('', (string)$fixture);
|
||||
$this->assertSame(null, $fixture->getVersion());
|
||||
$this->assertSame(null, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfSinceIsNotString()
|
||||
{
|
||||
$this->assertNull(Since::create([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex()
|
||||
{
|
||||
$this->assertNull(Since::create('dkhf<'));
|
||||
}
|
||||
}
|
||||
199
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/SourceTest.php
vendored
Normal file
199
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/SourceTest.php
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Source
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class SourceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Source(1, null, new Description('Description'));
|
||||
|
||||
$this->assertSame('source', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Source(1, 10, new Description('Description'));
|
||||
$this->assertSame('@source 1 10 Description', $fixture->render());
|
||||
|
||||
$fixture = new Source(1, null, new Description('Description'));
|
||||
$this->assertSame('@source 1 Description', $fixture->render());
|
||||
|
||||
$fixture = new Source(1);
|
||||
$this->assertSame('@source 1', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Source(1);
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getStartingLine
|
||||
*/
|
||||
public function testHasStartingLine()
|
||||
{
|
||||
$expected = 1;
|
||||
|
||||
$fixture = new Source($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getStartingLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getLineCount
|
||||
*/
|
||||
public function testHasLineCount()
|
||||
{
|
||||
$expected = 2;
|
||||
|
||||
$fixture = new Source(1, $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getLineCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Source('1', null, $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Source(1, 10, new Description('Description'));
|
||||
|
||||
$this->assertSame('1 10 Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Source::create('1 10 My Description', $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('1 10 My Description', (string)$fixture);
|
||||
$this->assertSame(1, $fixture->getStartingLine());
|
||||
$this->assertSame(10, $fixture->getLineCount());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
Source::create('', $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
Source::create([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
Source::create('1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfStartingLineIsNotInteger()
|
||||
{
|
||||
new Source('blabla');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfLineCountIsNotIntegerOrNull()
|
||||
{
|
||||
new Source('1', []);
|
||||
}
|
||||
}
|
||||
170
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/ThrowsTest.php
vendored
Normal file
170
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/ThrowsTest.php
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Throws
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class ThrowsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Throws(new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('throws', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Throws(new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('@throws string Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Throws(new String_(), new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getType
|
||||
*/
|
||||
public function testHasType()
|
||||
{
|
||||
$expected = new String_();
|
||||
|
||||
$fixture = new Throws($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Throws(new String_(), $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Throws(new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('string Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Throws::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
|
||||
$type = new String_();
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Throws::create('string My Description', $resolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string My Description', (string)$fixture);
|
||||
$this->assertEquals($type, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
$this->assertNull(Throws::create([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotEmpty()
|
||||
{
|
||||
$this->assertNull(Throws::create(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
Throws::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
Throws::create('body', new TypeResolver());
|
||||
}
|
||||
}
|
||||
174
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/UsesTest.php
vendored
Normal file
174
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/UsesTest.php
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Fqsen;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Uses
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class UsesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Uses(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('uses', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Uses(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('@uses \DateTime Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Uses(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getReference
|
||||
*/
|
||||
public function testHasReferenceToFqsen()
|
||||
{
|
||||
$expected = new Fqsen('\DateTime');
|
||||
|
||||
$fixture = new Uses($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Uses(new Fqsen('\DateTime'), $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Uses(new Fqsen('\DateTime'), new Description('Description'));
|
||||
|
||||
$this->assertSame('\DateTime Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Fqsen
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = m::mock(FqsenResolver::class);
|
||||
$context = new Context('');
|
||||
|
||||
$fqsen = new Fqsen('\DateTime');
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory
|
||||
->shouldReceive('create')->with('My Description', $context)->andReturn($description)
|
||||
;
|
||||
$resolver->shouldReceive('resolve')->with('DateTime', $context)->andReturn($fqsen);
|
||||
|
||||
$fixture = Uses::create('DateTime My Description', $resolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('\DateTime My Description', (string)$fixture);
|
||||
$this->assertSame($fqsen, $fixture->getReference());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
$this->assertNull(Uses::create([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotEmpty()
|
||||
{
|
||||
$this->assertNull(Uses::create(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
Uses::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
Uses::create('body', new FqsenResolver());
|
||||
}
|
||||
}
|
||||
200
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/VarTest.php
vendored
Normal file
200
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/VarTest.php
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Var_
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class VarTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Var_('myVariable', null, new Description('Description'));
|
||||
|
||||
$this->assertSame('var', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Var_('myVariable', new String_(), new Description('Description'));
|
||||
$this->assertSame('@var string $myVariable Description', $fixture->render());
|
||||
|
||||
$fixture = new Var_('myVariable', null, new Description('Description'));
|
||||
$this->assertSame('@var $myVariable Description', $fixture->render());
|
||||
|
||||
$fixture = new Var_('myVariable');
|
||||
$this->assertSame('@var $myVariable', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Var_('myVariable');
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getVariableName
|
||||
*/
|
||||
public function testHasVariableName()
|
||||
{
|
||||
$expected = 'myVariable';
|
||||
|
||||
$fixture = new Var_($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getVariableName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getType
|
||||
*/
|
||||
public function testHasType()
|
||||
{
|
||||
$expected = new String_();
|
||||
|
||||
$fixture = new Var_('myVariable', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Var_('1.0', null, $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Var_('myVariable', new String_(), new Description('Description'));
|
||||
|
||||
$this->assertSame('string $myVariable Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Var_::create('string $myVariable My Description', $typeResolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string $myVariable My Description', (string)$fixture);
|
||||
$this->assertSame('myVariable', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
Var_::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotString()
|
||||
{
|
||||
Var_::create([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull()
|
||||
{
|
||||
Var_::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull()
|
||||
{
|
||||
Var_::create('body', new TypeResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfVariableNameIsNotString()
|
||||
{
|
||||
new Var_([]);
|
||||
}
|
||||
}
|
||||
166
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/VersionTest.php
vendored
Normal file
166
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlock/Tags/VersionTest.php
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
<?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 phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\Version
|
||||
* @covers ::<private>
|
||||
*/
|
||||
class VersionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfCorrectTagNameIsReturned()
|
||||
{
|
||||
$fixture = new Version('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('version', $fixture->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingDefaultFormatter()
|
||||
{
|
||||
$fixture = new Version('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('@version 1.0 Description', $fixture->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::__construct
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
|
||||
*/
|
||||
public function testIfTagCanBeRenderedUsingSpecificFormatter()
|
||||
{
|
||||
$fixture = new Version('1.0', new Description('Description'));
|
||||
|
||||
$formatter = m::mock(Formatter::class);
|
||||
$formatter->shouldReceive('format')->with($fixture)->andReturn('Rendered output');
|
||||
|
||||
$this->assertSame('Rendered output', $fixture->render($formatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getVersion
|
||||
*/
|
||||
public function testHasVersionNumber()
|
||||
{
|
||||
$expected = '1.0';
|
||||
|
||||
$fixture = new Version($expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getDescription
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testHasDescription()
|
||||
{
|
||||
$expected = new Description('Description');
|
||||
|
||||
$fixture = new Version('1.0', $expected);
|
||||
|
||||
$this->assertSame($expected, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::__toString
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testStringRepresentationIsReturned()
|
||||
{
|
||||
$fixture = new Version('1.0', new Description('Description'));
|
||||
|
||||
$this->assertSame('1.0 Description', (string)$fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethod()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$version = '1.0';
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Version::create('1.0 My Description', $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('1.0 My Description', (string)$fixture);
|
||||
$this->assertSame($version, $fixture->getVersion());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testFactoryMethodCreatesEmptyVersionTag()
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory->shouldReceive('create')->never();
|
||||
|
||||
$fixture = Version::create('', $descriptionFactory, new Context(''));
|
||||
|
||||
$this->assertSame('', (string)$fixture);
|
||||
$this->assertSame(null, $fixture->getVersion());
|
||||
$this->assertSame(null, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testFactoryMethodFailsIfVersionIsNotString()
|
||||
{
|
||||
$this->assertNull(Version::create([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex()
|
||||
{
|
||||
$this->assertNull(Version::create('dkhf<'));
|
||||
}
|
||||
}
|
||||
290
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlockFactoryTest.php
vendored
Normal file
290
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlockFactoryTest.php
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
<?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 phpDocumentor\Reflection;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\TagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass phpDocumentor\Reflection\DocBlockFactory
|
||||
* @covers ::<private>
|
||||
* @uses \Webmozart\Assert\Assert
|
||||
* @uses phpDocumentor\Reflection\DocBlock
|
||||
*/
|
||||
class DocBlockFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::createInstance
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
*/
|
||||
public function testCreateFactoryUsingFactoryMethod()
|
||||
{
|
||||
$fixture = DocBlockFactory::createInstance();
|
||||
|
||||
$this->assertInstanceOf(DocBlockFactory::class, $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testCreateDocBlockFromReflection()
|
||||
{
|
||||
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
|
||||
|
||||
$docBlock = '/** This is a DocBlock */';
|
||||
$classReflector = m::mock(\ReflectionClass::class);
|
||||
$classReflector->shouldReceive('getDocComment')->andReturn($docBlock);
|
||||
$docblock = $fixture->create($classReflector);
|
||||
|
||||
$this->assertInstanceOf(DocBlock::class, $docblock);
|
||||
$this->assertSame('This is a DocBlock', $docblock->getSummary());
|
||||
$this->assertEquals(new Description(''), $docblock->getDescription());
|
||||
$this->assertSame([], $docblock->getTags());
|
||||
$this->assertEquals(new Context(''), $docblock->getContext());
|
||||
$this->assertNull($docblock->getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testCreateDocBlockFromStringWithDocComment()
|
||||
{
|
||||
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
|
||||
|
||||
$docblock = $fixture->create('/** This is a DocBlock */');
|
||||
|
||||
$this->assertInstanceOf(DocBlock::class, $docblock);
|
||||
$this->assertSame('This is a DocBlock', $docblock->getSummary());
|
||||
$this->assertEquals(new Description(''), $docblock->getDescription());
|
||||
$this->assertSame([], $docblock->getTags());
|
||||
$this->assertEquals(new Context(''), $docblock->getContext());
|
||||
$this->assertNull($docblock->getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testCreateDocBlockFromStringWithoutDocComment()
|
||||
{
|
||||
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
|
||||
|
||||
$docblock = $fixture->create('This is a DocBlock');
|
||||
|
||||
$this->assertInstanceOf(DocBlock::class, $docblock);
|
||||
$this->assertSame('This is a DocBlock', $docblock->getSummary());
|
||||
$this->assertEquals(new Description(''), $docblock->getDescription());
|
||||
$this->assertSame([], $docblock->getTags());
|
||||
$this->assertEquals(new Context(''), $docblock->getContext());
|
||||
$this->assertNull($docblock->getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @dataProvider provideSummaryAndDescriptions
|
||||
*/
|
||||
public function testSummaryAndDescriptionAreSeparated($given, $summary, $description)
|
||||
{
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
|
||||
|
||||
$docblock = $fixture->create($given);
|
||||
|
||||
$this->assertSame($summary, $docblock->getSummary());
|
||||
$this->assertEquals(new Description($description), $docblock->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDescriptionsRetainFormatting()
|
||||
{
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
|
||||
|
||||
$given = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a summary.
|
||||
* This is a multiline Description
|
||||
* that contains a code block.
|
||||
*
|
||||
* See here: a CodeBlock
|
||||
*/
|
||||
DOCBLOCK;
|
||||
|
||||
$description = <<<DESCRIPTION
|
||||
This is a multiline Description
|
||||
that contains a code block.
|
||||
|
||||
See here: a CodeBlock
|
||||
DESCRIPTION;
|
||||
|
||||
$docblock = $fixture->create($given);
|
||||
|
||||
$this->assertEquals(new Description($description), $docblock->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testTagsAreInterpretedUsingFactory()
|
||||
{
|
||||
$tagString = <<<TAG
|
||||
@author Mike van Riel <me@mikevanriel.com> This is with
|
||||
multiline description.
|
||||
TAG;
|
||||
|
||||
$tag = m::mock(Tag::class);
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$tagFactory->shouldReceive('create')->with($tagString, m::type(Context::class))->andReturn($tag);
|
||||
|
||||
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
|
||||
|
||||
$given = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a summary.
|
||||
*
|
||||
* @author Mike van Riel <me@mikevanriel.com> This is with
|
||||
* multiline description.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
|
||||
$docblock = $fixture->create($given, new Context(''));
|
||||
|
||||
$this->assertEquals([$tag], $docblock->getTags());
|
||||
}
|
||||
|
||||
public function provideSummaryAndDescriptions()
|
||||
{
|
||||
return [
|
||||
['This is a DocBlock', 'This is a DocBlock', ''],
|
||||
[
|
||||
'This is a DocBlock. This should still be summary.',
|
||||
'This is a DocBlock. This should still be summary.',
|
||||
''
|
||||
],
|
||||
[
|
||||
<<<DOCBLOCK
|
||||
This is a DocBlock.
|
||||
This should be a Description.
|
||||
DOCBLOCK
|
||||
,
|
||||
'This is a DocBlock.',
|
||||
'This should be a Description.'
|
||||
],
|
||||
[
|
||||
<<<DOCBLOCK
|
||||
This is a
|
||||
multiline Summary.
|
||||
This should be a Description.
|
||||
DOCBLOCK
|
||||
,
|
||||
"This is a\nmultiline Summary.",
|
||||
'This should be a Description.'
|
||||
],
|
||||
[
|
||||
<<<DOCBLOCK
|
||||
This is a Summary without dot but with a whiteline
|
||||
|
||||
This should be a Description.
|
||||
DOCBLOCK
|
||||
,
|
||||
'This is a Summary without dot but with a whiteline',
|
||||
'This should be a Description.'
|
||||
],
|
||||
[
|
||||
<<<DOCBLOCK
|
||||
This is a Summary with dot and with a whiteline.
|
||||
|
||||
This should be a Description.
|
||||
DOCBLOCK
|
||||
,
|
||||
'This is a Summary with dot and with a whiteline.',
|
||||
'This should be a Description.'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
*
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses phpDocumentor\Reflection\Types\Context
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Param
|
||||
*/
|
||||
public function testTagsWithContextNamespace()
|
||||
{
|
||||
$tagFactoryMock = m::mock(TagFactory::class);
|
||||
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), $tagFactoryMock);
|
||||
$context = new Context('MyNamespace');
|
||||
|
||||
$tagFactoryMock->shouldReceive('create')->with(m::any(), $context)->andReturn(new Param('param'));
|
||||
$docblock = $fixture->create('/** @param MyType $param */', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
*
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testTagsAreFilteredForNullValues()
|
||||
{
|
||||
$tagString = <<<TAG
|
||||
@author Mike van Riel <me@mikevanriel.com> This is with
|
||||
multiline description.
|
||||
TAG;
|
||||
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$tagFactory->shouldReceive('create')->with($tagString, m::any())->andReturn(null);
|
||||
|
||||
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
|
||||
|
||||
$given = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a summary.
|
||||
*
|
||||
* @author Mike van Riel <me@mikevanriel.com> This is with
|
||||
* multiline description.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
|
||||
$docblock = $fixture->create($given, new Context(''));
|
||||
|
||||
$this->assertEquals([], $docblock->getTags());
|
||||
}
|
||||
}
|
||||
252
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlockTest.php
vendored
Normal file
252
vendor/phpdocumentor/reflection-docblock/tests/unit/DocBlockTest.php
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
<?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 phpDocumentor\Reflection;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass phpDocumentor\Reflection\DocBlock
|
||||
* @covers ::<private>
|
||||
* @uses \Webmozart\Assert\Assert
|
||||
*/
|
||||
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getSummary
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDocBlockCanHaveASummary()
|
||||
{
|
||||
$summary = 'This is a summary';
|
||||
|
||||
$fixture = new DocBlock($summary);
|
||||
|
||||
$this->assertSame($summary, $fixture->getSummary());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfSummaryIsNotAString()
|
||||
{
|
||||
new DocBlock([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfTemplateStartIsNotABoolean()
|
||||
{
|
||||
new DocBlock('', null, [], null, null, ['is not boolean']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfTemplateEndIsNotABoolean()
|
||||
{
|
||||
new DocBlock('', null, [], null, null, false, ['is not boolean']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getDescription
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDocBlockCanHaveADescription()
|
||||
{
|
||||
$description = new DocBlock\Description('');
|
||||
|
||||
$fixture = new DocBlock('', $description);
|
||||
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getTags
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tag
|
||||
*/
|
||||
public function testDocBlockCanHaveTags()
|
||||
{
|
||||
$tags = [
|
||||
m::mock(DocBlock\Tag::class)
|
||||
];
|
||||
|
||||
$fixture = new DocBlock('', null, $tags);
|
||||
|
||||
$this->assertSame($tags, $fixture->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getTags
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tag
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testDocBlockAllowsOnlyTags()
|
||||
{
|
||||
$tags = [
|
||||
null
|
||||
];
|
||||
|
||||
$fixture = new DocBlock('', null, $tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getTagsByName
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock::getTags
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tag
|
||||
*/
|
||||
public function testFindTagsInDocBlockByName()
|
||||
{
|
||||
$tag1 = m::mock(DocBlock\Tag::class);
|
||||
$tag2 = m::mock(DocBlock\Tag::class);
|
||||
$tag3 = m::mock(DocBlock\Tag::class);
|
||||
$tags = [$tag1, $tag2, $tag3];
|
||||
|
||||
$tag1->shouldReceive('getName')->andReturn('abc');
|
||||
$tag2->shouldReceive('getName')->andReturn('abcd');
|
||||
$tag3->shouldReceive('getName')->andReturn('ab');
|
||||
|
||||
$fixture = new DocBlock('', null, $tags);
|
||||
|
||||
$this->assertSame([$tag2], $fixture->getTagsByName('abcd'));
|
||||
$this->assertSame([], $fixture->getTagsByName('Ebcd'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getTagsByName
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfNameForTagsIsNotString()
|
||||
{
|
||||
$fixture = new DocBlock();
|
||||
$fixture->getTagsByName([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::hasTag
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock::getTags
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tag
|
||||
*/
|
||||
public function testCheckIfThereAreTagsWithAGivenName()
|
||||
{
|
||||
$tag1 = m::mock(DocBlock\Tag::class);
|
||||
$tag2 = m::mock(DocBlock\Tag::class);
|
||||
$tag3 = m::mock(DocBlock\Tag::class);
|
||||
$tags = [$tag1, $tag2, $tag3];
|
||||
|
||||
$tag1->shouldReceive('getName')->twice()->andReturn('abc');
|
||||
$tag2->shouldReceive('getName')->twice()->andReturn('abcd');
|
||||
$tag3->shouldReceive('getName')->once();
|
||||
|
||||
$fixture = new DocBlock('', null, $tags);
|
||||
|
||||
$this->assertTrue($fixture->hasTag('abcd'));
|
||||
$this->assertFalse($fixture->hasTag('Ebcd'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::hasTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfNameForCheckingTagsIsNotString()
|
||||
{
|
||||
$fixture = new DocBlock();
|
||||
$fixture->hasTag([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getContext
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testDocBlockKnowsInWhichNamespaceItIsAndWhichAliasesThereAre()
|
||||
{
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = new DocBlock('', null, [], $context);
|
||||
|
||||
$this->assertSame($context, $fixture->getContext());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getLocation
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Location
|
||||
*/
|
||||
public function testDocBlockKnowsAtWhichLineItIs()
|
||||
{
|
||||
$location = new Location(10);
|
||||
|
||||
$fixture = new DocBlock('', null, [], null, $location);
|
||||
|
||||
$this->assertSame($location, $fixture->getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::isTemplateStart
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDocBlockKnowsIfItIsTheStartOfADocBlockTemplate()
|
||||
{
|
||||
$fixture = new DocBlock('', null, [], null, null, true);
|
||||
|
||||
$this->assertTrue($fixture->isTemplateStart());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::isTemplateEnd
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate()
|
||||
{
|
||||
$fixture = new DocBlock('', null, [], null, null, false, true);
|
||||
|
||||
$this->assertTrue($fixture->isTemplateEnd());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user