Skip to content

feat: add toBeCasedCorrectly arch test assertion#1455

Open
SimonBroekaert wants to merge 1 commit intopestphp:4.xfrom
SimonBroekaert:feat/to_be_cased_correctly_arch_test_assertion
Open

feat: add toBeCasedCorrectly arch test assertion#1455
SimonBroekaert wants to merge 1 commit 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

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