These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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-2018 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 Webmozart\Assert\Assert; |
||
18 | |||
19 | /** |
||
20 | * This class contains the context methods for tests of the see tag. |
||
21 | */ |
||
22 | final class SeeTagContext extends BaseContext implements Context |
||
23 | { |
||
24 | /** |
||
25 | * @param string $classFqsen |
||
26 | * @throws \Exception |
||
27 | * @Then class ":classFqsen" has a tag see referencing url ":reference" |
||
28 | */ |
||
29 | public function classHasTagSeeReferencingUrl($classFqsen, $reference) |
||
30 | { |
||
31 | $class = $this->findClassByFqsen($classFqsen); |
||
32 | $seeTags = $class->getTags()->get('see', []); |
||
33 | /** @var SeeTag $tag */ |
||
34 | foreach ($seeTags as $tag) { |
||
35 | if (((string) $tag->getReference()) === $reference) { |
||
36 | return; |
||
37 | } |
||
38 | } |
||
39 | |||
40 | throw new \Exception(sprintf('Missing see tag with reference "%s"', $reference)); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param string $classFqsen |
||
45 | * @Then class ":classFqsen" has :number tag/tags see referencing :element descriptor ":reference" |
||
46 | */ |
||
47 | public function classHasTagSeeReferencing($classFqsen, $number, $element, $reference) |
||
48 | { |
||
49 | $this->classHasTagSeeReferencingWithDescription($classFqsen, $number, $element, $reference, new PyStringNode([], 0)); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param string $classFqsen |
||
54 | * @throws \Exception |
||
55 | * @Then class ":classFqsen" has :number tag/tags see referencing :element descriptor ":reference" with description: |
||
56 | */ |
||
57 | public function classHasTagSeeReferencingWithDescription($classFqsen, $number, $element, $reference, PyStringNode $description) |
||
0 ignored issues
–
show
|
|||
58 | { |
||
59 | $count = 0; |
||
60 | $class = $this->findClassByFqsen($classFqsen); |
||
61 | $seeTags = $class->getTags()->get('see', []); |
||
62 | /** @var SeeTag $tag */ |
||
63 | foreach ($seeTags as $tag) { |
||
64 | $r = (string) $tag->getReference(); |
||
65 | if ($r === $reference |
||
66 | && ((string) $tag->getDescription()) === $description->getRaw() |
||
67 | ) { |
||
68 | ++$count; |
||
69 | } |
||
70 | } |
||
71 | |||
72 | Assert::eq($number, $count, sprintf('Missing see tag with reference "%s"', $reference)); |
||
73 | } |
||
74 | } |
||
75 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.