Laravel version update
Laravel version update
This commit is contained in:
3
vendor/phpdocumentor/reflection-docblock/.coveralls.yml
vendored
Normal file
3
vendor/phpdocumentor/reflection-docblock/.coveralls.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
service_name: travis-ci
|
||||
coverage_clover: coverage.xml
|
||||
json_path: coverage.json
|
@@ -1,2 +0,0 @@
|
||||
.idea
|
||||
vendor
|
@@ -1,32 +0,0 @@
|
||||
before_commands:
|
||||
- "composer install --no-dev --prefer-source"
|
||||
|
||||
tools:
|
||||
external_code_coverage: true
|
||||
php_code_sniffer:
|
||||
enabled: true
|
||||
config:
|
||||
standard: PSR2
|
||||
filter:
|
||||
paths: ["src/*", "tests/*"]
|
||||
php_cpd:
|
||||
enabled: true
|
||||
excluded_dirs: ["tests", "vendor"]
|
||||
php_loc:
|
||||
enabled: true
|
||||
excluded_dirs: ["tests", "vendor"]
|
||||
php_mess_detector:
|
||||
enabled: true
|
||||
config:
|
||||
ruleset: phpmd.xml.dist
|
||||
design_rules: { eval_expression: false }
|
||||
filter:
|
||||
paths: ["src/*"]
|
||||
php_pdepend:
|
||||
enabled: true
|
||||
excluded_dirs: ["tests", "vendor"]
|
||||
php_analyzer:
|
||||
enabled: true
|
||||
filter:
|
||||
paths: ["src/*", "tests/*"]
|
||||
sensiolabs_security_checker: true
|
@@ -1,36 +0,0 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
- nightly
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php:
|
||||
- hhvm
|
||||
- nightly
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit --coverage-clover=coverage.clover -v
|
||||
- composer update --no-interaction --prefer-source
|
||||
- vendor/bin/phpunit -v
|
||||
|
||||
before_script:
|
||||
- composer install --no-interaction
|
||||
|
||||
after_script:
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#phpdocumentor"
|
||||
email:
|
||||
- mike.vanriel@naenius.com
|
||||
- ashnazg@php.net
|
||||
- boen.robot@gmail.com
|
@@ -10,16 +10,12 @@ that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest
|
||||
With this component, a library can provide support for annotations via DocBlocks
|
||||
or otherwise retrieve information that is embedded in a DocBlock.
|
||||
|
||||
> **Note**: *this is a core component of phpDocumentor and is constantly being
|
||||
> optimized for performance.*
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
You can install the component in the following ways:
|
||||
|
||||
* Use the official Github repository (https://github.com/phpDocumentor/ReflectionDocBlock)
|
||||
* Via Composer (http://packagist.org/packages/phpdocumentor/reflection-docblock)
|
||||
```bash
|
||||
composer require phpdocumentor/reflection-docblock
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
@@ -52,18 +48,20 @@ $docblock = $factory->create($docComment);
|
||||
```
|
||||
|
||||
The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock`
|
||||
whose methods can be queried as shown in the following example.
|
||||
whose methods can be queried:
|
||||
|
||||
```php
|
||||
// Should contain the summary for this DocBlock
|
||||
// Contains the summary for this DocBlock
|
||||
$summary = $docblock->getSummary();
|
||||
|
||||
// Contains an object of type \phpDocumentor\Reflection\DocBlock\Description;
|
||||
// you can either cast it to string or use the render method to get a string
|
||||
// representation of the Description.
|
||||
// Contains \phpDocumentor\Reflection\DocBlock\Description object
|
||||
$description = $docblock->getDescription();
|
||||
|
||||
// You can either cast it to string
|
||||
$description = (string) $docblock->getDescription();
|
||||
|
||||
// Or use the render method to get a string representation of the Description.
|
||||
$description = $docblock->getDescription()->render();
|
||||
```
|
||||
|
||||
> For more examples it would be best to review the scripts in the `/examples`
|
||||
> folder.
|
||||
|
||||
> For more examples it would be best to review the scripts in the [`/examples` folder](/examples).
|
||||
|
@@ -10,9 +10,9 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5",
|
||||
"phpdocumentor/reflection-common": "^1.0@dev",
|
||||
"phpdocumentor/type-resolver": "^0.2.0",
|
||||
"php": "^7.0",
|
||||
"phpdocumentor/reflection-common": "^1.0.0",
|
||||
"phpdocumentor/type-resolver": "^0.4.0",
|
||||
"webmozart/assert": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
@@ -22,7 +22,13 @@
|
||||
"psr-4": {"phpDocumentor\\Reflection\\": ["tests/unit"]}
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^0.9.4",
|
||||
"phpunit/phpunit": "^4.4"
|
||||
"mockery/mockery": "^1.0",
|
||||
"phpunit/phpunit": "^6.4",
|
||||
"doctrine/instantiator": "~1.0.5"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1120
vendor/phpdocumentor/reflection-docblock/composer.lock
generated
vendored
1120
vendor/phpdocumentor/reflection-docblock/composer.lock
generated
vendored
File diff suppressed because it is too large
Load Diff
31
vendor/phpdocumentor/reflection-docblock/easy-coding-standard.neon
vendored
Normal file
31
vendor/phpdocumentor/reflection-docblock/easy-coding-standard.neon
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
includes:
|
||||
- temp/ecs/config/clean-code.neon
|
||||
- temp/ecs/config/psr2-checkers.neon
|
||||
- temp/ecs/config/spaces.neon
|
||||
- temp/ecs/config/common.neon
|
||||
|
||||
checkers:
|
||||
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
|
||||
spacing: one
|
||||
|
||||
parameters:
|
||||
exclude_checkers:
|
||||
# from temp/ecs/config/common.neon
|
||||
- PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer
|
||||
- PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer
|
||||
- PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer
|
||||
# from temp/ecs/config/spaces.neon
|
||||
- PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer
|
||||
|
||||
skip:
|
||||
SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff:
|
||||
# WIP code
|
||||
- src/DocBlock/StandardTagFactory.php
|
||||
PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff:
|
||||
# WIP code
|
||||
- src/DocBlock/StandardTagFactory.php
|
||||
PHP_CodeSniffer\Standards\Squiz\Sniffs\Classes\ValidClassNameSniff:
|
||||
- src/DocBlock/Tags/Return_.php
|
||||
- src/DocBlock/Tags/Var_.php
|
||||
PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff:
|
||||
- */tests/**
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
|
||||
$docComment = <<<DOCCOMMENT
|
||||
/**
|
||||
* This is an example of a summary.
|
||||
*
|
||||
* This is a Description. A Summary and Description are separated by either
|
||||
* two subsequent newlines (thus a whiteline in between as can be seen in this
|
||||
* example), or when the Summary ends with a dot (`.`) and some form of
|
||||
* whitespace.
|
||||
*/
|
||||
DOCCOMMENT;
|
||||
|
||||
$factory = DocBlockFactory::createInstance();
|
||||
$docblock = $factory->create($docComment);
|
||||
|
||||
// Should contain the first line of the DocBlock
|
||||
$summary = $docblock->getSummary();
|
||||
|
||||
// Contains an object of type Description; you can either cast it to string or use
|
||||
// the render method to get a string representation of the Description.
|
||||
//
|
||||
// In subsequent examples we will be fiddling a bit more with the Description.
|
||||
$description = $docblock->getDescription();
|
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
|
||||
$docComment = <<<DOCCOMMENT
|
||||
/**
|
||||
* This is an example of a summary.
|
||||
*
|
||||
* @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
|
||||
*/
|
||||
DOCCOMMENT;
|
||||
|
||||
$factory = DocBlockFactory::createInstance();
|
||||
$docblock = $factory->create($docComment);
|
||||
|
||||
// You can check if a DocBlock has one or more see tags
|
||||
$hasSeeTag = $docblock->hasTag('see');
|
||||
|
||||
// Or we can get a complete list of all tags
|
||||
$tags = $docblock->getTags();
|
||||
|
||||
// But we can also grab all tags of a specific type, such as `see`
|
||||
$seeTags = $docblock->getTagsByName('see');
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Serializer;
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
|
||||
$docComment = <<<DOCCOMMENT
|
||||
/**
|
||||
* This is an example of a summary.
|
||||
*
|
||||
* And here is an example of the description
|
||||
* of a DocBlock that can span multiple lines.
|
||||
*
|
||||
* @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
|
||||
*/
|
||||
DOCCOMMENT;
|
||||
|
||||
$factory = DocBlockFactory::createInstance();
|
||||
$docblock = $factory->create($docComment);
|
||||
|
||||
// Create the serializer that will reconstitute the DocBlock back to its original form.
|
||||
$serializer = new Serializer();
|
||||
|
||||
// Reconstitution is performed by the `getDocComment()` method.
|
||||
$reconstitutedDocComment = $serializer->getDocComment($docblock);
|
||||
|
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* In this example we demonstrate how you can add your own Tag using a Static Factory method in your Tag class.
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Serializer;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\BaseTag;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
* An example of a custom tag called `my-tag` with an optional description.
|
||||
*
|
||||
* A Custom Tag is a class that can consist of two parts:
|
||||
*
|
||||
* 1. a method `create` that is a static factory for this class.
|
||||
* 2. methods and properties that have this object act as an immutable Value Object representing a Tag instance.
|
||||
*
|
||||
* The static factory `create` is used to convert a tag line (without the tag name) into an instance of the
|
||||
* same tag object with the right constructor parameters set. This method has a dynamic list of parameters so that you
|
||||
* can inject various dependencies, see the method's DocBlock for more information.
|
||||
*
|
||||
* An object of this class, and its methods and properties, represent a single instance of that tag in your
|
||||
* documentation in the form of a Value Object whose properties should not be changed after instantiation (it should be
|
||||
* immutable).
|
||||
*
|
||||
* > Important: Tag classes that act as Factories using the `create` method should implement the TagFactory interface.
|
||||
*/
|
||||
final class MyTag extends BaseTag implements StaticMethod
|
||||
{
|
||||
/**
|
||||
* A required property that is used by Formatters to reconstitute the complete tag line.
|
||||
*
|
||||
* @see Formatter
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'my-tag';
|
||||
|
||||
/**
|
||||
* The constructor for this Tag; this should contain all properties for this object.
|
||||
*
|
||||
* @param Description $description An example of how to add a Description to the tag; the Description is often
|
||||
* an optional variable so passing null is allowed in this instance (though you can
|
||||
* also construct an empty description object).
|
||||
*
|
||||
* @see BaseTag for the declaration of the description property and getDescription method.
|
||||
*/
|
||||
public function __construct(Description $description = null)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* A static Factory that creates a new instance of the current Tag.
|
||||
*
|
||||
* In this example the MyTag tag can be created by passing a description text as $body. Because we have added
|
||||
* a $descriptionFactory that is type-hinted as DescriptionFactory we can now construct a new Description object
|
||||
* and pass that to the constructor.
|
||||
*
|
||||
* > You could directly instantiate a Description object here but that won't be parsed for inline tags and Types
|
||||
* > won't be resolved. The DescriptionFactory will take care of those actions.
|
||||
*
|
||||
* The `create` method's interface states that this method only features a single parameter (`$body`) but the
|
||||
* {@see TagFactory} will read the signature of this method and if it has more parameters then it will try
|
||||
* to find declarations for it in the ServiceLocator of the TagFactory (see {@see TagFactory::$serviceLocator}).
|
||||
*
|
||||
* > Important: all properties following the `$body` should default to `null`, otherwise PHP will error because
|
||||
* > it no longer matches the interface. This is why you often see the default tags check that an optional argument
|
||||
* > is not null nonetheless.
|
||||
*
|
||||
* @param string $body
|
||||
* @param DescriptionFactory $descriptionFactory
|
||||
* @param Context|null $context The Context is used to resolve Types and FQSENs, although optional
|
||||
* it is highly recommended to pass it. If you omit it then it is assumed that
|
||||
* the DocBlock is in the global namespace and has no `use` statements.
|
||||
*
|
||||
* @see Tag for the interface declaration of the `create` method.
|
||||
* @see Tag::create() for more information on this method's workings.
|
||||
*
|
||||
* @return MyTag
|
||||
*/
|
||||
public static function create($body, DescriptionFactory $descriptionFactory = null, Context $context = null)
|
||||
{
|
||||
Assert::string($body);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
return new static($descriptionFactory->create($body, $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rendition of the original tag line.
|
||||
*
|
||||
* This method is used to reconstitute a DocBlock into its original form by the {@see Serializer}. It should
|
||||
* feature all parts of the tag so that the serializer can put it back together.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string)$this->description;
|
||||
}
|
||||
}
|
||||
|
||||
$docComment = <<<DOCCOMMENT
|
||||
/**
|
||||
* This is an example of a summary.
|
||||
*
|
||||
* @my-tag I have a description
|
||||
*/
|
||||
DOCCOMMENT;
|
||||
|
||||
// Make a mapping between the tag name `my-tag` and the Tag class containing the Factory Method `create`.
|
||||
$customTags = ['my-tag' => MyTag::class];
|
||||
|
||||
// Do pass the list of custom tags to the Factory for the DocBlockFactory.
|
||||
$factory = DocBlockFactory::createInstance($customTags);
|
||||
// You can also add Tags later using `$factory->registerTagHandler()` with a tag name and Tag class name.
|
||||
|
||||
// Create the DocBlock
|
||||
$docblock = $factory->create($docComment);
|
||||
|
||||
// Take a look: the $customTagObjects now contain an array with your newly added tag
|
||||
$customTagObjects = $docblock->getTagsByName('my-tag');
|
||||
|
||||
// As an experiment: let's reconstitute the DocBlock and observe that because we added a __toString() method
|
||||
// to the tag class that we can now also see it.
|
||||
$serializer = new Serializer();
|
||||
$reconstitutedDocComment = $serializer->getDocComment($docblock);
|
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . '/../../vendor/autoload.php');
|
||||
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
|
||||
$docComment = <<<DOCCOMMENT
|
||||
/**
|
||||
* This is an example of a summary.
|
||||
*
|
||||
* You can escape the @-sign by surrounding it with braces, for example: {@}. And escape a closing brace within an
|
||||
* inline tag by adding an opening brace in front of it like this: {}.
|
||||
*
|
||||
* Here are example texts where you can see how they could be used in a real life situation:
|
||||
*
|
||||
* This is a text with an {@internal inline tag where a closing brace ({}) is shown}.
|
||||
* Or an {@internal inline tag with a literal {{@}link{} in it}.
|
||||
*
|
||||
* Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
|
||||
*/
|
||||
DOCCOMMENT;
|
||||
|
||||
$factory = DocBlockFactory::createInstance();
|
||||
$docblock = $factory->create($docComment);
|
||||
|
||||
// Escaping is automatic so this happens in the DescriptionFactory.
|
||||
$description = $docblock->getDescription();
|
||||
|
||||
// This is the rendition that we will receive of the Description.
|
||||
$receivedDocComment = <<<DOCCOMMENT
|
||||
/**
|
||||
* This is an example of a summary.
|
||||
*
|
||||
* You can escape the @-sign by surrounding it with braces, for example: {@}. And escape a closing brace within an
|
||||
* inline tag by adding an opening brace in front of it like this: {}.
|
||||
*
|
||||
* Here are example texts where you can see how they could be used in a real life situation:
|
||||
*
|
||||
* This is a text with an {@internal inline tag where a closing brace ({}) is shown}.
|
||||
* Or an {@internal inline tag with a literal {{@}link{} in it}.
|
||||
*
|
||||
* Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
|
||||
*/
|
||||
DOCCOMMENT;
|
||||
|
||||
// Render it using the default PassthroughFormatter
|
||||
$foundDescription = $description->render();
|
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<ruleset
|
||||
name="ProxyManager rules"
|
||||
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||
>
|
||||
<rule ref="rulesets/codesize.xml"/>
|
||||
<rule ref="rulesets/unusedcode.xml"/>
|
||||
<rule ref="rulesets/design.xml">
|
||||
<!-- eval is needed to generate runtime classes -->
|
||||
<exclude name="EvalExpression"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/naming.xml">
|
||||
<exclude name="LongVariable"/>
|
||||
</rule>
|
||||
<rule ref="rulesets/naming.xml/LongVariable">
|
||||
<properties>
|
||||
<property name="minimum">40</property>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<phpunit
|
||||
colors="true"
|
||||
checkForUnintentionallyCoveredCode="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
forceCoversAnnotation="true"
|
||||
verbose="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
<directory>./tests/unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="integration">
|
||||
<directory>./tests/integration</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">./src/</directory>
|
||||
</whitelist>
|
||||
<blacklist>
|
||||
<directory>./vendor/</directory>
|
||||
</blacklist>
|
||||
</filter>
|
||||
<listeners>
|
||||
<listener
|
||||
class="Mockery\Adapter\Phpunit\TestListener"
|
||||
file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php"
|
||||
/>
|
||||
</listeners>
|
||||
</phpunit>
|
@@ -24,7 +24,7 @@ final class DocBlock
|
||||
private $description = null;
|
||||
|
||||
/** @var Tag[] An array containing all the tags in this docblock; except inline. */
|
||||
private $tags = array();
|
||||
private $tags = [];
|
||||
|
||||
/** @var Types\Context Information about the context of this DocBlock. */
|
||||
private $context = null;
|
||||
@@ -55,8 +55,7 @@ final class DocBlock
|
||||
Location $location = null,
|
||||
$isTemplateStart = false,
|
||||
$isTemplateEnd = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
Assert::string($summary);
|
||||
Assert::boolean($isTemplateStart);
|
||||
Assert::boolean($isTemplateEnd);
|
||||
@@ -171,11 +170,11 @@ final class DocBlock
|
||||
{
|
||||
Assert::string($name);
|
||||
|
||||
$result = array();
|
||||
$result = [];
|
||||
|
||||
/** @var Tag $tag */
|
||||
foreach ($this->getTags() as $tag) {
|
||||
if ($tag->getName() != $name) {
|
||||
if ($tag->getName() !== $name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -198,7 +197,7 @@ final class DocBlock
|
||||
|
||||
/** @var Tag $tag */
|
||||
foreach ($this->getTags() as $tag) {
|
||||
if ($tag->getName() == $name) {
|
||||
if ($tag->getName() === $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -206,6 +205,23 @@ final class DocBlock
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a tag from this DocBlock.
|
||||
*
|
||||
* @param Tag $tag The tag to remove.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeTag(Tag $tagToRemove)
|
||||
{
|
||||
foreach ($this->tags as $key => $tag) {
|
||||
if ($tag === $tagToRemove) {
|
||||
unset($this->tags[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tag to this DocBlock.
|
||||
*
|
||||
|
@@ -70,6 +70,16 @@ class Description
|
||||
$this->tags = $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tags for this DocBlock.
|
||||
*
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getTags()
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders this description as a string where the provided formatter will format the tags in the expected string
|
||||
* format.
|
||||
@@ -88,6 +98,7 @@ class Description
|
||||
foreach ($this->tags as $tag) {
|
||||
$tags[] = '{' . $formatter->format($tag) . '}';
|
||||
}
|
||||
|
||||
return vsprintf($this->bodyTemplate, $tags);
|
||||
}
|
||||
|
||||
|
@@ -188,5 +188,4 @@ class DescriptionFactory
|
||||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Example;
|
||||
|
||||
@@ -23,7 +23,7 @@ class ExampleFinder
|
||||
private $sourceDirectory = '';
|
||||
|
||||
/** @var string[] */
|
||||
private $exampleDirectories = array();
|
||||
private $exampleDirectories = [];
|
||||
|
||||
/**
|
||||
* Attempts to find the example contents for the given descriptor.
|
||||
|
@@ -32,6 +32,9 @@ class Serializer
|
||||
/** @var int|null The max length of a line. */
|
||||
protected $lineLength = null;
|
||||
|
||||
/** @var DocBlock\Tags\Formatter A custom tag formatter. */
|
||||
protected $tagFormatter = null;
|
||||
|
||||
/**
|
||||
* Create a Serializer instance.
|
||||
*
|
||||
@@ -39,18 +42,21 @@ class Serializer
|
||||
* @param string $indentString The string to indent the comment with.
|
||||
* @param bool $indentFirstLine Whether to indent the first line.
|
||||
* @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
|
||||
* @param DocBlock\Tags\Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter.
|
||||
*/
|
||||
public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null)
|
||||
public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null, $tagFormatter = null)
|
||||
{
|
||||
Assert::integer($indent);
|
||||
Assert::string($indentString);
|
||||
Assert::boolean($indentFirstLine);
|
||||
Assert::nullOrInteger($lineLength);
|
||||
Assert::nullOrIsInstanceOf($tagFormatter, 'phpDocumentor\Reflection\DocBlock\Tags\Formatter');
|
||||
|
||||
$this->indent = $indent;
|
||||
$this->indentString = $indentString;
|
||||
$this->isFirstLineIndented = $indentFirstLine;
|
||||
$this->lineLength = $lineLength;
|
||||
$this->tagFormatter = $tagFormatter ?: new DocBlock\Tags\Formatter\PassthroughFormatter();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +81,12 @@ class Serializer
|
||||
)
|
||||
);
|
||||
|
||||
$comment = "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n";
|
||||
$comment = "{$firstIndent}/**\n";
|
||||
if ($text) {
|
||||
$comment .= "{$indent} * {$text}\n";
|
||||
$comment .= "{$indent} *\n";
|
||||
}
|
||||
|
||||
$comment = $this->addTagBlock($docblock, $wrapLength, $indent, $comment);
|
||||
$comment .= $indent . ' */';
|
||||
|
||||
@@ -115,6 +126,7 @@ class Serializer
|
||||
$text = wordwrap($text, $wrapLength);
|
||||
return $text;
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
@@ -128,11 +140,11 @@ class Serializer
|
||||
private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment)
|
||||
{
|
||||
foreach ($docblock->getTags() as $tag) {
|
||||
$formatter = new DocBlock\Tags\Formatter\PassthroughFormatter();
|
||||
$tagText = $formatter->format($tag);
|
||||
$tagText = $this->tagFormatter->format($tag);
|
||||
if ($wrapLength !== null) {
|
||||
$tagText = wordwrap($tagText, $wrapLength);
|
||||
}
|
||||
|
||||
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
||||
|
||||
$comment .= "{$indent} * {$tagText}\n";
|
||||
|
@@ -113,6 +113,12 @@ final class StandardTagFactory implements TagFactory
|
||||
|
||||
list($tagName, $tagBody) = $this->extractTagParts($tagLine);
|
||||
|
||||
if ($tagBody !== '' && $tagBody[0] === '[') {
|
||||
throw new \InvalidArgumentException(
|
||||
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->createTag($tagBody, $tagName, $context);
|
||||
}
|
||||
|
||||
@@ -160,8 +166,8 @@ final class StandardTagFactory implements TagFactory
|
||||
*/
|
||||
private function extractTagParts($tagLine)
|
||||
{
|
||||
$matches = array();
|
||||
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us', $tagLine, $matches)) {
|
||||
$matches = [];
|
||||
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
|
||||
);
|
||||
@@ -190,8 +196,7 @@ final class StandardTagFactory implements TagFactory
|
||||
$arguments = $this->getArgumentsForParametersFromWiring(
|
||||
$this->fetchParametersForHandlerFactoryMethod($handlerClassName),
|
||||
$this->getServiceLocatorWithDynamicParameters($context, $name, $body)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
return call_user_func_array([$handlerClassName, 'create'], $arguments);
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->authorName . '<' . $this->authorEmail . '>';
|
||||
return $this->authorName . (strlen($this->authorEmail) ? ' <' . $this->authorEmail . '>' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -12,11 +12,11 @@
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Fqsen;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
@@ -49,8 +49,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
FqsenResolver $resolver = null,
|
||||
TypeContext $context = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
Assert::string($body);
|
||||
Assert::notEmpty($body);
|
||||
|
||||
|
@@ -12,9 +12,9 @@
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
|
@@ -12,7 +12,9 @@
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
* Reflection class for a {@}example tag in a Docblock.
|
||||
@@ -22,7 +24,7 @@ final class Example extends BaseTag
|
||||
/**
|
||||
* @var string Path to a file to use as an example. May also be an absolute URI.
|
||||
*/
|
||||
private $filePath = '';
|
||||
private $filePath;
|
||||
|
||||
/**
|
||||
* @var bool Whether the file path component represents an URI. This determines how the file portion
|
||||
@@ -30,6 +32,33 @@ final class Example extends BaseTag
|
||||
*/
|
||||
private $isURI = false;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $startingLine;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $lineCount;
|
||||
|
||||
public function __construct($filePath, $isURI, $startingLine, $lineCount, $description)
|
||||
{
|
||||
Assert::notEmpty($filePath);
|
||||
Assert::integer($startingLine);
|
||||
Assert::greaterThanEq($startingLine, 0);
|
||||
|
||||
$this->filePath = $filePath;
|
||||
$this->startingLine = $startingLine;
|
||||
$this->lineCount = $lineCount;
|
||||
$this->name = 'example';
|
||||
if ($description !== null) {
|
||||
$this->description = trim($description);
|
||||
}
|
||||
|
||||
$this->isURI = $isURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -43,7 +72,7 @@ final class Example extends BaseTag
|
||||
:$this->filePath;
|
||||
}
|
||||
|
||||
$this->description = $filePath . ' ' . parent::getContent();
|
||||
return trim($filePath . ' ' . parent::getDescription());
|
||||
}
|
||||
|
||||
return $this->description;
|
||||
@@ -71,16 +100,29 @@ final class Example extends BaseTag
|
||||
$lineCount = null;
|
||||
$description = null;
|
||||
|
||||
// Starting line / Number of lines / Description
|
||||
if (preg_match('/^([1-9]\d*)\s*(?:((?1))\s+)?(.*)$/sux', $matches[3], $matches)) {
|
||||
$startingLine = (int)$matches[1];
|
||||
if (isset($matches[2]) && $matches[2] !== '') {
|
||||
$lineCount = (int)$matches[2];
|
||||
}
|
||||
if (array_key_exists(3, $matches)) {
|
||||
$description = $matches[3];
|
||||
|
||||
// Starting line / Number of lines / Description
|
||||
if (preg_match('/^([1-9]\d*)(?:\s+((?1))\s*)?(.*)$/sux', $matches[3], $contentMatches)) {
|
||||
$startingLine = (int)$contentMatches[1];
|
||||
if (isset($contentMatches[2]) && $contentMatches[2] !== '') {
|
||||
$lineCount = (int)$contentMatches[2];
|
||||
}
|
||||
|
||||
if (array_key_exists(3, $contentMatches)) {
|
||||
$description = $contentMatches[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new static($filePath, $fileUri, $startingLine, $lineCount, $description);
|
||||
return new static(
|
||||
$filePath !== null?$filePath:$fileUri,
|
||||
$fileUri !== null,
|
||||
$startingLine,
|
||||
$lineCount,
|
||||
$description
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,46 +136,6 @@ final class Example extends BaseTag
|
||||
return $this->filePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file path.
|
||||
*
|
||||
* @param string $filePath The new file path to use for the example.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFilePath($filePath)
|
||||
{
|
||||
$this->isURI = false;
|
||||
$this->filePath = trim($filePath);
|
||||
|
||||
$this->description = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file path as an URI.
|
||||
*
|
||||
* This function is equivalent to {@link setFilePath()}, except that it
|
||||
* converts an URI to a file path before that.
|
||||
*
|
||||
* There is no getFileURI(), as {@link getFilePath()} is compatible.
|
||||
*
|
||||
* @param string $uri The new file URI to use as an example.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileURI($uri)
|
||||
{
|
||||
$this->isURI = true;
|
||||
$this->description = null;
|
||||
|
||||
$this->filePath = $this->isUriRelative($uri)
|
||||
? rawurldecode(str_replace(array('/', '\\'), '%2F', $uri))
|
||||
: $this->filePath = $uri;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*
|
||||
@@ -141,7 +143,7 @@ final class Example extends BaseTag
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->filePath . ($this->description ? ' ' . $this->description->render() : '');
|
||||
return $this->filePath . ($this->description ? ' ' . $this->description : '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,4 +157,20 @@ final class Example extends BaseTag
|
||||
{
|
||||
return false === strpos($uri, ':');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStartingLine()
|
||||
{
|
||||
return $this->startingLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLineCount()
|
||||
{
|
||||
return $this->lineCount;
|
||||
}
|
||||
}
|
||||
|
47
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/AlignFormatter.php
vendored
Normal file
47
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Formatter/AlignFormatter.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @author Jan Schneider <jan@horde.org>
|
||||
* @copyright 2017 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 phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
|
||||
class AlignFormatter implements Formatter
|
||||
{
|
||||
/** @var int The maximum tag name length. */
|
||||
protected $maxLen = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Tag[] $tags All tags that should later be aligned with the formatter.
|
||||
*/
|
||||
public function __construct(array $tags)
|
||||
{
|
||||
foreach ($tags as $tag) {
|
||||
$this->maxLen = max($this->maxLen, strlen($tag->getName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given tag to return a simple plain text version.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(Tag $tag)
|
||||
{
|
||||
return '@' . $tag->getName() . str_repeat(' ', $this->maxLen - strlen($tag->getName()) + 1) . (string)$tag;
|
||||
}
|
||||
}
|
@@ -26,6 +26,6 @@ class PassthroughFormatter implements Formatter
|
||||
*/
|
||||
public function format(Tag $tag)
|
||||
{
|
||||
return '@' . $tag->getName() . ' ' . (string)$tag;
|
||||
return trim('@' . $tag->getName() . ' ' . (string)$tag);
|
||||
}
|
||||
}
|
||||
|
@@ -91,11 +91,15 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
)?
|
||||
# Return type
|
||||
(?:
|
||||
(
|
||||
(?:[\w\|_\\\\]+)
|
||||
# array notation
|
||||
(?:\[\])*
|
||||
)?
|
||||
(
|
||||
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
|
||||
|
|
||||
(?:
|
||||
(?:[\w\|_\\\\]+)
|
||||
# array notation
|
||||
(?:\[\])*
|
||||
)*
|
||||
)
|
||||
\s+
|
||||
)?
|
||||
# Legacy method name (not captured)
|
||||
@@ -121,12 +125,17 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
list(, $static, $returnType, $methodName, $arguments, $description) = $matches;
|
||||
|
||||
$static = $static === 'static';
|
||||
|
||||
if ($returnType === '') {
|
||||
$returnType = 'void';
|
||||
}
|
||||
|
||||
$returnType = $typeResolver->resolve($returnType, $context);
|
||||
$description = $descriptionFactory->create($description, $context);
|
||||
|
||||
if ('' !== $arguments) {
|
||||
if (is_string($arguments) && strlen($arguments) > 0) {
|
||||
$arguments = explode(',', $arguments);
|
||||
foreach($arguments as &$argument) {
|
||||
foreach ($arguments as &$argument) {
|
||||
$argument = explode(' ', self::stripRestArg(trim($argument)), 2);
|
||||
if ($argument[0][0] === '$') {
|
||||
$argumentName = substr($argument[0], 1);
|
||||
@@ -192,11 +201,11 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
$arguments[] = $argument['type'] . ' $' . $argument['name'];
|
||||
}
|
||||
|
||||
return ($this->isStatic() ? 'static ' : '')
|
||||
return trim(($this->isStatic() ? 'static ' : '')
|
||||
. (string)$this->returnType . ' '
|
||||
. $this->methodName
|
||||
. '(' . implode(', ', $arguments) . ')'
|
||||
. ($this->description ? ' ' . $this->description->render() : '');
|
||||
. ($this->description ? ' ' . $this->description->render() : ''));
|
||||
}
|
||||
|
||||
private function filterArguments($arguments)
|
||||
@@ -205,10 +214,13 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
if (is_string($argument)) {
|
||||
$argument = [ 'name' => $argument ];
|
||||
}
|
||||
|
||||
if (! isset($argument['type'])) {
|
||||
$argument['type'] = new Void_();
|
||||
}
|
||||
|
||||
$keys = array_keys($argument);
|
||||
sort($keys);
|
||||
if ($keys !== [ 'name', 'type' ]) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Arguments can only have the "name" and "type" fields, found: ' . var_export($keys, true)
|
||||
|
@@ -77,7 +77,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
}
|
||||
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$')) {
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$' || substr($parts[0], 0, 4) === '...$')) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
|
||||
|
@@ -70,7 +70,7 @@ class Property extends BaseTag implements Factory\StaticMethod
|
||||
}
|
||||
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
|
||||
|
@@ -70,7 +70,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
||||
}
|
||||
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
|
||||
|
@@ -70,7 +70,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
||||
}
|
||||
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
|
||||
|
42
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Fqsen.php
vendored
Normal file
42
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Fqsen.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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-2017 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\Reference;
|
||||
|
||||
use phpDocumentor\Reflection\Fqsen as RealFqsen;
|
||||
|
||||
/**
|
||||
* Fqsen reference used by {@see phpDocumentor\Reflection\DocBlock\Tags\See}
|
||||
*/
|
||||
final class Fqsen implements Reference
|
||||
{
|
||||
/**
|
||||
* @var RealFqsen
|
||||
*/
|
||||
private $fqsen;
|
||||
|
||||
/**
|
||||
* Fqsen constructor.
|
||||
*/
|
||||
public function __construct(RealFqsen $fqsen)
|
||||
{
|
||||
$this->fqsen = $fqsen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string string representation of the referenced fqsen
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string)$this->fqsen;
|
||||
}
|
||||
}
|
21
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Reference.php
vendored
Normal file
21
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Reference.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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-2017 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\Reference;
|
||||
|
||||
/**
|
||||
* Interface for references in {@see phpDocumentor\Reflection\DocBlock\Tags\See}
|
||||
*/
|
||||
interface Reference
|
||||
{
|
||||
public function __toString();
|
||||
}
|
40
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Url.php
vendored
Normal file
40
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Reference/Url.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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-2017 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\Reference;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
* Url reference used by {@see phpDocumentor\Reflection\DocBlock\Tags\See}
|
||||
*/
|
||||
final class Url implements Reference
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $uri;
|
||||
|
||||
/**
|
||||
* Url constructor.
|
||||
*/
|
||||
public function __construct($uri)
|
||||
{
|
||||
Assert::stringNotEmpty($uri);
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
}
|
@@ -43,8 +43,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
Assert::string($body);
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
|
||||
|
@@ -12,11 +12,13 @@
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Fqsen;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Reference;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
@@ -26,16 +28,16 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
protected $name = 'see';
|
||||
|
||||
/** @var Fqsen */
|
||||
/** @var Reference */
|
||||
protected $refers = null;
|
||||
|
||||
/**
|
||||
* Initializes this tag.
|
||||
*
|
||||
* @param Fqsen $refers
|
||||
* @param Reference $refers
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct(Fqsen $refers, Description $description = null)
|
||||
public function __construct(Reference $refers, Description $description = null)
|
||||
{
|
||||
$this->refers = $refers;
|
||||
$this->description = $description;
|
||||
@@ -56,13 +58,18 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
$parts = preg_split('/\s+/Su', $body, 2);
|
||||
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
|
||||
|
||||
return new static($resolver->resolve($parts[0], $context), $description);
|
||||
// https://tools.ietf.org/html/rfc2396#section-3
|
||||
if (preg_match('/\w:\/\/\w/i', $parts[0])) {
|
||||
return new static(new Url($parts[0]), $description);
|
||||
}
|
||||
|
||||
return new static(new FqsenRef($resolver->resolve($parts[0], $context)), $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the structural element this tag refers to.
|
||||
* Returns the ref of this tag.
|
||||
*
|
||||
* @return Fqsen
|
||||
* @return Reference
|
||||
*/
|
||||
public function getReference()
|
||||
{
|
||||
|
@@ -12,9 +12,9 @@
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
|
@@ -59,6 +59,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
if (isset($matches[2]) && $matches[2] !== '') {
|
||||
$lineCount = (int)$matches[2];
|
||||
}
|
||||
|
||||
$description = $matches[3];
|
||||
}
|
||||
|
||||
|
@@ -70,7 +70,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
}
|
||||
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] == '$')) {
|
||||
if (isset($parts[0]) && (strlen($parts[0]) > 0) && ($parts[0][0] === '$')) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
|
||||
@@ -112,7 +112,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
public function __toString()
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. '$' . $this->variableName
|
||||
. ($this->description ? ' ' . $this->description : '');
|
||||
. (empty($this->variableName) ? null : ('$' . $this->variableName))
|
||||
. ($this->description ? ' ' . $this->description : '');
|
||||
}
|
||||
}
|
||||
|
@@ -12,9 +12,9 @@
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
|
@@ -93,7 +93,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
return new DocBlock(
|
||||
$summary,
|
||||
$description ? $this->descriptionFactory->create($description, $context) : null,
|
||||
array_filter($this->parseTagBlock($tags, $context), function($tag) {
|
||||
array_filter($this->parseTagBlock($tags, $context), function ($tag) {
|
||||
return $tag instanceof Tag;
|
||||
}),
|
||||
$context,
|
||||
@@ -120,11 +120,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
$comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment));
|
||||
|
||||
// reg ex above is not able to remove */ from a single line docblock
|
||||
if (substr($comment, -2) == '*/') {
|
||||
if (substr($comment, -2) === '*/') {
|
||||
$comment = trim(substr($comment, 0, -2));
|
||||
}
|
||||
|
||||
return str_replace(array("\r\n", "\r"), "\n", $comment);
|
||||
return str_replace(["\r\n", "\r"], "\n", $comment);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
|
||||
// performance impact of running a regular expression
|
||||
if (strpos($comment, '@') === 0) {
|
||||
return array('', '', '', $comment);
|
||||
return ['', '', '', $comment];
|
||||
}
|
||||
|
||||
// clears all extra horizontal whitespace from the line endings to prevent parsing issues
|
||||
@@ -241,7 +241,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*/
|
||||
private function splitTagBlockIntoTagLines($tags)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach (explode("\n", $tags) as $tag_line) {
|
||||
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
||||
$result[] = $tag_line;
|
||||
|
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
class InterpretingDocBlocksTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testInterpretingASimpleDocBlock()
|
||||
{
|
||||
/**
|
||||
* @var DocBlock $docblock
|
||||
* @var string $summary
|
||||
* @var Description $description
|
||||
*/
|
||||
include(__DIR__ . '/../../examples/01-interpreting-a-simple-docblock.php');
|
||||
|
||||
$descriptionText = <<<DESCRIPTION
|
||||
This is a Description. A Summary and Description are separated by either
|
||||
two subsequent newlines (thus a whiteline in between as can be seen in this
|
||||
example), or when the Summary ends with a dot (`.`) and some form of
|
||||
whitespace.
|
||||
DESCRIPTION;
|
||||
|
||||
$this->assertInstanceOf(DocBlock::class, $docblock);
|
||||
$this->assertSame('This is an example of a summary.', $summary);
|
||||
$this->assertInstanceOf(Description::class, $description);
|
||||
$this->assertSame($descriptionText, $description->render());
|
||||
$this->assertEmpty($docblock->getTags());
|
||||
}
|
||||
|
||||
public function testInterpretingTags()
|
||||
{
|
||||
/**
|
||||
* @var DocBlock $docblock
|
||||
* @var boolean $hasSeeTag
|
||||
* @var Tag[] $tags
|
||||
* @var See[] $seeTags
|
||||
*/
|
||||
include(__DIR__ . '/../../examples/02-interpreting-tags.php');
|
||||
|
||||
$this->assertTrue($hasSeeTag);
|
||||
$this->assertCount(1, $tags);
|
||||
$this->assertCount(1, $seeTags);
|
||||
|
||||
$this->assertInstanceOf(See::class, $tags[0]);
|
||||
$this->assertInstanceOf(See::class, $seeTags[0]);
|
||||
|
||||
$seeTag = $seeTags[0];
|
||||
$this->assertSame('\\' . StandardTagFactory::class, (string)$seeTag->getReference());
|
||||
$this->assertSame('', (string)$seeTag->getDescription());
|
||||
}
|
||||
|
||||
public function testDescriptionsCanEscapeAtSignsAndClosingBraces()
|
||||
{
|
||||
/**
|
||||
* @var string $docComment
|
||||
* @var DocBlock $docblock
|
||||
* @var Description $description
|
||||
* @var string $receivedDocComment
|
||||
* @var string $foundDescription
|
||||
*/
|
||||
|
||||
include(__DIR__ . '/../../examples/playing-with-descriptions/02-escaping.php');
|
||||
$this->assertSame(<<<'DESCRIPTION'
|
||||
You can escape the @-sign by surrounding it with braces, for example: @. And escape a closing brace within an
|
||||
inline tag by adding an opening brace in front of it like this: }.
|
||||
|
||||
Here are example texts where you can see how they could be used in a real life situation:
|
||||
|
||||
This is a text with an {@internal inline tag where a closing brace (}) is shown}.
|
||||
Or an {@internal inline tag with a literal {@link} in it}.
|
||||
|
||||
Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
|
||||
DESCRIPTION
|
||||
,
|
||||
$foundDescription
|
||||
)
|
||||
;
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
class ReconstitutingADocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testReconstituteADocBlock()
|
||||
{
|
||||
/**
|
||||
* @var string $docComment
|
||||
* @var string $reconstitutedDocComment
|
||||
*/
|
||||
include(__DIR__ . '/../../examples/03-reconstituting-a-docblock.php');
|
||||
|
||||
$this->assertSame($docComment, $reconstitutedDocComment);
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
class UsingTagsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAddingYourOwnTagUsingAStaticMethodAsFactory()
|
||||
{
|
||||
/**
|
||||
* @var object[] $customTagObjects
|
||||
* @var string $docComment
|
||||
* @var string $reconstitutedDocComment
|
||||
*/
|
||||
include(__DIR__ . '/../../examples/04-adding-your-own-tag.php');
|
||||
|
||||
$this->assertInstanceOf(\MyTag::class, $customTagObjects[0]);
|
||||
$this->assertSame('my-tag', $customTagObjects[0]->getName());
|
||||
$this->assertSame('I have a description', (string)$customTagObjects[0]->getDescription());
|
||||
$this->assertSame($docComment, $reconstitutedDocComment);
|
||||
}
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
<?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 }.'],
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
<?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([]);
|
||||
}
|
||||
}
|
@@ -1,201 +0,0 @@
|
||||
<?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, []);
|
||||
}
|
||||
}
|
@@ -1,361 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@@ -1,148 +0,0 @@
|
||||
<?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<'));
|
||||
}
|
||||
}
|
@@ -1,155 +0,0 @@
|
||||
<?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(''));
|
||||
}
|
||||
}
|
@@ -1,166 +0,0 @@
|
||||
<?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->assertEquals(new Deprecated(), Deprecated::create('dkhf<'));
|
||||
}
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
<?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')))
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,146 +0,0 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
@@ -1,158 +0,0 @@
|
||||
<?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([]));
|
||||
}
|
||||
}
|
@@ -1,437 +0,0 @@
|
||||
<?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 ::create
|
||||
*/
|
||||
public function testRestArgumentIsParsedAsRegularArg()
|
||||
{
|
||||
$expected = [
|
||||
[ 'name' => 'arg1', 'type' => new Void_() ],
|
||||
[ 'name' => 'rest', 'type' => new Void_() ],
|
||||
[ 'name' => 'rest2', 'type' => new Array_() ],
|
||||
];
|
||||
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
$description = new Description('');
|
||||
$descriptionFactory->shouldReceive('create')->with('', $context)->andReturn($description);
|
||||
|
||||
$fixture = Method::create(
|
||||
'void myMethod($arg1, ...$rest, array ... $rest2)',
|
||||
$resolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$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());
|
||||
}
|
||||
}
|
@@ -1,228 +0,0 @@
|
||||
<?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, []);
|
||||
}
|
||||
}
|
@@ -1,201 +0,0 @@
|
||||
<?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([]);
|
||||
}
|
||||
}
|
@@ -1,200 +0,0 @@
|
||||
<?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([]);
|
||||
}
|
||||
}
|
@@ -1,201 +0,0 @@
|
||||
<?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([]);
|
||||
}
|
||||
}
|
@@ -1,170 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@@ -1,173 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@@ -1,166 +0,0 @@
|
||||
<?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<'));
|
||||
}
|
||||
}
|
@@ -1,199 +0,0 @@
|
||||
<?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', []);
|
||||
}
|
||||
}
|
@@ -1,170 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
@@ -1,200 +0,0 @@
|
||||
<?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_([]);
|
||||
}
|
||||
}
|
@@ -1,166 +0,0 @@
|
||||
<?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<'));
|
||||
}
|
||||
}
|
@@ -1,290 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\TagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass phpDocumentor\Reflection\DocBlockFactory
|
||||
* @covers ::<private>
|
||||
* @uses \Webmozart\Assert\Assert
|
||||
* @uses phpDocumentor\Reflection\DocBlock
|
||||
*/
|
||||
class DocBlockFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::createInstance
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
*/
|
||||
public function testCreateFactoryUsingFactoryMethod()
|
||||
{
|
||||
$fixture = DocBlockFactory::createInstance();
|
||||
|
||||
$this->assertInstanceOf(DocBlockFactory::class, $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testCreateDocBlockFromReflection()
|
||||
{
|
||||
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
|
||||
|
||||
$docBlock = '/** This is a DocBlock */';
|
||||
$classReflector = m::mock(\ReflectionClass::class);
|
||||
$classReflector->shouldReceive('getDocComment')->andReturn($docBlock);
|
||||
$docblock = $fixture->create($classReflector);
|
||||
|
||||
$this->assertInstanceOf(DocBlock::class, $docblock);
|
||||
$this->assertSame('This is a DocBlock', $docblock->getSummary());
|
||||
$this->assertEquals(new Description(''), $docblock->getDescription());
|
||||
$this->assertSame([], $docblock->getTags());
|
||||
$this->assertEquals(new Context(''), $docblock->getContext());
|
||||
$this->assertNull($docblock->getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testCreateDocBlockFromStringWithDocComment()
|
||||
{
|
||||
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
|
||||
|
||||
$docblock = $fixture->create('/** This is a DocBlock */');
|
||||
|
||||
$this->assertInstanceOf(DocBlock::class, $docblock);
|
||||
$this->assertSame('This is a DocBlock', $docblock->getSummary());
|
||||
$this->assertEquals(new Description(''), $docblock->getDescription());
|
||||
$this->assertSame([], $docblock->getTags());
|
||||
$this->assertEquals(new Context(''), $docblock->getContext());
|
||||
$this->assertNull($docblock->getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
* @covers ::__construct
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testCreateDocBlockFromStringWithoutDocComment()
|
||||
{
|
||||
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
|
||||
|
||||
$docblock = $fixture->create('This is a DocBlock');
|
||||
|
||||
$this->assertInstanceOf(DocBlock::class, $docblock);
|
||||
$this->assertSame('This is a DocBlock', $docblock->getSummary());
|
||||
$this->assertEquals(new Description(''), $docblock->getDescription());
|
||||
$this->assertSame([], $docblock->getTags());
|
||||
$this->assertEquals(new Context(''), $docblock->getContext());
|
||||
$this->assertNull($docblock->getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @dataProvider provideSummaryAndDescriptions
|
||||
*/
|
||||
public function testSummaryAndDescriptionAreSeparated($given, $summary, $description)
|
||||
{
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
|
||||
|
||||
$docblock = $fixture->create($given);
|
||||
|
||||
$this->assertSame($summary, $docblock->getSummary());
|
||||
$this->assertEquals(new Description($description), $docblock->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDescriptionsRetainFormatting()
|
||||
{
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
|
||||
|
||||
$given = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a summary.
|
||||
* This is a multiline Description
|
||||
* that contains a code block.
|
||||
*
|
||||
* See here: a CodeBlock
|
||||
*/
|
||||
DOCBLOCK;
|
||||
|
||||
$description = <<<DESCRIPTION
|
||||
This is a multiline Description
|
||||
that contains a code block.
|
||||
|
||||
See here: a CodeBlock
|
||||
DESCRIPTION;
|
||||
|
||||
$docblock = $fixture->create($given);
|
||||
|
||||
$this->assertEquals(new Description($description), $docblock->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testTagsAreInterpretedUsingFactory()
|
||||
{
|
||||
$tagString = <<<TAG
|
||||
@author Mike van Riel <me@mikevanriel.com> This is with
|
||||
multiline description.
|
||||
TAG;
|
||||
|
||||
$tag = m::mock(Tag::class);
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$tagFactory->shouldReceive('create')->with($tagString, m::type(Context::class))->andReturn($tag);
|
||||
|
||||
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
|
||||
|
||||
$given = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a summary.
|
||||
*
|
||||
* @author Mike van Riel <me@mikevanriel.com> This is with
|
||||
* multiline description.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
|
||||
$docblock = $fixture->create($given, new Context(''));
|
||||
|
||||
$this->assertEquals([$tag], $docblock->getTags());
|
||||
}
|
||||
|
||||
public function provideSummaryAndDescriptions()
|
||||
{
|
||||
return [
|
||||
['This is a DocBlock', 'This is a DocBlock', ''],
|
||||
[
|
||||
'This is a DocBlock. This should still be summary.',
|
||||
'This is a DocBlock. This should still be summary.',
|
||||
''
|
||||
],
|
||||
[
|
||||
<<<DOCBLOCK
|
||||
This is a DocBlock.
|
||||
This should be a Description.
|
||||
DOCBLOCK
|
||||
,
|
||||
'This is a DocBlock.',
|
||||
'This should be a Description.'
|
||||
],
|
||||
[
|
||||
<<<DOCBLOCK
|
||||
This is a
|
||||
multiline Summary.
|
||||
This should be a Description.
|
||||
DOCBLOCK
|
||||
,
|
||||
"This is a\nmultiline Summary.",
|
||||
'This should be a Description.'
|
||||
],
|
||||
[
|
||||
<<<DOCBLOCK
|
||||
This is a Summary without dot but with a whiteline
|
||||
|
||||
This should be a Description.
|
||||
DOCBLOCK
|
||||
,
|
||||
'This is a Summary without dot but with a whiteline',
|
||||
'This should be a Description.'
|
||||
],
|
||||
[
|
||||
<<<DOCBLOCK
|
||||
This is a Summary with dot and with a whiteline.
|
||||
|
||||
This should be a Description.
|
||||
DOCBLOCK
|
||||
,
|
||||
'This is a Summary with dot and with a whiteline.',
|
||||
'This should be a Description.'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
*
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses phpDocumentor\Reflection\Types\Context
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Tags\Param
|
||||
*/
|
||||
public function testTagsWithContextNamespace()
|
||||
{
|
||||
$tagFactoryMock = m::mock(TagFactory::class);
|
||||
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), $tagFactoryMock);
|
||||
$context = new Context('MyNamespace');
|
||||
|
||||
$tagFactoryMock->shouldReceive('create')->with(m::any(), $context)->andReturn(new Param('param'));
|
||||
$docblock = $fixture->create('/** @param MyType $param */', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::create
|
||||
*
|
||||
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testTagsAreFilteredForNullValues()
|
||||
{
|
||||
$tagString = <<<TAG
|
||||
@author Mike van Riel <me@mikevanriel.com> This is with
|
||||
multiline description.
|
||||
TAG;
|
||||
|
||||
$tagFactory = m::mock(TagFactory::class);
|
||||
$tagFactory->shouldReceive('create')->with($tagString, m::any())->andReturn(null);
|
||||
|
||||
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
|
||||
|
||||
$given = <<<DOCBLOCK
|
||||
/**
|
||||
* This is a summary.
|
||||
*
|
||||
* @author Mike van Riel <me@mikevanriel.com> This is with
|
||||
* multiline description.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
|
||||
$docblock = $fixture->create($given, new Context(''));
|
||||
|
||||
$this->assertEquals([], $docblock->getTags());
|
||||
}
|
||||
}
|
@@ -1,252 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright 2010-2015 Mike van Riel<mike@phpdoc.org>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass phpDocumentor\Reflection\DocBlock
|
||||
* @covers ::<private>
|
||||
* @uses \Webmozart\Assert\Assert
|
||||
*/
|
||||
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getSummary
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDocBlockCanHaveASummary()
|
||||
{
|
||||
$summary = 'This is a summary';
|
||||
|
||||
$fixture = new DocBlock($summary);
|
||||
|
||||
$this->assertSame($summary, $fixture->getSummary());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfSummaryIsNotAString()
|
||||
{
|
||||
new DocBlock([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfTemplateStartIsNotABoolean()
|
||||
{
|
||||
new DocBlock('', null, [], null, null, ['is not boolean']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfTemplateEndIsNotABoolean()
|
||||
{
|
||||
new DocBlock('', null, [], null, null, false, ['is not boolean']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getDescription
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDocBlockCanHaveADescription()
|
||||
{
|
||||
$description = new DocBlock\Description('');
|
||||
|
||||
$fixture = new DocBlock('', $description);
|
||||
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getTags
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tag
|
||||
*/
|
||||
public function testDocBlockCanHaveTags()
|
||||
{
|
||||
$tags = [
|
||||
m::mock(DocBlock\Tag::class)
|
||||
];
|
||||
|
||||
$fixture = new DocBlock('', null, $tags);
|
||||
|
||||
$this->assertSame($tags, $fixture->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getTags
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tag
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testDocBlockAllowsOnlyTags()
|
||||
{
|
||||
$tags = [
|
||||
null
|
||||
];
|
||||
|
||||
$fixture = new DocBlock('', null, $tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getTagsByName
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock::getTags
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tag
|
||||
*/
|
||||
public function testFindTagsInDocBlockByName()
|
||||
{
|
||||
$tag1 = m::mock(DocBlock\Tag::class);
|
||||
$tag2 = m::mock(DocBlock\Tag::class);
|
||||
$tag3 = m::mock(DocBlock\Tag::class);
|
||||
$tags = [$tag1, $tag2, $tag3];
|
||||
|
||||
$tag1->shouldReceive('getName')->andReturn('abc');
|
||||
$tag2->shouldReceive('getName')->andReturn('abcd');
|
||||
$tag3->shouldReceive('getName')->andReturn('ab');
|
||||
|
||||
$fixture = new DocBlock('', null, $tags);
|
||||
|
||||
$this->assertSame([$tag2], $fixture->getTagsByName('abcd'));
|
||||
$this->assertSame([], $fixture->getTagsByName('Ebcd'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getTagsByName
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfNameForTagsIsNotString()
|
||||
{
|
||||
$fixture = new DocBlock();
|
||||
$fixture->getTagsByName([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::hasTag
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock::getTags
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tag
|
||||
*/
|
||||
public function testCheckIfThereAreTagsWithAGivenName()
|
||||
{
|
||||
$tag1 = m::mock(DocBlock\Tag::class);
|
||||
$tag2 = m::mock(DocBlock\Tag::class);
|
||||
$tag3 = m::mock(DocBlock\Tag::class);
|
||||
$tags = [$tag1, $tag2, $tag3];
|
||||
|
||||
$tag1->shouldReceive('getName')->twice()->andReturn('abc');
|
||||
$tag2->shouldReceive('getName')->twice()->andReturn('abcd');
|
||||
$tag3->shouldReceive('getName')->once();
|
||||
|
||||
$fixture = new DocBlock('', null, $tags);
|
||||
|
||||
$this->assertTrue($fixture->hasTag('abcd'));
|
||||
$this->assertFalse($fixture->hasTag('Ebcd'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::hasTag
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testExceptionIsThrownIfNameForCheckingTagsIsNotString()
|
||||
{
|
||||
$fixture = new DocBlock();
|
||||
$fixture->hasTag([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getContext
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*/
|
||||
public function testDocBlockKnowsInWhichNamespaceItIsAndWhichAliasesThereAre()
|
||||
{
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = new DocBlock('', null, [], $context);
|
||||
|
||||
$this->assertSame($context, $fixture->getContext());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::getLocation
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Location
|
||||
*/
|
||||
public function testDocBlockKnowsAtWhichLineItIs()
|
||||
{
|
||||
$location = new Location(10);
|
||||
|
||||
$fixture = new DocBlock('', null, [], null, $location);
|
||||
|
||||
$this->assertSame($location, $fixture->getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::isTemplateStart
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDocBlockKnowsIfItIsTheStartOfADocBlockTemplate()
|
||||
{
|
||||
$fixture = new DocBlock('', null, [], null, null, true);
|
||||
|
||||
$this->assertTrue($fixture->isTemplateStart());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::__construct
|
||||
* @covers ::isTemplateEnd
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
*/
|
||||
public function testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate()
|
||||
{
|
||||
$fixture = new DocBlock('', null, [], null, null, false, true);
|
||||
|
||||
$this->assertTrue($fixture->isTemplateEnd());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user