Skip to content

Comments

feat: add toBeCasedCorrectly arch test assertion#1455

Open
SimonBroekaert wants to merge 2 commits intopestphp:4.xfrom
SimonBroekaert:feat/to_be_cased_correctly_arch_test_assertion
Open

feat: add toBeCasedCorrectly arch test assertion#1455
SimonBroekaert wants to merge 2 commits intopestphp:4.xfrom
SimonBroekaert:feat/to_be_cased_correctly_arch_test_assertion

Conversation

@SimonBroekaert
Copy link

@SimonBroekaert SimonBroekaert commented Aug 22, 2025

What:

  • Bug Fix
  • New Feature

Description:

This PR adds a new arch test assertion that compares the file path and namespace casing with each other to detect casing errors.

As most developers work on Mac OS or Windows, which by default have case insensitive file systems, these casing spelling errors might not be caught until deployed on linux environments.

This feature helps solve this issue by comparing both namespace and file path with each other.

Important:

This PR depends on the following PR in the pest-plugin-arch plugin: pestphp/pest-plugin-arch#27

Example:

File path: app/Providers/AppServiceProvider.php

<?php

namespace App\providers

class AppServiceProvider {}

The wrongly cased namespace part 'providers' will not cause a 'Class not found' exception on Mac OS, but will on linux.

With this feature, we can add the following test:

arch()
    ->expect('App')
    ->toBeCasedCorrectly();

This will catch the miss-cased namespaces / file paths

@nunomaduro
Copy link
Member

i like it.. can you add a test please?

@SimonBroekaert SimonBroekaert force-pushed the feat/to_be_cased_correctly_arch_test_assertion branch from adfebb1 to 1675dd1 Compare February 17, 2026 18:04
@SimonBroekaert
Copy link
Author

i like it.. can you add a test please?

@nunomaduro , Thank you for considering this feature.

I've added some tests.

Keep in mind that they will fail until the pestphp/pest-plugin-arch#27 PR has been merged. (See the important note in the description).

To get the namespaces working for the tests, I've also added a new commit to that PR so that the Composer::userNamespaces() can find the namespace of the Fixture files.

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.

2 participants