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

chore: upgrade PHPUnit 9 => 10 #780

Closed
wants to merge 3 commits into from
Closed

chore: upgrade PHPUnit 9 => 10 #780

wants to merge 3 commits into from

Conversation

Chris53897
Copy link
Contributor

changes for sebastian/comparator

#746 rebased against master.
Migrate Config PHPUnit 9 => 10
Only Allow PHPUnit 10.

I did not have a closer look to the comperator changes.

changes for sebastian/comparator
@Chris53897
Copy link
Contributor Author

Tests are failing, because of
DeprecatedMethod: The method PHPUnit\Framework\TestCase::setLocale has been marked as deprecated (see https://psalm.dev/001)

replace setLocale() calls with setlocale()
@Chris53897
Copy link
Contributor Author

I replaced it with direct calls to setlocale().
But i am not sure if this is enough.

Copy link
Member

@frederikbosch frederikbosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Only with regard to setlocale I would solve that differently

@@ -13,6 +15,6 @@ public function setUp(): void
{
parent::setUp();

$this->setLocale(LC_ALL, 'ru_RU.UTF-8');
setlocale(LC_ALL, 'ru_RU.UTF-8');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a file called tests/LocaleTest.php, with the following content.

declare(strict_types=1);

namespace Tests\Money;

trait LocaleTest
{
    public static function setLocale(int $category, string $locale, \Closure $callback)
    {
        $currentLocale= \setlocale($category, 0);
        try {
            \setlocale($category, $locale);
            $callback();
        } finally {
            \setlocale($category, $currentLocale);
        }
    }
}

And then remove setlocale from setUp but simply use it in the test file as follows

use Tests\Money\LocaleTest;

public static function the_test()
{
    LocaleTest::setLocale(LC_ALL, 'ru_RU.UTF-8', function () {
        // test content here
    });
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed your suggestion. But i did need to make some changes to make it work.
The name setLocale is already taken with other parameters.

Filename changed from LocaleTest to Locale

I am not sure if i did everythink correct. Please have a look.

@frederikbosch frederikbosch mentioned this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants