Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test runner deprecations when docblock is needed #5693

Closed
Jean85 opened this issue Feb 5, 2024 · 4 comments
Closed

Test runner deprecations when docblock is needed #5693

Jean85 opened this issue Feb 5, 2024 · 4 comments

Comments

@Jean85
Copy link
Contributor

Jean85 commented Feb 5, 2024

Q A
PHPUnit version 11.0.2
PHP version 8.3
Installation Method Composer

Summary

I'm working on Paraunit to make it fully compatible with PHPUnit 11, but my CI is reporting a ton of deprecations because many of my test methods have PHPDoc annotations due to static analysis.

Unfortu

Current behavior

I get dozens of deprecations in this form:

  1. Metadata found in doc-comment for class Tests[...][...]Test. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

How to reproduce

Put a @param or @return on top of a test method or a data provider.

Expected behavior

No deprecations for annotations that are not PHPUnit-related.

@sebastianbergmann
Copy link
Owner

Thank you for your report. Unfortunately, I cannot reproduce it:

tests/end-to-end/regression/5693/Issue5693Test.php

<?php declare(strict_types=1);
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PHPUnit\Metadata\Parser\TestFixture\Issue5693Test;

use PHPUnit\Framework\TestCase;
use stdClass;

final class Issue5693Test extends TestCase
{
    /**
     * @return stdClass
     */
    public function testOne(): stdClass
    {
        $this->assertTrue(true);

        return new stdClass;
    }
}
$ ./phpunit tests/end-to-end/regression/5693/Issue5693Test.php
PHPUnit 11.0.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.2
Configuration: /usr/local/src/phpunit/phpunit.xml

.                                                                   1 / 1 (100%)

Time: 00:00.012, Memory: 6.00 MB

OK (1 test, 1 assertion)

Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.

Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.

@sebastianbergmann sebastianbergmann added the status/waiting-for-feedback Waiting for feedback from original reporter label Feb 5, 2024
@sebastianbergmann
Copy link
Owner

This and this are the only two places where this deprecation event is emitted.

This deprecation event is only emitted when at least one PHPUnit\Metadata\Metadata object was created based on the doc-comment of a test class or based on the doc-comment of a test method (!empty($result)).

@Jean85
Copy link
Contributor Author

Jean85 commented Feb 5, 2024

My bad, I've double checked my tests and it seems that the deprecations go away when I comment out the ProphecyTrait coming from phpspec/prophecy-phpunit.

I'll dig some more and see if I can file an issue (or a PR) there, since I'm already using phpspec/prophecy#616 to use it before the real compat is released.

@Jean85 Jean85 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2024
@sebastianbergmann sebastianbergmann removed type/bug Something is broken status/waiting-for-feedback Waiting for feedback from original reporter labels Feb 5, 2024
@Jean85
Copy link
Contributor Author

Jean85 commented Feb 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants