update v 1.0.7.5
This commit is contained in:
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<'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user