1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of phpDocumentor. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @copyright 2010-2017 Mike van Riel<[email protected]> |
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
10
|
|
|
* @link http://phpdoc.org |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace phpDocumentor\Behat\Contexts\Ast; |
14
|
|
|
|
15
|
|
|
use Behat\Behat\Context\Context; |
16
|
|
|
use Behat\Gherkin\Node\PyStringNode; |
17
|
|
|
use phpDocumentor\Reflection\DocBlock\Type\Collection; |
18
|
|
|
use PHPUnit\Framework\Assert; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* This class contains the context methods for tests of the see tag. |
22
|
|
|
*/ |
23
|
|
|
final class SeeTagContext extends BaseContext implements Context |
24
|
|
|
{ |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param string $classFqsen |
29
|
|
|
* @param $reference |
30
|
|
|
* @throws \Exception |
31
|
|
|
* @Then class ":classFqsen" has a tag see referencing url ":reference" |
32
|
|
|
*/ |
33
|
|
|
public function classHasTagSeeReferencingUrl($classFqsen, $reference) |
34
|
|
|
{ |
35
|
|
|
$class = $this->findClassByFqsen($classFqsen); |
36
|
|
|
$seeTags = $class->getTags()->get('see', new Collection()); |
37
|
|
|
/** @var SeeTag $tag */ |
38
|
|
|
foreach ($seeTags as $tag) { |
39
|
|
|
if ($tag->getReference() === $reference) { |
40
|
|
|
return; |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
throw new \Exception(sprintf('Missing see tag with reference "%s"', $reference)); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param string $classFqsen |
49
|
|
|
* @param $element |
50
|
|
|
* @param $reference |
51
|
|
|
* @Then class ":classFqsen" has :number tag/tags see referencing :element descriptor ":reference" |
52
|
|
|
*/ |
53
|
|
|
public function classHasTagSeeReferencing($classFqsen, $number, $element, $reference) |
54
|
|
|
{ |
55
|
|
|
$this->classHasTagSeeReferencingWithDescription($classFqsen, $number, $element, $reference, new PyStringNode([],0)); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $classFqsen |
60
|
|
|
* @param $element |
61
|
|
|
* @param $reference |
62
|
|
|
* @param $description |
63
|
|
|
* @throws \Exception |
64
|
|
|
* @Then class ":classFqsen" has :number tag/tags see referencing :element descriptor ":reference" with description: |
65
|
|
|
*/ |
66
|
|
|
public function classHasTagSeeReferencingWithDescription($classFqsen, $number, $element, $reference, PyStringNode $description) |
67
|
|
|
{ |
68
|
|
|
$count = 0; |
69
|
|
|
$class = $this->findClassByFqsen($classFqsen); |
70
|
|
|
$seeTags = $class->getTags()->get('see', new Collection()); |
71
|
|
|
$element = '\\phpDocumentor\\Descriptor\\' .ucfirst($element) . 'Descriptor'; |
72
|
|
|
/** @var SeeTag $tag */ |
73
|
|
|
foreach ($seeTags as $tag) { |
74
|
|
|
$r = $tag->getReference(); |
75
|
|
|
if ($r instanceof $element |
76
|
|
|
&& $r->getFullyQualifiedStructuralElementName() === $reference |
77
|
|
|
&& $tag->getDescription() === $description->getRaw() |
78
|
|
|
) { |
79
|
|
|
$count++; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
Assert::assertEquals($number, $count, sprintf('Missing see tag with reference "%s"', $reference)); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|