Architecture testing: support for willcards #1072
Replies: 2 comments 1 reply
-
This will be very helpfull feature! But only if you separate files into folders correctly. Also there will be nice to have more complex quering of entities. Something like this: // What is available for now
test('Models have no suffixes', function () {
expect('App\Models')
->classes->not->toHaveSuffix('Model');
});
// What will be nice to have
test('Models have no suffixes', function () {
expect('App\Models')
->targeting(function ($fileInfo) {
// Check if file/class is exactly extends Model
})->not->toHaveSuffix('Model')
->targeting(function ($fileInfo) {
// Check if file/class is exactly extends Pivot
})->toHaveSuffix('Pivot');
});
// This will be helpful if you targeting files with much more complex patterns
// or if you filesystem structure does not separate entities in different folders
// like Laravel `Model` and `Pivot` classes (both of them stored in `app/Models` folder by default) @nunomaduro What do you think about that? |
Beta Was this translation helpful? Give feedback.
-
Got this working in a test environment as I need this functionality to effectively test in namespaces with multiple domains/modules. Need to see about adding unit tests for those cases as well. edit: PR for non-globstar implementation: pestphp/pest-plugin-arch#12 |
Beta Was this translation helpful? Give feedback.
-
Hi,
Currently,
Architecture
testing does not support willcards. If you are using an architecture per feature, it can be useful to employ wildcards.For example:
Beta Was this translation helpful? Give feedback.
All reactions