Skip to content

Not reporting anymore as much parameters for functions #352

Closed
@williamdes

Description

@williamdes
1) Doctum\Tests\Parser\NodeVisitorTest::testUpdateMethodParametersFromTags
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
     0 => 'The "param2" parameter of the method "fun1" is missing a @param tag'
-    1 => 'The method "fun1" has "5" @param tags but only "2" where expected.'
 )

/home/runner/work/doctum/doctum/tests/Parser/NodeVisitorTest.php:402

2) Doctum\Tests\Parser\NodeVisitorTest::testUpdateMethodParametersFromInvalidTags
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
     0 => 'The "param2" parameter of the method "fun1" is missing a @param tag'
-    1 => 'The method "fun1" has "6" @param tags but only "2" where expected.'
-    2 => 'The method "fun1" has "1" invalid @param tags.'
-    3 => 'Invalid @param tag on "fun1": "array[\Illuminate\Notifications\Channels\Notification]  $notification"'
+    1 => 'The method "fun1" has "3" @param tags but only "2" where expected.'
 )

/home/runner/work/doctum/doctum/tests/Parser/NodeVisitorTest.php:483

3) Doctum\Tests\Parser\NodeVisitorTest::testUpdateMethodParametersFromInvalidTagsReport
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
-Array &0 (
-    0 => 'The "notification" parameter of the method "fun1" is missing a @param tag'
-    1 => 'The method "fun1" has "1" invalid @param tags.'
-    2 => 'Invalid @param tag on "fun1": "array[\Illuminate\Notifications\Channels\Notification]  $notification"'
-)
+Array &0 ()

/home/runner/work/doctum/doctum/tests/Parser/NodeVisitorTest.php:520

FAILURES!
Tests: 177, Assertions: [36](https://github.com/code-lts/doctum/actions/runs/4397526274/jobs/7700727629#step:7:37)0, Failures: 3.
    /**
     * @see NodeVisitor::updateMethodParametersFromTags
     */
    public function testUpdateMethodParametersFromTags(): void
    {
        $parserContext  = new ParserContext(new TrueFilter(), new DocBlockParser(), new Standard());
        $docBlockParser = new DocBlockParser();
        $docBlockNode   = $docBlockParser->parse(
            '/**' . "\n"
            . '* @param type1 $param1 Description' . "\n"
            . '* @param $param8 Description 4' . "\n"
            . '* @param $param9' . "\n"
            . '* @param foo' . "\n"
            . '* @param type1 $param4 Description 4' . "\n"
            . '**/' . "\n",
            $parserContext
        );

        $visitor  = new NodeVisitor($parserContext);
        $function = new FunctionReflection('fun1', 0);

        $param1 = (new ParameterReflection('param1', 0));
        $param1->setHint('array');
        $function->addParameter($param1);

        $param2 = (new ParameterReflection('param2', 0));
        $function->addParameter($param2);

        $this->assertSame(
            [
                'The "param2" parameter of the method "fun1" is missing a @param tag',
                'The method "fun1" has "5" @param tags but only "2" where expected.',
            ],
            $this->callMethod(
                $visitor,
                'updateMethodParametersFromTags',
                [
                $function,
                $docBlockNode->getTag('param'),
                ]
            )
        );
    }

    /**
     * @see NodeVisitor::updateMethodParametersFromTags
     */
    public function testUpdateMethodParametersFromInvalidTags(): void
    {
        $parserContext  = new ParserContext(new TrueFilter(), new DocBlockParser(), new Standard());
        $docBlockParser = new DocBlockParser();
        $docBlockNode   = $docBlockParser->parse(
            '/**' . "\n"
            . '* @param type1 $param1 Description' . "\n"
            . '* @param $param8 Description 4' . "\n"
            . '* @param $param9' . "\n"
            . '* @param foo' . "\n"
            . '* @param type1 $param4 Description 4' . "\n"
            . '* @param array[\Illuminate\Notifications\Channels\Notification]  $notification' . "\n"
            . '**/' . "\n",
            $parserContext
        );

        $visitor  = new NodeVisitor($parserContext);
        $function = new FunctionReflection('fun1', 0);

        $param1 = (new ParameterReflection('param1', 0));
        $param1->setHint('array');
        $function->addParameter($param1);

        $param2 = (new ParameterReflection('param2', 0));
        $function->addParameter($param2);

        $this->assertSame(
            [
                'The "param2" parameter of the method "fun1" is missing a @param tag',
                'The method "fun1" has "6" @param tags but only "2" where expected.',
                'The method "fun1" has "1" invalid @param tags.',
                'Invalid @param tag on "fun1": "array[\Illuminate\Notifications\Channels\Notification]  $notification"',
            ],
            $this->callMethod(
                $visitor,
                'updateMethodParametersFromTags',
                [
                $function,
                $docBlockNode->getTag('param'),
                ]
            )
        );
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions