pest icon indicating copy to clipboard operation
pest copied to clipboard

Arch testing expectation parameters for not->toBeUsedIn()

Open adamthehutt opened this issue 1 year ago • 1 comments

The documentation on architecture testing doesn't provide a lot of information on what is supported when using "toBeUsedIn".

I'm trying to test that no model observers are registered within a certain namespace. Some of the things I've tried that don't work:

arch('observers')
->expect('observe')
->not->toBeUsedIn('The\Namespace');

arch('observers')
->expect([Model::class, 'observe'])
->not->toBeUsedIn('The\Namespace');

arch('observers')
->expect(Model::class . '@observe')
->not->toBeUsedIn('The\Namespace');

None of these work. Is this kind of test possible? If so, what syntax should I be using? Thank you!

adamthehutt avatar Sep 16 '24 23:09 adamthehutt

According to the docs, this should work: https://pestphp.com/docs/arch-testing#content-tobeusedin

If it's not working, then this is a bug.

Question, though. Where did it tell you to use arch('observers') and ->expect('observe')?

danielh-official avatar Oct 29 '24 15:10 danielh-official

We don't support methods on the toBeUsedIn at the moment.

nunomaduro avatar Aug 03 '25 22:08 nunomaduro