Session data in phpunittest

@KevinPfeifer Kevin Pfeifer
Tue, 03 Sep 2024 15:02:11 +0000

behaviors are part of the model, therefore they don’t have access to either the request nor the logged in user directly.

Usually you add GitHub - UseMuffin/Footprint: CakePHP plugin to allow passing currently logged in user to model layer. to your application and therefore have easy access to the logged in user inside your model via the options array.

Otherwise the only way you can access the logged in user inside your behavios is by passing down the logged in user to the method you are calling (e.g. inside your controller)