Skip to content

Fix locale discovery so provider tests run again - #1065

Open
a-vasyukov wants to merge 1 commit into
FakerPHP:2.0from
a-vasyukov:fix/locale-discovery-path
Open

Fix locale discovery so provider tests run again#1065
a-vasyukov wants to merge 1 commit into
FakerPHP:2.0from
a-vasyukov:fix/locale-discovery-path

Conversation

@a-vasyukov

Copy link
Copy Markdown

What is the reason for this PR?

  • A new feature
  • Fixed an issue

Faker\Test\TestCase::getAllLocales() globs __DIR__ . '/../../src/Faker/Provider/*_*'. On 2.0
that path resolves outside the repository, so the glob returns an empty array,
localeDataProvider() yields no data sets, and every test using it is silently skipped — PHPUnit
only reports skipped by data provider.

Both halves of the path went stale in the same commit — 67825a1 "Fix: Flatten directory structure"
(#773, 2023-09-20): tests moved from test/Faker/ to test/, and providers moved from
src/Faker/Provider to src/Provider. The glob was never updated, so these tests have not run
since then.

This affects 8 test methods in ProviderOverrideTest, 4 in InternetTest and 1 in PaymentTest,
across all 75 locales. On 1.24 the same code lives in test/Faker/TestCase.php, where the path
still resolves, so that branch is unaffected.

To reproduce on 2.0 before this change:

vendor/bin/phpunit --filter ProviderOverrideTest
# 8 tests, every one of them "skipped by data provider"

Author's checklist

Summary of changes

  • point the glob at src/Provider relative to test/
  • add a regression test asserting that locales are discovered; it fails with
    No locales were discovered if the path breaks again

Before:

Tests: 1416, Assertions: 10495, Skipped: 16.

After:

Tests: 2453, Assertions: 12457, Skipped: 34.

No test starts failing once they run — the suite stays green, only the count grows.

Review checklist

  • All checks have passed
  • Changes are added to the CHANGELOG.md
  • Changes are approved by maintainer

The glob in getAllLocales() still pointed at src/Faker/Provider relative
to test/Faker, so on 2.0 it resolved outside the repository and returned
an empty array. Every test using localeDataProvider was silently skipped:
8 methods in ProviderOverrideTest, 4 in InternetTest and 1 in PaymentTest,
across all 75 locales.
@a-vasyukov

Copy link
Copy Markdown
Author

Two weeks, no CI run — workflows on PRs from outside contributors need manual approval, so the
14162453 jump is still verified locally only.

Anything you'd like changed here? If patching the path by hand looks fragile, I can resolve the
package root instead, so a future directory move can't disable the data provider silently again.

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.

1 participant