foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Metadata in doc-comments is deprecated

Open Piairre opened this issue 1 year ago • 3 comments

We are currently writing functionals tests. We implement our test files with Factories and ResetDatabase this way:

<?php

namespace App\Tests\Func\Auth;

use App\DataFixtures\Factory\UserFactory;
use App\Tests\Func\CustomApiTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
// Some others imports


class AuthTest extends CustomApiTestCase
{

    use Factories;
    use ResetDatabase;

    public function testBadLogin(): void
    {
        // Our test
    }
}

Our tests pass, but we have this warning: Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

It appears on the _setUpFactories, _tearDownFactories, _resetDatabase and _resetSchema methods.

It appears that annotations will soon no longer be supported.

Piairre avatar Feb 05 '24 16:02 Piairre

Hi,

thaks for reporting this.

It seems that you're using PHPUnit 11. But Foundry still have not taken the phpunit 10 train, nor the whole Symfony world... we are more or less waiting for symfony phpunit bridge. I think you can add these warnings to a baseline, for sure when phpunit 12 will be released, we will use attributes :innocent:

nikophil avatar Feb 05 '24 17:02 nikophil

@Piairre, can you confirm if a test has the docblock AND the corresponding attribute, the deprecation is removed? I think the solution here is to have the attribute in addition to the docblock.

kbond avatar Feb 05 '24 17:02 kbond

From : https://docs.phpunit.de/en/11.0/annotations.html

PHPUnit will first look for metadata in attributes before it looks for annotations in comments. When metadata is found in attributes, metadata in comments is ignored. Support for metadata in comments is closed for further development: bugs will be fixed, but no new functionality will be implemented based on annotations.

this means the migration can be done smoothly

nikophil avatar Feb 06 '24 09:02 nikophil

Should be fixed by #562.

kbond avatar Mar 20 '24 16:03 kbond